- map<const TrackType *, TrackType3D *>::const_iterator i = tracks.find(&tt);
- if(i==tracks.end())
- throw KeyError("Unknown track type");
-
- return *i->second;
+ ObjectMap::iterator i = objects.find(&ot);
+ if(i!=objects.end())
+ return *i->second;
+
+ ObjectType3D *ot3d = 0;
+ if(const TrackType *tt = dynamic_cast<const TrackType *>(&ot))
+ ot3d = new TrackType3D(*this, *tt);
+ else if(const SignalType *st = dynamic_cast<const SignalType *>(&ot))
+ ot3d = new SignalType3D(*this, *st);
+ else if(const VehicleType *vt = dynamic_cast<const VehicleType *>(&ot))
+ ot3d = new VehicleType3D(*this, *vt);
+ else
+ throw key_error(&ot);
+
+ objects[&ot] = ot3d;
+ return *ot3d;