- GL::Vector3 corner(vt.get_length()/2, vt.get_width()/2, vt.get_height());
-
- GL::MeshBuilder bld(body_mesh);
- bld.begin(GL::QUADS);
- bld.normal(1, 0, 0);
- bld.vertex(corner.x, -corner.y, 0);
- bld.vertex(corner.x, corner.y, 0);
- bld.vertex(corner.x, corner.y, corner.z);
- bld.vertex(corner.x, -corner.y, corner.z);
- bld.normal(-1, 0, 0);
- bld.vertex(-corner.x, corner.y, 0);
- bld.vertex(-corner.x, -corner.y, 0);
- bld.vertex(-corner.x, -corner.y, corner.z);
- bld.vertex(-corner.x, corner.y, corner.z);
- bld.normal(0, 1, 0);
- bld.vertex(corner.x, corner.y, 0);
- bld.vertex(-corner.x, corner.y, 0);
- bld.vertex(-corner.x, corner.y, corner.z);
- bld.vertex(corner.x, corner.y, corner.z);
- bld.normal(0, -1, 0);
- bld.vertex(-corner.x, -corner.y, 0);
- bld.vertex(corner.x, -corner.y, 0);
- bld.vertex(corner.x, -corner.y, corner.z);
- bld.vertex(-corner.x, -corner.y, corner.z);
- bld.normal(0, 0, 1);
- bld.vertex(-corner.x, -corner.y, corner.z);
- bld.vertex(corner.x, -corner.y, corner.z);
- bld.vertex(corner.x, corner.y, corner.z);
- bld.vertex(-corner.x, corner.y, corner.z);
- bld.end();
+ body_object = get_object(vt.get_object());
+
+ for(unsigned i=0; i<bogie_objects.size(); ++i)
+ bogie_objects[i] = get_object(vt.get_bogies()[i].object);
+}
+
+VehicleType3D::~VehicleType3D()
+{
+ for(map<string, GL::Object *>::iterator i=objects.begin(); i!=objects.end(); ++i)
+ delete i->second;
+}
+
+const GL::Object *VehicleType3D::get_axle_object(unsigned) const
+{
+ return 0;
+}
+
+const GL::Object *VehicleType3D::get_bogie_object(unsigned i) const
+{
+ if(i>=bogie_objects.size())
+ throw InvalidParameterValue("Bogie index out of range");
+ return bogie_objects[i];
+}
+
+const GL::Object *VehicleType3D::get_bogie_axle_object(unsigned, unsigned) const
+{
+ return 0;
+}
+
+GL::Object *VehicleType3D::get_object(const string &name)
+{
+ if(name.empty())
+ return 0;
+
+ GL::Object *&ptr = objects[name];
+ if(!ptr)
+ {
+ ptr = new GL::Object;
+ DataFile::load(*ptr, name);
+ }
+ return ptr;