comparison engine/core/view/renderers/lightrenderer.cpp @ 680:60621d858548

* Fixed the image/animation functions in GenericRenderer and LightRenderer. The functions now consider the camera zoom level. * Added the forgotten LightEdit plugin for the editor.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 21 Nov 2010 15:58:14 +0000
parents e3140f01749d
children
comparison
equal deleted inserted replaced
679:49fb0370f8e1 680:60621d858548
245 Point p = m_anchor.getCalculatedPoint(cam, layer); 245 Point p = m_anchor.getCalculatedPoint(cam, layer);
246 if(m_anchor.getLayer() == layer) { 246 if(m_anchor.getLayer() == layer) {
247 Image* img = &imagepool->getImage(m_image); 247 Image* img = &imagepool->getImage(m_image);
248 Rect r; 248 Rect r;
249 Rect viewport = cam->getViewPort(); 249 Rect viewport = cam->getViewPort();
250 r.x = p.x-img->getWidth()/2; 250 unsigned int widtht = round(img->getWidth() * cam->getZoom());
251 r.y = p.y-img->getHeight()/2; 251 unsigned int height = round(img->getHeight() * cam->getZoom());
252 r.w = img->getWidth(); 252 r.x = p.x-widtht/2;
253 r.h = img->getHeight(); 253 r.y = p.y-height/2;
254 r.w = widtht;
255 r.h = height;
254 renderbackend->changeBlending(m_src, m_dst); 256 renderbackend->changeBlending(m_src, m_dst);
255 if(r.intersects(viewport)) 257 if(r.intersects(viewport))
256 img->render(r); 258 img->render(r);
257 } 259 }
258 } 260 }
294 Animation& animation = animpool->getAnimation(m_animation); 296 Animation& animation = animpool->getAnimation(m_animation);
295 int animtime = scaleTime(m_time_scale, TimeManager::instance()->getTime() - m_start_time) % animation.getDuration(); 297 int animtime = scaleTime(m_time_scale, TimeManager::instance()->getTime() - m_start_time) % animation.getDuration();
296 Image* img = animation.getFrameByTimestamp(animtime); 298 Image* img = animation.getFrameByTimestamp(animtime);
297 Rect r; 299 Rect r;
298 Rect viewport = cam->getViewPort(); 300 Rect viewport = cam->getViewPort();
299 r.x = p.x-img->getWidth()/2; 301 unsigned int widtht = round(img->getWidth() * cam->getZoom());
300 r.y = p.y-img->getHeight()/2; 302 unsigned int height = round(img->getHeight() * cam->getZoom());
301 r.w = img->getWidth(); 303 r.x = p.x-widtht/2;
302 r.h = img->getHeight(); 304 r.y = p.y-height/2;
305 r.w = widtht;
306 r.h = height;
303 renderbackend->changeBlending(m_src, m_dst); 307 renderbackend->changeBlending(m_src, m_dst);
304 if(r.intersects(viewport)) 308 if(r.intersects(viewport))
305 img->render(r); 309 img->render(r);
306 } 310 }
307 } 311 }
341 Point p = m_anchor.getCalculatedPoint(cam, layer); 345 Point p = m_anchor.getCalculatedPoint(cam, layer);
342 if(m_anchor.getLayer() == layer) { 346 if(m_anchor.getLayer() == layer) {
343 Image* img = &imagepool->getImage(m_image); 347 Image* img = &imagepool->getImage(m_image);
344 Rect r; 348 Rect r;
345 Rect viewport = cam->getViewPort(); 349 Rect viewport = cam->getViewPort();
346 r.x = p.x-m_width/2; 350 unsigned int widtht = round(m_width * cam->getZoom());
347 r.y = p.y-m_height/2; 351 unsigned int height = round(m_height * cam->getZoom());
348 r.w = m_width; 352 r.x = p.x-widtht/2;
349 r.h = m_height; 353 r.y = p.y-height/2;
354 r.w = widtht;
355 r.h = height;
350 renderbackend->changeBlending(m_src, m_dst); 356 renderbackend->changeBlending(m_src, m_dst);
351 if(r.intersects(viewport)) 357 if(r.intersects(viewport))
352 img->render(r); 358 img->render(r);
353 } 359 }
354 } 360 }
390 m_alpha_ref(0.0) { 396 m_alpha_ref(0.0) {
391 } 397 }
392 void LightRendererSimpleLightInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 398 void LightRendererSimpleLightInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
393 Point p = m_anchor.getCalculatedPoint(cam, layer); 399 Point p = m_anchor.getCalculatedPoint(cam, layer);
394 if(m_anchor.getLayer() == layer) { 400 if(m_anchor.getLayer() == layer) {
401 double zoom = cam->getZoom();
395 renderbackend->changeBlending(m_src, m_dst); 402 renderbackend->changeBlending(m_src, m_dst);
396 renderbackend->drawLightPrimitive(p, m_intensity, m_radius, m_subdivisions, m_xstretch, m_ystretch, m_red, m_green, m_blue); 403 renderbackend->drawLightPrimitive(p, m_intensity, m_radius, m_subdivisions, m_xstretch * zoom, m_ystretch * zoom, m_red, m_green, m_blue);
397 } 404 }
398 } 405 }
399 void LightRendererSimpleLightInfo::setStencil(uint8_t stencil_ref, float alpha_ref) { 406 void LightRendererSimpleLightInfo::setStencil(uint8_t stencil_ref, float alpha_ref) {
400 m_stencil = true; 407 m_stencil = true;
401 m_stencil_ref = stencil_ref; 408 m_stencil_ref = stencil_ref;