30 #include "video/renderbackend.h"
31 #include "util/math/fife_math.h"
32 #include "util/log/logger.h"
33 #include "model/metamodel/grids/cellgrid.h"
34 #include "model/structures/instance.h"
35 #include "model/structures/layer.h"
36 #include "model/structures/location.h"
38 #include "view/camera.h"
39 #include "blockinginforenderer.h"
43 static Logger _log(LM_VIEWVIEW);
45 BlockingInfoRenderer::BlockingInfoRenderer(RenderBackend* renderbackend, int32_t position):
46 RendererBase(renderbackend, position) {
53 BlockingInfoRenderer::BlockingInfoRenderer(
const BlockingInfoRenderer& old):
55 m_color(old.m_color) {
59 RendererBase* BlockingInfoRenderer::clone() {
60 return new BlockingInfoRenderer(*
this);
63 BlockingInfoRenderer::~BlockingInfoRenderer() {
66 BlockingInfoRenderer* BlockingInfoRenderer::getInstance(IRendererContainer* cnt) {
67 return dynamic_cast<BlockingInfoRenderer*
>(cnt->getRenderer(
"BlockingInfoRenderer"));
70 void BlockingInfoRenderer::render(Camera* cam, Layer* layer, RenderList& instances) {
71 CellGrid* cg = layer->getCellGrid();
73 FL_WARN(_log,
"No cellgrid assigned to layer, cannot draw grid");
77 Rect cv = cam->getViewPort();
78 RenderList::const_iterator instance_it = instances.begin();
79 for (;instance_it != instances.end(); ++instance_it) {
80 Instance* instance = (*instance_it)->instance;
81 if (!instance->getObject()->isBlocking() || !instance->isBlocking()) {
84 std::vector<ExactModelCoordinate> vertices;
85 cg->getVertices(vertices, instance->getLocationRef().getLayerCoordinates());
86 std::vector<ExactModelCoordinate>::const_iterator it = vertices.begin();
87 int32_t halfind = vertices.size() / 2;
88 ScreenPoint firstpt = cam->toScreenCoordinates(cg->toMapCoordinates(*it));
89 Point pt1(firstpt.x, firstpt.y);
92 for (; it != vertices.end(); it++) {
93 ScreenPoint pts = cam->toScreenCoordinates(cg->toMapCoordinates(*it));
94 pt2.x = pts.x; pt2.y = pts.y;
97 m_renderbackend->drawLine(cpt1, cpt2, m_color.r, m_color.g, m_color.b);
100 m_renderbackend->drawLine(pt2, Point(firstpt.x, firstpt.y), m_color.r, m_color.g, m_color.b);
101 ScreenPoint spt1 = cam->toScreenCoordinates(cg->toMapCoordinates(vertices[0]));
102 Point pt3(spt1.x, spt1.y);
103 ScreenPoint spt2 = cam->toScreenCoordinates(cg->toMapCoordinates(vertices[halfind]));
104 Point pt4(spt2.x, spt2.y);
105 m_renderbackend->drawLine(pt3, pt4, m_color.r, m_color.g, m_color.b);
109 void BlockingInfoRenderer::setColor(uint8_t r, uint8_t g, uint8_t b) {
virtual void setEnabled(bool enabled)