FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
instancerenderer.h
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_INSTANCERENDERER_H
23 #define FIFE_INSTANCERENDERER_H
24 
25 // Standard C++ library includes
26 #include <string>
27 #include <list>
28 
29 // 3rd party library includes
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 #include "view/rendererbase.h"
36 
37 namespace FIFE {
38  class Location;
39  class RenderBackend;
40  class ImagePool;
41  class AnimationPool;
42 
43  class InstanceRenderer: public RendererBase {
44  public:
50  InstanceRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool);
51 
52  InstanceRenderer(const InstanceRenderer& old);
53 
54  RendererBase* clone();
55 
58  virtual ~InstanceRenderer();
59  void render(Camera* cam, Layer* layer, RenderList& instances);
60  std::string getName() { return "InstanceRenderer"; }
61 
64  void addOutlined(Instance* instance, int r, int g, int b, int width);
65 
68  void addColored(Instance* instance, int r, int g, int b);
69 
72  void addTransparentArea(Instance* instance, const std::list<std::string> &groups, unsigned int w, unsigned int h, unsigned char trans, bool front = true);
73 
76  void removeOutlined(Instance* instance);
77 
80  void removeColored(Instance* instance);
81 
84  void removeTransparentArea(Instance* instance);
85 
88  void removeAllOutlines();
89 
92  void removeAllColored();
93 
96  void removeAllTransparentAreas();
97 
101  void addIgnoreLight(const std::list<std::string> &groups);
102 
105  void removeIgnoreLight(const std::list<std::string> &groups);
106 
109  void removeAllIgnoreLight();
110 
113  static InstanceRenderer* getInstance(IRendererContainer* cnt);
114 
117  RenderBackend* getRenderBackend() const {return m_renderbackend;}
118 
119  void reset();
120 
121  private:
122  ImagePool* m_imagepool;
123  AnimationPool* m_animationpool;
124  bool m_area_layer;
125  std::list<std::string> m_unlit_groups;
126 
127  // contains per-instance information for outline drawing
128  class OutlineInfo {
129  public:
130  uint8_t r;
131  uint8_t g;
132  uint8_t b;
133  int width;
134  bool dirty;
135  Image* outline;
136  Image* curimg;
137  OutlineInfo();
138  ~OutlineInfo();
139  };
140  // contains per-instance information for overlay drawing
141  class ColoringInfo {
142  public:
143  uint8_t r;
144  uint8_t g;
145  uint8_t b;
146  bool dirty;
147  Image* overlay;
148  Image* curimg;
149  ColoringInfo();
150  ~ColoringInfo();
151  };
152  class AreaInfo {
153  public:
154  Instance* instance;
155  //std::string groups;
156  std::list<std::string> groups;
157  unsigned int w;
158  unsigned int h;
159  unsigned char trans;
160  bool front;
161  float z;
162  AreaInfo();
163  ~AreaInfo();
164  };
165  typedef std::map<Instance*, OutlineInfo> InstanceToOutlines_t;
166  typedef std::map<Instance*, ColoringInfo> InstanceToColoring_t;
167  typedef std::map<Instance*, AreaInfo> InstanceToAreas_t;
168 
169  InstanceToOutlines_t m_instance_outlines;
170  InstanceToColoring_t m_instance_colorings;
171  InstanceToAreas_t m_instance_areas;
172 
175  Image* bindOutline(OutlineInfo& info, RenderItem& vc, Camera* cam);
176  Image* bindColoring(ColoringInfo& info, RenderItem& vc, Camera* cam);
177  };
178 }
179 
180 #endif