X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Fvehicle.cpp;h=f14f3c2c238df933943cc938fabffdf6231241f2;hb=1ff06c5bc46a677fa389ef86c6b26664368f1653;hp=4fbac68c0ea36c952bbe537022315d7db383d923;hpb=e5cd9e4fbc577036a0385c985b6b65df8218d0a2;p=r2c2.git diff --git a/source/3d/vehicle.cpp b/source/3d/vehicle.cpp index 4fbac68..f14f3c2 100644 --- a/source/3d/vehicle.cpp +++ b/source/3d/vehicle.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 */ @@ -11,9 +11,10 @@ Distributed under the GPL #include "vehicle.h" #include "vehicletype.h" +using namespace std; using namespace Msp; -namespace Marklin { +namespace R2C2 { Vehicle3D::Vehicle3D(Layout3D &l, Vehicle &v): layout(l), @@ -36,18 +37,58 @@ Point Vehicle3D::get_node() const return Point(p.x, p.y, p.z+0.01+vehicle.get_type().get_height()); } +bool Vehicle3D::is_visible() const +{ + return vehicle.get_track(); +} + void Vehicle3D::render(const GL::Tag &tag) const { + if(!vehicle.get_track()) + return; + if(tag==0) { GL::PushMatrix push_mat; const Point &pos = vehicle.get_position(); - GL::translate(pos.x, pos.y, pos.z+0.01); + GL::translate(pos.x, pos.y, pos.z); GL::rotate(vehicle.get_direction()*180/M_PI, 0, 0, 1); - type.get_body_mesh().draw(); + if(const GL::Object *obj = type.get_body_object()) + obj->render(tag); + + const vector &axles = vehicle.get_type().get_axles(); + for(unsigned i=0; irender(tag); + } + + const vector &bogies = vehicle.get_type().get_bogies(); + for(unsigned i=0; irender(tag); + } + + if(bogies[i].rotate_object) + GL::rotate(180, 0, 0, 1); + if(const GL::Object *obj = type.get_bogie_object(i)) + obj->render(tag); + } } } -} // namespace Marklin +} // namespace R2C2