]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/vehicle.cpp
Add single get_stuff methods with index to VehicleType
[r2c2.git] / source / 3d / vehicle.cpp
index 7e4814b008b03a64b588479792959329d7254cf9..8027a1999d3827ab14dad36ced4816703f070a34 100644 (file)
@@ -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
 */
@@ -14,7 +14,7 @@ Distributed under the GPL
 using namespace std;
 using namespace Msp;
 
-namespace Marklin {
+namespace R2C2 {
 
 Vehicle3D::Vehicle3D(Layout3D &l, Vehicle &v):
        layout(l),
@@ -64,6 +64,7 @@ void Vehicle3D::render(const GL::Tag &tag) const
                        {
                                GL::PushMatrix push_mat2;
                                GL::translate(axles[i].position, 0, axles[i].wheel_dia/2);
+                               GL::rotate(vehicle.get_axle(i).angle*180/M_PI, 0, 1, 0);
                                obj->render(tag);
                        }
 
@@ -72,7 +73,7 @@ void Vehicle3D::render(const GL::Tag &tag) const
                {
                        GL::PushMatrix push_mat2;
                        GL::translate(bogies[i].position, 0, 0);
-                       float angle = vehicle.get_bogie_direction(i)*180/M_PI;
+                       float angle = vehicle.get_bogie(i).direction*180/M_PI;
                        GL::rotate(angle, 0, 0, 1);
 
                        for(unsigned j=0; j<bogies[i].axles.size(); ++j)
@@ -80,6 +81,7 @@ void Vehicle3D::render(const GL::Tag &tag) const
                                {
                                        GL::PushMatrix push_mat3;
                                        GL::translate(bogies[i].axles[j].position, 0, bogies[i].axles[j].wheel_dia/2);
+                                       GL::rotate(vehicle.get_bogie_axle(i, j).angle*180/M_PI, 0, 1, 0);
                                        obj->render(tag);
                                }
 
@@ -88,7 +90,21 @@ void Vehicle3D::render(const GL::Tag &tag) const
                        if(const GL::Object *obj = type.get_bogie_object(i))
                                obj->render(tag);
                }
+
+               const vector<VehicleType::Rod> &rods = vehicle.get_type().get_rods();
+               for(unsigned i=0; i<rods.size(); ++i)
+                       if(const GL::Object *obj = type.get_rod_object(i))
+                       {
+                               GL::PushMatrix push_mat2;
+                               const Point &rpos = vehicle.get_rod(i).position;
+                               float angle = vehicle.get_rod(i).angle;
+                               GL::translate(rpos.x, rpos.y, rpos.z);
+                               if(rods[i].mirror_object)
+                                       GL::scale(1, -1, 1);
+                               GL::rotate(angle*180/M_PI, 0, -1, 0);
+                               obj->render(tag);
+                       }
        }
 }
 
-} // namespace Marklin
+} // namespace R2C2