zoomedit: Make vertices visible.
This commit is contained in:
parent
acb1721e94
commit
16397f4474
4 changed files with 42 additions and 6 deletions
3
Portal.h
3
Portal.h
|
@ -57,8 +57,7 @@ class Portal : public LevelObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void move(float x, float y) {
|
virtual void move(float x, float y) {
|
||||||
pos.setX(pos.getX()+x);
|
pos += Vertex(x, y);
|
||||||
pos.setY(pos.getY()+y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void rotate(float a) {
|
virtual void rotate(float a) {
|
||||||
|
|
34
Renderer.cpp
34
Renderer.cpp
|
@ -69,6 +69,15 @@ void Renderer::drawCircle(const Vertex &m, float r, int n) {
|
||||||
glEnd();
|
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) {
|
void Renderer::drawCross(const Vertex &m, float r) {
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
|
||||||
|
@ -90,6 +99,15 @@ void Renderer::renderObject(const LevelObject &object, bool selected, bool highl
|
||||||
renderPortal(*(Portal*)&object, selected, highlighted, scale);
|
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) {
|
void Renderer::renderRoom(const Room &room, bool selected, bool highlighted, float scale) {
|
||||||
if(selected)
|
if(selected)
|
||||||
glColor4f(0.0f, 0.7f, 1.0f, 0.2f);
|
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);
|
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) {
|
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);
|
glVertex2f(portal.getPosition().getX()+x, portal.getPosition().getY()+y);
|
||||||
|
|
||||||
glEnd();
|
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) {
|
void Renderer::render(const Level &level, const Rectangle &rect, float scale) {
|
||||||
|
|
|
@ -19,11 +19,14 @@ class Renderer {
|
||||||
protected:
|
protected:
|
||||||
void fillPolygon(const Polygon &polygon);
|
void fillPolygon(const Polygon &polygon);
|
||||||
void drawPolygon(const Polygon &polygon, bool close = true);
|
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 drawCircle(const Vertex &m, float r, int n = 64);
|
||||||
void drawCross(const Vertex &m, float r);
|
void drawCross(const Vertex &m, float r);
|
||||||
|
|
||||||
void renderObject(const LevelObject &object, bool selected, bool highlighted, float scale);
|
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 renderRoom(const Room &room, bool selected, bool highlighted, float scale);
|
||||||
void renderPlayerStart(const PlayerStart &start, 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);
|
void renderPortal(const Portal &portal, bool selected, bool highlighted, float scale);
|
||||||
|
|
8
Room.h
8
Room.h
|
@ -30,10 +30,10 @@ class Room : public Polygon, public LevelObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void move(float x, float y) {
|
virtual void move(float x, float y) {
|
||||||
for(iterator v = begin(); v != end(); v++) {
|
Vertex m(x, y);
|
||||||
v->setX(v->getX()+x);
|
|
||||||
v->setY(v->getY()+y);
|
for(iterator v = begin(); v != end(); v++)
|
||||||
}
|
*v += m;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void rotate(float a) {
|
virtual void rotate(float a) {
|
||||||
|
|
Reference in a new issue