From c4aadd98230f3b9ab50398b715164ff874ea8a61 Mon Sep 17 00:00:00 2001 From: neoraider Date: Wed, 13 Feb 2008 21:06:01 +0000 Subject: zoomedit: Vertices are selectable now. --- Room.h | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'Room.h') diff --git a/Room.h b/Room.h index c9f5dcb..c2d96d9 100644 --- a/Room.h +++ b/Room.h @@ -3,10 +3,12 @@ #include "Polygon.h" #include "LevelObject.h" +#include "VertexProvider.h" +#include "LevelVertex.h" #include -class Room : public Polygon, public LevelObject { +class Room : public Polygon, public LevelObject, public VertexProvider { private: std::string name; float height; @@ -22,9 +24,18 @@ class Room : public Polygon, public LevelObject { float getHeight() const {return height;} void setHeight(float height) {this->height = height;} - virtual bool hit(const Vertex &v) const {return contains(v);} + virtual bool hit(const Vertex &v, float scale) const {return contains(v);} virtual int getPriority() const {return 0;} + virtual std::vector > getChildren() { + std::vector > children; + + for(size_t i = 0; i < size(); i++) + children.push_back(SharedPtr(new LevelVertex(this, i))); + + return children; + } + virtual const char* getType() const { return "Room"; } @@ -56,6 +67,31 @@ class Room : public Polygon, public LevelObject { return ret / size(); } + + virtual const Vertex* getVertex(size_t id) const { + return &at(id); + } + + virtual size_t getVertexCount() const { + return size(); + } + + virtual void moveVertex(size_t id, float x, float y) { + at(id) += Vertex(x, y); + } + + virtual void rotateVertex(size_t id, float a) { + Vertex z = at(id); + float s = sinf(a); + float c = cosf(a); + + for(iterator v = begin(); v != end(); v++) { + *v -= z; + v->setLocation(c*v->getX() - s*v->getY(), c*v->getY() + s*v->getX()); + *v += z; + } + } + }; #endif /*ROOM_H_*/ -- cgit v1.2.3