22 #ifndef FIFE_LIGHTRENDERER_H
23 #define FIFE_LIGHTRENDERER_H
34 #include "view/rendererbase.h"
42 class LightRendererNode {
44 LightRendererNode(Instance* attached_instance,
const Location &relative_location, Layer* relative_layer,
const Point &relative_point = Point(0,0));
45 LightRendererNode(Instance* attached_instance,
const Location &relative_location,
const Point &relative_point = Point(0,0));
46 LightRendererNode(Instance* attached_instance, Layer* relative_layer,
const Point &relative_point = Point(0,0));
47 LightRendererNode(Instance* attached_instance,
const Point &relative_point = Point(0,0));
48 LightRendererNode(
const Location &attached_location, Layer* relative_layer,
const Point &relative_point = Point(0,0));
49 LightRendererNode(
const Location &attached_location,
const Point &relative_point = Point(0,0));
50 LightRendererNode(Layer* attached_layer,
const Point &relative_point = Point(0,0));
51 LightRendererNode(
const Point &attached_point);
54 void setAttached(Instance* attached_instance,
const Location &relative_location,
const Point &relative_point);
55 void setAttached(Instance* attached_instance,
const Location &relative_location);
56 void setAttached(Instance* attached_instance,
const Point &relative_point);
57 void setAttached(Instance* attached_instance);
58 void setAttached(
const Location &attached_location,
const Point &relative_point);
59 void setAttached(
const Location &attached_location);
60 void setAttached(Layer* attached_layer);
61 void setAttached(
const Point &attached_point);
63 void setRelative(
const Location &relative_location);
64 void setRelative(
const Location &relative_location, Point relative_point);
65 void setRelative(
const Point &relative_point);
67 Instance* getAttachedInstance();
68 Location getAttachedLocation();
69 Layer* getAttachedLayer();
70 Point getAttachedPoint();
72 Location getOffsetLocation();
73 Point getOffsetPoint();
75 Instance* getInstance();
76 Location getLocation();
80 Point getCalculatedPoint(Camera* cam, Layer* layer);
88 class LightRendererElementInfo {
90 virtual void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {};
91 virtual std::string getName() {
return 0; };
92 virtual LightRendererNode* getNode() {
return NULL; };
93 virtual int getId() {
return -1; };
94 virtual int getSrcBlend() {
return -1; };
95 virtual int getDstBlend() {
return -1; };
96 virtual void setStencil(uint8_t stencil_ref,
float alpha_ref) {};
97 virtual int getStencil() {
return 0; };
98 virtual float getAlpha() {
return 0; };
99 virtual void removeStencil() {};
100 virtual std::vector<uint8_t> getColor() {
return std::vector<uint8_t>(); };
101 virtual float getRadius() {
return 0; };
102 virtual int getSubdivisions() {
return 0; };
103 virtual float getXStretch() {
return 0; };
104 virtual float getYStretch() {
return 0; };
105 virtual ~LightRendererElementInfo() {};
108 class LightRendererImageInfo :
public LightRendererElementInfo {
110 void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool);
111 std::string getName() {
return "image"; };
112 LightRendererNode* getNode() {
return &m_anchor; };
113 int getId() {
return m_image; };
114 int getSrcBlend() {
return m_src; };
115 int getDstBlend() {
return m_dst; };
116 void setStencil(uint8_t stencil_ref,
float alpha_ref);
119 void removeStencil();
120 LightRendererImageInfo(LightRendererNode n,
int image,
int src,
int dst);
121 virtual ~LightRendererImageInfo() {};
123 LightRendererNode m_anchor;
128 uint8_t m_stencil_ref;
131 class LightRendererAnimationInfo :
public LightRendererElementInfo {
133 void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool);
134 std::string getName() {
return "animation"; };
135 LightRendererNode* getNode() {
return &m_anchor; };
136 int getId() {
return m_animation; };
137 int getSrcBlend() {
return m_src; };
138 int getDstBlend() {
return m_dst; };
139 void setStencil(uint8_t stencil_ref,
float alpha_ref);
142 void removeStencil();
143 LightRendererAnimationInfo(LightRendererNode n,
int animation,
int src,
int dst);
144 virtual ~LightRendererAnimationInfo() {};
146 LightRendererNode m_anchor;
150 unsigned int m_start_time;
153 uint8_t m_stencil_ref;
156 class LightRendererSimpleLightInfo :
public LightRendererElementInfo {
158 void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool);
159 std::string getName() {
return "simple"; };
160 LightRendererNode* getNode() {
return &m_anchor; };
161 int getSrcBlend() {
return m_src; };
162 int getDstBlend() {
return m_dst; };
163 void setStencil(uint8_t stencil_ref,
float alpha_ref);
166 void removeStencil();
167 std::vector<uint8_t> getColor();
168 float getRadius() {
return m_radius; };
169 int getSubdivisions() {
return m_subdivisions; };
170 float getXStretch() {
return m_xstretch; };
171 float getYStretch() {
return m_ystretch; };
172 LightRendererSimpleLightInfo(LightRendererNode n, uint8_t intensity,
float radius,
int subdivisions,
float xstretch,
float ystretch, uint8_t r, uint8_t g, uint8_t b,
int src,
int dst);
173 virtual ~LightRendererSimpleLightInfo() {};
175 LightRendererNode m_anchor;
187 uint8_t m_stencil_ref;
190 class LightRendererResizeInfo :
public LightRendererElementInfo {
192 void render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool);
193 std::string getName() {
return "resize"; };
194 LightRendererNode* getNode() {
return &m_anchor; };
195 int getId() {
return m_image; };
196 int getSrcBlend() {
return m_src; };
197 int getDstBlend() {
return m_dst; };
198 void setStencil(uint8_t stencil_ref,
float alpha_ref);
201 void removeStencil();
202 LightRendererResizeInfo(LightRendererNode n,
int image,
int width,
int height,
int src,
int dst);
203 virtual ~LightRendererResizeInfo() {};
205 LightRendererNode m_anchor;
212 uint8_t m_stencil_ref;
215 class LightRenderer:
public RendererBase {
221 LightRenderer(RenderBackend* renderbackend,
int position, ImagePool* imagepool, AnimationPool* animpool);
223 LightRenderer(
const LightRenderer& old);
229 virtual ~LightRenderer();
230 void render(Camera* cam, Layer* layer, RenderList& instances);
231 std::string getName() {
return "LightRenderer"; }
235 static LightRenderer* getInstance(IRendererContainer* cnt);
237 void addImage(
const std::string &group, LightRendererNode n,
int image,
int src=-1,
int dst=-1);
238 void addAnimation(
const std::string &group, LightRendererNode n,
int animation,
int src=-1,
int dst=-1);
239 void addSimpleLight(
const std::string &group, LightRendererNode n, uint8_t intensity,
float radius,
int subdivisions,
float xstretch,
float ystretch, uint8_t r, uint8_t g, uint8_t b,
int src=-1,
int dst=-1);
240 void resizeImage(
const std::string &group, LightRendererNode n,
int image,
int width,
int height,
int src=-1,
int dst=-1);
241 void addStencilTest(
const std::string &group, uint8_t stencil_ref=0,
float alpha_ref=0.0);
242 void removeStencilTest(
const std::string &group);
243 std::list<std::string> getGroups();
244 std::vector<LightRendererElementInfo*> getLightInfo(
const std::string &group);
245 void removeAll(
const std::string &group);
248 ImagePool* m_imagepool;
249 AnimationPool* m_animationpool;
250 std::map<std::string, std::vector<LightRendererElementInfo*> > m_groups;