X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Flayout.cpp;h=be19b0020a9a2680b64e4750690cd288b0b8c1c6;hb=346d933cb7d5d2e016ce235fb4336e202ca7708e;hp=db419d3639065c2e76a574702ebfe062085b6eae;hpb=4049f5bdacfdb61247f3c74fc5f748990be7bd4d;p=r2c2.git diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index db419d3..be19b00 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -1,6 +1,8 @@ +#include "beamgate.h" #include "layout.h" #include "signal.h" #include "track.h" +#include "utility.h" #include "vehicle.h" using namespace std; @@ -14,6 +16,8 @@ Layout3D::Layout3D(Layout &l): { // South, 15° from zenith sun.set_position(0, -0.259, 0.966, 0); + sun.set_diffuse(GL::Color(0.9)); + lighting.set_ambient(GL::Color(0.4)); lighting.attach(0, sun); layout.signal_object_added.connect(sigc::mem_fun(this, &Layout3D::object_added)); @@ -26,6 +30,8 @@ Layout3D::Layout3D(Layout &l): Layout3D::~Layout3D() { + while(!utilities.empty()) + delete *utilities.begin(); while(!objects.empty()) delete objects.begin()->second; } @@ -35,7 +41,11 @@ void Layout3D::get_bounds(Vector &minp, Vector &maxp) const Geometry::BoundingBox bbox; for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i) - bbox = bbox|i->second->get_object().get_type().get_shape()->get_axis_aligned_bounding_box(); + { + const Shape *shape = i->second->get_object().get_shape(); + if(shape) + bbox = bbox|shape->get_axis_aligned_bounding_box(); + } minp = bbox.get_minimum_point(); maxp = bbox.get_maximum_point(); @@ -46,7 +56,7 @@ void Layout3D::add(Object3D &o) insert_unique(objects, &o.get_object(), &o); } -Object3D &Layout3D::get(Object &o) const +Object3D &Layout3D::get_3d(Object &o) const { return *get_item(objects, &o); } @@ -56,6 +66,16 @@ void Layout3D::remove(Object3D &o) objects.erase(&o.get_object()); } +void Layout3D::add(Utility3D &u) +{ + utilities.insert(&u); +} + +void Layout3D::remove(Utility3D &u) +{ + utilities.erase(&u); +} + void Layout3D::object_added(Object &o) { if(Track *t = dynamic_cast(&o)) @@ -64,6 +84,8 @@ void Layout3D::object_added(Object &o) new Signal3D(*this, *s); else if(Vehicle *v = dynamic_cast(&o)) new Vehicle3D(*this, *v); + else if(BeamGate *g = dynamic_cast(&o)) + new BeamGate3D(*this, *g); } void Layout3D::object_removed(Object &o)