diff options
author | neoraider <devnull@localhost> | 2008-02-09 13:21:00 +0100 |
---|---|---|
committer | neoraider <devnull@localhost> | 2008-02-09 13:21:00 +0100 |
commit | 16397f4474fbbe5f140a5e68b3bb6934170bf2e3 (patch) | |
tree | 78fe6e556228bb95d28d68d38d51faa77d95f132 | |
parent | acb1721e94a49a4941bb11dfc2f832c3848aa204 (diff) | |
download | zoomedit-16397f4474fbbe5f140a5e68b3bb6934170bf2e3.tar zoomedit-16397f4474fbbe5f140a5e68b3bb6934170bf2e3.zip |
zoomedit: Make vertices visible.
-rw-r--r-- | Portal.h | 3 | ||||
-rw-r--r-- | Renderer.cpp | 34 | ||||
-rw-r--r-- | Renderer.h | 3 | ||||
-rw-r--r-- | Room.h | 8 |
4 files changed, 42 insertions, 6 deletions
@@ -57,8 +57,7 @@ class Portal : public LevelObject { } virtual void move(float x, float y) { - pos.setX(pos.getX()+x); - pos.setY(pos.getY()+y); + pos += Vertex(x, y); } virtual void rotate(float a) { diff --git a/Renderer.cpp b/Renderer.cpp index c8ecac2..e2ededc 100644 --- a/Renderer.cpp +++ b/Renderer.cpp @@ -69,6 +69,15 @@ void Renderer::drawCircle(const Vertex &m, float r, int n) { glEnd(); } +void Renderer::fillCircle(const Vertex &m, float r, int n) { + glBegin(GL_POLYGON); + + for(int i = 0; i < n; i++) + glVertex2f(m.getX()+r*cosf(2*M_PI*i/n), m.getY()+r*sinf(2*M_PI*i/n)); + + glEnd(); +} + void Renderer::drawCross(const Vertex &m, float r) { glBegin(GL_LINES); @@ -90,6 +99,15 @@ void Renderer::renderObject(const LevelObject &object, bool selected, bool highl renderPortal(*(Portal*)&object, selected, highlighted, scale); } +void Renderer::renderVertex(const Vertex &vertex, bool selected, bool highlighted, float scale) { + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + fillCircle(vertex, 3/scale, 16); + + glLineWidth(1.0f); + glColor4f(9.0f, 0.7f, 0.0f, 0.9f); + drawCircle(vertex, 3/scale, 16); +} + void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, float scale) { if(selected) glColor4f(0.0f, 0.7f, 1.0f, 0.2f); @@ -112,6 +130,11 @@ void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, flo } drawPolygon(room); + + if(selected || highlighted) { + for(Room::const_iterator v = room.begin(); v != room.end(); v++) + renderVertex(*v, false, false, scale); + } } void Renderer::renderPlayerStart(const PlayerStart &start, bool selected, bool highlighted, float scale) { @@ -169,6 +192,17 @@ void Renderer::renderPortal(const Portal &portal, bool selected, bool highlighte glVertex2f(portal.getPosition().getX()+x, portal.getPosition().getY()+y); glEnd(); + + if(highlighted || selected) { + renderVertex(Vertex(portal.getPosition().getX()-x+ts, portal.getPosition().getY()-y-tc), + false, false, scale); + renderVertex(Vertex(portal.getPosition().getX()-x-ts, portal.getPosition().getY()-y+tc), + false, false, scale); + renderVertex(Vertex(portal.getPosition().getX()+x+ts, portal.getPosition().getY()+y-tc), + false, false, scale); + renderVertex(Vertex(portal.getPosition().getX()+x-ts, portal.getPosition().getY()+y+tc), + false, false, scale); + } } void Renderer::render(const Level &level, const Rectangle &rect, float scale) { @@ -19,11 +19,14 @@ class Renderer { protected: void fillPolygon(const Polygon &polygon); void drawPolygon(const Polygon &polygon, bool close = true); + void fillCircle(const Vertex &m, float r, int n = 64); void drawCircle(const Vertex &m, float r, int n = 64); void drawCross(const Vertex &m, float r); void renderObject(const LevelObject &object, bool selected, bool highlighted, float scale); + void renderVertex(const Vertex &vertex, bool selected, bool highlighted, float scale); + void renderRoom(const Room &room, bool selected, bool highlighted, float scale); void renderPlayerStart(const PlayerStart &start, bool selected, bool highlighted, float scale); void renderPortal(const Portal &portal, bool selected, bool highlighted, float scale); @@ -30,10 +30,10 @@ class Room : public Polygon, public LevelObject { } virtual void move(float x, float y) { - for(iterator v = begin(); v != end(); v++) { - v->setX(v->getX()+x); - v->setY(v->getY()+y); - } + Vertex m(x, y); + + for(iterator v = begin(); v != end(); v++) + *v += m; } virtual void rotate(float a) { |