Mercurial > fife-parpg
comparison engine/core/view/renderers/genericrenderer.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 |
---|---|
326 Point p = m_anchor.getCalculatedPoint(cam, layer); | 326 Point p = m_anchor.getCalculatedPoint(cam, layer); |
327 if(m_anchor.getLayer() == layer) { | 327 if(m_anchor.getLayer() == layer) { |
328 Image* img = &imagepool->getImage(m_image); | 328 Image* img = &imagepool->getImage(m_image); |
329 Rect r; | 329 Rect r; |
330 Rect viewport = cam->getViewPort(); | 330 Rect viewport = cam->getViewPort(); |
331 r.x = p.x-img->getWidth()/2; | 331 unsigned int widtht = round(img->getWidth() * cam->getZoom()); |
332 r.y = p.y-img->getHeight()/2; | 332 unsigned int height = round(img->getHeight() * cam->getZoom()); |
333 r.w = img->getWidth(); | 333 r.x = p.x-widtht/2; |
334 r.h = img->getHeight(); | 334 r.y = p.y-height/2; |
335 r.w = widtht; | |
336 r.h = height; | |
335 if(r.intersects(viewport)) | 337 if(r.intersects(viewport)) |
336 img->render(r); | 338 img->render(r); |
337 } | 339 } |
338 } | 340 } |
339 | 341 |
350 Animation& animation = animpool->getAnimation(m_animation); | 352 Animation& animation = animpool->getAnimation(m_animation); |
351 int animtime = scaleTime(m_time_scale, TimeManager::instance()->getTime() - m_start_time) % animation.getDuration(); | 353 int animtime = scaleTime(m_time_scale, TimeManager::instance()->getTime() - m_start_time) % animation.getDuration(); |
352 Image* img = animation.getFrameByTimestamp(animtime); | 354 Image* img = animation.getFrameByTimestamp(animtime); |
353 Rect r; | 355 Rect r; |
354 Rect viewport = cam->getViewPort(); | 356 Rect viewport = cam->getViewPort(); |
355 r.x = p.x-img->getWidth()/2; | 357 unsigned int widtht = round(img->getWidth() * cam->getZoom()); |
356 r.y = p.y-img->getHeight()/2; | 358 unsigned int height = round(img->getHeight() * cam->getZoom()); |
357 r.w = img->getWidth(); | 359 r.x = p.x-widtht/2; |
358 r.h = img->getHeight(); | 360 r.y = p.y-height/2; |
361 r.w = widtht; | |
362 r.h = height; | |
359 if(r.intersects(viewport)) | 363 if(r.intersects(viewport)) |
360 img->render(r); | 364 img->render(r); |
361 } | 365 } |
362 } | 366 } |
363 | 367 |
395 void GenericRendererResizeInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { | 399 void GenericRendererResizeInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { |
396 Point p = m_anchor.getCalculatedPoint(cam, layer); | 400 Point p = m_anchor.getCalculatedPoint(cam, layer); |
397 if(m_anchor.getLayer() == layer) { | 401 if(m_anchor.getLayer() == layer) { |
398 Image* img = &imagepool->getImage(m_image); | 402 Image* img = &imagepool->getImage(m_image); |
399 Rect r; | 403 Rect r; |
400 r.x = p.x-m_width/2; | 404 Rect viewport = cam->getViewPort(); |
401 r.y = p.y-m_height/2; | 405 unsigned int widtht = round(m_width * cam->getZoom()); |
402 r.w = m_width; | 406 unsigned int height = round(m_height * cam->getZoom()); |
403 r.h = m_height; | 407 r.x = p.x-widtht/2; |
404 renderbackend->disableLighting(); | 408 r.y = p.y-height/2; |
405 img->render(r); | 409 r.w = widtht; |
406 renderbackend->enableLighting(); | 410 r.h = height; |
411 if(r.intersects(viewport)) { | |
412 img->render(r); | |
413 } | |
407 } | 414 } |
408 } | 415 } |
409 | 416 |
410 GenericRenderer* GenericRenderer::getInstance(IRendererContainer* cnt) { | 417 GenericRenderer* GenericRenderer::getInstance(IRendererContainer* cnt) { |
411 return dynamic_cast<GenericRenderer*>(cnt->getRenderer("GenericRenderer")); | 418 return dynamic_cast<GenericRenderer*>(cnt->getRenderer("GenericRenderer")); |