00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "video/renderbackend.h"
00031 #include "util/math/fife_math.h"
00032 #include "util/log/logger.h"
00033 #include "model/metamodel/grids/cellgrid.h"
00034 #include "model/structures/instance.h"
00035 #include "model/structures/layer.h"
00036 #include "model/structures/location.h"
00037
00038 #include "view/camera.h"
00039 #include "blockinginforenderer.h"
00040
00041
00042 namespace FIFE {
00043 static Logger _log(LM_VIEWVIEW);
00044
00045 BlockingInfoRenderer::BlockingInfoRenderer(RenderBackend* renderbackend, int position):
00046 RendererBase(renderbackend, position) {
00047 setEnabled(false);
00048 }
00049
00050 BlockingInfoRenderer::BlockingInfoRenderer(const BlockingInfoRenderer& old):
00051 RendererBase(old) {
00052 }
00053
00054 RendererBase* BlockingInfoRenderer::clone() {
00055 return new BlockingInfoRenderer(*this);
00056 }
00057
00058 BlockingInfoRenderer::~BlockingInfoRenderer() {
00059 }
00060
00061 void BlockingInfoRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) {
00062 CellGrid* cg = layer->getCellGrid();
00063 if (!cg) {
00064 FL_WARN(_log, "No cellgrid assigned to layer, cannot draw grid");
00065 return;
00066 }
00067
00068 Rect cv = cam->getViewPort();
00069 std::vector<Instance*>::const_iterator instance_it = instances.begin();
00070 for (;instance_it != instances.end(); ++instance_it) {
00071 Instance* instance = *instance_it;
00072 if (!instance->getObject()->isBlocking()) {
00073 continue;
00074 }
00075 std::vector<ExactModelCoordinate> vertices;
00076 cg->getVertices(vertices, instance->getLocationRef().getLayerCoordinates());
00077 int halfind = vertices.size() / 2;
00078 ScreenPoint spt1 = cam->toScreenCoordinates(cg->toMapCoordinates(vertices[0]));
00079 Point pt1(spt1.x, spt1.y);
00080 ScreenPoint spt2 = cam->toScreenCoordinates(cg->toMapCoordinates(vertices[halfind]));
00081 Point pt2(spt2.x, spt2.y);
00082 m_renderbackend->drawLine(pt1, pt2, 0, 255, 0);
00083 }
00084 }
00085 }