11 Layout3D::Layout3D(Layout &l):
13 catalogue(layout.get_catalogue())
15 // South, 15° from zenith
16 sun.set_position(0, -0.259, 0.966, 0);
17 lighting.attach(0, sun);
19 layout.signal_object_added.connect(sigc::mem_fun(this, &Layout3D::object_added));
20 layout.signal_object_removed.connect(sigc::mem_fun(this, &Layout3D::object_removed));
22 const set<Object *> &lobjs = layout.get_all<Object>();
23 for(set<Object *>::iterator i=lobjs.begin(); i!=lobjs.end(); ++i)
29 while(!objects.empty())
30 delete objects.begin()->second;
33 void Layout3D::get_bounds(Vector &minp, Vector &maxp) const
35 Geometry::BoundingBox<float, 3> bbox;
37 for(ObjectMap::const_iterator i=objects.begin(); i!=objects.end(); ++i)
38 bbox = bbox|i->second->get_object().get_type().get_shape()->get_axis_aligned_bounding_box();
40 minp = bbox.get_minimum_point();
41 maxp = bbox.get_maximum_point();
44 void Layout3D::add(Object3D &o)
46 insert_unique(objects, &o.get_object(), &o);
49 Object3D &Layout3D::get(Object &o) const
51 return *get_item(objects, &o);
54 void Layout3D::remove(Object3D &o)
56 objects.erase(&o.get_object());
59 void Layout3D::object_added(Object &o)
61 if(Track *t = dynamic_cast<Track *>(&o))
62 new Track3D(*this, *t);
63 else if(Signal *s = dynamic_cast<Signal *>(&o))
64 new Signal3D(*this, *s);
65 else if(Vehicle *v = dynamic_cast<Vehicle *>(&o))
66 new Vehicle3D(*this, *v);
69 void Layout3D::object_removed(Object &o)
71 ObjectMap::iterator i = objects.find(&o);