X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Fvehicletype.cpp;h=27fb883a985241ef12b66ea8a4e56d5cff9f91b3;hb=460c64181aca1a134d74cb15ea4ad3bb4f275b60;hp=b283eddebe896b1307881fef7b96098117dd64b1;hpb=30df355287abd0bfe1189e616056335505287e9a;p=r2c2.git diff --git a/source/3d/vehicletype.cpp b/source/3d/vehicletype.cpp index b283edd..27fb883 100644 --- a/source/3d/vehicletype.cpp +++ b/source/3d/vehicletype.cpp @@ -1,6 +1,6 @@ /* $Id$ -This file is part of the MSP Märklin suite +This file is part of R²C² Copyright © 2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -29,9 +29,9 @@ T get(const map ¶ms, const string &key, T def = T()) } -namespace Marklin { +namespace R2C2 { -VehicleType3D::VehicleType3D(const Catalogue3D &c, const VehicleType &t): +VehicleType3D::VehicleType3D(Catalogue3D &c, const VehicleType &t): catalogue(c), type(t), body_object(0), @@ -51,6 +51,10 @@ VehicleType3D::VehicleType3D(const Catalogue3D &c, const VehicleType &t): for(vector::const_iterator j=i->axles.begin(); j!=i->axles.end(); ++j) axle_objects.back().push_back(get_object(j->object)); } + + const vector &rods = type.get_rods(); + for(vector::const_iterator i=rods.begin(); i!=rods.end(); ++i) + rod_objects.push_back(get_object(i->object)); } VehicleType3D::~VehicleType3D() @@ -82,6 +86,13 @@ const GL::Object *VehicleType3D::get_bogie_axle_object(unsigned i, unsigned j) c return axle_objects[i+1][j]; } +const GL::Object *VehicleType3D::get_rod_object(unsigned i) const +{ + if(i>=rod_objects.size()) + throw InvalidParameterValue("Rod index out of range"); + return rod_objects[i]; +} + GL::Object *VehicleType3D::get_object(const string &name) { if(name.empty()) @@ -133,10 +144,7 @@ GL::Object *VehicleType3D::get_object(const string &name) } } else - { - ptr = new GL::Object; - DataFile::load(*ptr, name); - } + return catalogue.get(name); } return ptr; } @@ -154,7 +162,7 @@ GL::Technique *VehicleType3D::create_technique(const map ¶ms mat->set_diffuse(GL::Color(1)); pass.set_material(mat); GL::Texture2D *tex = new GL::Texture2D; - tex->storage(GL::RGB, 2, 1, 0); + tex->storage(GL::RGB, 2, 1); tex->set_min_filter(GL::NEAREST); tex->set_mag_filter(GL::NEAREST); unsigned char data[6] = { color>>16, color>>8, color, color2>>16, color2>>8, color2 }; @@ -342,4 +350,4 @@ GL::Mesh *VehicleType3D::create_flat_wagon(const map ¶ms) return mesh; } -} // namespace Marklin +} // namespace R2C2