commit 4e75e57835e4b4a1573119d1c68c08e3ef33cfc2
parent 0d9e460631e22f726355f436331ab2143516adcf
Author: Yoann <yoann.b87@voila.fr>
Date: Sun, 11 Dec 2011 21:04:31 +0100
Ajout de la classe trottoirRoute.
Diffstat:
4 files changed, 58 insertions(+), 46 deletions(-)
diff --git a/all_includes.hh b/all_includes.hh
@@ -28,6 +28,7 @@ class Chose;
#include "rules/batiment.hh"
#include "rules/carrefour.hh"
#include "rules/route.hh"
+#include "rules/trottoirroute.hh"
#include "rules/quadrilatere.hh"
#include "rules/quadcroix.hh"
#include "rules/quadrect.hh"
diff --git a/rules/route.cpp b/rules/route.cpp
@@ -17,58 +17,22 @@ std::ostream& operator<<(std::ostream& os, const Route& r) {
return os << "Route " << r.ne << "-" << r.se << "-" << r.sw << "-" << r.nw;
}
-/*
void Route::triangulation() {
triangles.reserve(2);
addTriangle(new Triangle(ne, nw, sw, 0x36, 0x36, 0x36));
addTriangle(new Triangle(sw, se, ne, 0x36, 0x36, 0x36));
-}*/
+}
// Version avec trottoirs.
-void Route::triangulation() {
- triangles.reserve(10);
+/*void Route::triangulation() {
+ triangles.reserve(2);
Vertex nne, nnw, nse, nsw; // Nouvel emplacement de la route.
- Vertex pvLne, pvLnw, pvLsw, pvLse; // Trottoir Nord (pv => pavement)
- Vertex pvRne, pvRnw, pvRsw, pvRse; // Trottoir Sud (pv => pavement)
- Vertex pvLCne, pvLCnw, pvLCsw, pvLCse; // Rebord du trottoir gauche.
- Vertex pvRCne, pvRCnw, pvRCsw, pvRCse; // rebord du trottoir droit.
- pvLnw = nw + Vertex(0,0,20);
- pvLsw = sw + Vertex(0,0,20);
- pvRne = ne + Vertex(0,0,20);
- pvRse = se + Vertex(0,0,20);
- pvLne = nw + ((ne - nw)/6);
- pvLse = sw + ((se - sw)/6);
- pvRnw = ne - ((ne - nw)/6);
- pvRsw = se - ((se - sw)/6);
- nnw = pvLne;
- nsw = pvLse;
- nne = pvRnw;
- nse = pvRsw;
- pvLne.z += 20;
- pvLse.z += 20;
- pvRnw.z += 20;
- pvRsw.z += 20;
- pvLCnw = pvLne;
- pvLCsw = pvLse;
- pvLCne = nnw;
- pvLCse = nsw;
- pvRCnw = nne;
- pvRCsw = nse;
- pvRCne = pvRnw;
- pvRCse = pvRsw;
-
+ nnw = nw + ((ne - nw)/6);
+ nsw = sw + ((se - sw)/6);
+ nne = ne - ((ne - nw)/6);
+ nse = se - ((se - sw)/6);
- addTriangle(new Triangle(pvLne, pvLnw, pvLsw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvLsw, pvLse, pvLne, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvRne, pvRnw, pvRsw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvRsw, pvRse, pvRne, 0x66, 0x66, 0x66));
-
- addTriangle(new Triangle(pvLCne, pvLCnw, pvLCsw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvLCsw, pvLCse, pvLCne, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvRCne, pvRCnw, pvRCsw, 0x66, 0x66, 0x66));
- addTriangle(new Triangle(pvRCsw, pvRCse, pvRCne, 0x66, 0x66, 0x66));
-
- addTriangle(new Triangle(nne, nnw, nsw, 0x36, 0x36, 0x36));
- addTriangle(new Triangle(nsw, nse, nne, 0x36, 0x36, 0x36));
-}
+ addChild(new TrottoirRoute(nnw, nsw, sw, nw, 20));
+ addChild(new TrottoirRoute(ne, se, nse, nne,20));
+}*/
diff --git a/rules/trottoirroute.cpp b/rules/trottoirroute.cpp
@@ -0,0 +1,27 @@
+#include "all_includes.hh"
+
+TrottoirRoute::TrottoirRoute(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height) {
+ this->ne = ne;
+ this->nw = nw;
+ this->se = se;
+ this->sw = sw;
+ this->height = height;
+ triangulation();
+}
+
+bool TrottoirRoute::subdivide() {
+ // TODO
+ return false;
+}
+
+void TrottoirRoute::triangulation() {
+ addTriangle(new Triangle(ne + Vertex(0,0,height), nw + Vertex(0,0,height) , sw + Vertex(0,0,height), 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(ne + Vertex(0,0,height), nw + Vertex(0,0,height), sw + Vertex(0,0,height), 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw + Vertex(0,0,height), se + Vertex(0,0,height), ne + Vertex(0,0,height), 0x66, 0x66, 0x66));
+
+ addTriangle(new Triangle(nw + Vertex(0,0,height), nw, sw, 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(sw, sw + Vertex(0,0,height), nw + Vertex(0,0,height), 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(ne, ne + Vertex(0,0,height), se + Vertex(0,0,height), 0x66, 0x66, 0x66));
+ addTriangle(new Triangle(se + Vertex(0,0,height), se, ne, 0x66, 0x66, 0x66));
+}
diff --git a/rules/trottoirroute.hh b/rules/trottoirroute.hh
@@ -0,0 +1,20 @@
+#ifndef _RULES_TROTTOIRROUTE_HH_
+#define _RULES_TRTTOIRROUTE_HH_
+
+#include "all_includes.hh"
+
+class TrottoirRoute : public Chose {
+ private :
+ Vertex ne;
+ Vertex se;
+ Vertex sw;
+ Vertex nw;
+ int height;
+
+ public :
+ TrottoirRoute(Vertex ne, Vertex se, Vertex sw, Vertex nw, int height);
+ virtual bool subdivide();
+ virtual void triangulation();
+};
+
+#endif