From 85e58bd658d3b572ed598e0460965d7827f4e901 Mon Sep 17 00:00:00 2001 From: neoraider Date: Tue, 15 Apr 2008 01:04:02 +0000 Subject: zoomedit: * Connected TopView to RenderArea --- src/View/TopView.cpp | 31 ++++++++++++++++--------------- src/View/TopView.h | 10 ++++++++-- src/View/View.h | 12 ------------ 3 files changed, 24 insertions(+), 29 deletions(-) (limited to 'src/View') diff --git a/src/View/TopView.cpp b/src/View/TopView.cpp index 43f0bc1..38d4824 100644 --- a/src/View/TopView.cpp +++ b/src/View/TopView.cpp @@ -18,28 +18,29 @@ */ #include "TopView.h" -#include "../Data/Level.h" -#include "../Data/Room.h" -#include "../Data/Triangle.h" -#include +#include +#include +#include +#include namespace ZoomEdit { namespace View { void TopView::renderRoom(Data::Room *room) { - const std::list &triangles = room->getTriangles(); - std::list floor; + const std::list &floor = room->getFloorTriangles(); - for(std::list::const_iterator t = triangles.begin(); t != triangles.end(); ++t) { - Data::Vector v1 = (*t)->getVertex(1) - (*t)->getVertex(0); - Data::Vector v2 = (*t)->getVertex(2) - (*t)->getVertex(0); - - Data::Vector n = (v1 % v2); - n.normalize(); - - if(n*Data::Vector(0, 1, 0) > std::cos(45)) - floor.push_back(*t); + glColor4f(0.0f, 0.7f, 1.0f, 0.3f); + + glBegin(GL_TRIANGLES); + + for(std::list::const_iterator t = floor.begin(); t != floor.end(); ++t) { + for(int i = 0; i < 3; ++i) { + const Data::Vertex &v = (*t)->getVertex(i); + glVertex2f(v.getX(), v.getZ()); + } } + + glEnd(); } void TopView::render() { diff --git a/src/View/TopView.h b/src/View/TopView.h index c5af1de..5141e51 100644 --- a/src/View/TopView.h +++ b/src/View/TopView.h @@ -25,6 +25,7 @@ namespace ZoomEdit { namespace Data { +class Level; class Room; } @@ -32,12 +33,17 @@ namespace View { class TopView : public View { private: + Data::Level *level; + void renderRoom(Data::Room *room); public: - TopView(Data::Level *level0 = 0) : View(level0) {} + TopView(Data::Level *level0 = 0) : level(level0) {} + + Data::Level* getLevel() {return level;} + void setLevel(Data::Level *level0) {level = level0;} - void render(); + virtual void render(); }; } diff --git a/src/View/View.h b/src/View/View.h index c7755f2..32c201e 100644 --- a/src/View/View.h +++ b/src/View/View.h @@ -21,24 +21,12 @@ #define ZOOMEDIT_VIEW_H_ namespace ZoomEdit { - -namespace Data { -class Level; -} - namespace View { class View { - protected: - Data::Level *level; - public: - View(Data::Level *level0) : level(level0) {} virtual ~View() {} - virtual Data::Level* getLevel() {return level;} - virtual void setLevel(Data::Level *level0) {level = level0;} - virtual void render() = 0; }; -- cgit v1.2.3