]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/axle.cpp
Remove the GTK-based remote control program
[r2c2.git] / source / 3d / axle.cpp
index 6b0e1f58315ced7adbcc774efff0d2e035b7da5e..4344eeacf76a480b52a63fc597c7d4b992318291 100644 (file)
@@ -1,5 +1,3 @@
-#include <msp/gl/matrix.h>
-#include <msp/gl/renderer.h>
 #include "axle.h"
 #include "vehicle.h"
 #include "vehicletype.h"
@@ -9,34 +7,17 @@ using namespace Msp;
 namespace R2C2 {
 
 Axle3D::Axle3D(const Vehicle3D &v, unsigned a):
-       GL::ObjectInstance(*v.get_type().get_fixed_axle_object(a)),
-       vehicle(v.get_vehicle()),
+       VehiclePart3D(v, *v.get_type().get_axle_object(a)),
        bogie(0),
-       axle(vehicle.get_fixed_axle(a))
-{ }
-
-Axle3D::Axle3D(const Vehicle3D &v, unsigned b, unsigned a):
-       GL::ObjectInstance(*v.get_type().get_bogie_axle_object(b, a)),
-       vehicle(v.get_vehicle()),
-       bogie(&vehicle.get_bogie(b)),
-       axle(bogie->axles[a])
-{ }
-
-void Axle3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
+       axle(vehicle.get_vehicle().get_axle(a))
 {
-       if(!vehicle.get_track())
-               return;
-
-       ObjectInstance::render(renderer, tag);
+       if(axle.type->bogie)
+               bogie = &vehicle.get_vehicle().get_bogie(axle.type->bogie->index);
 }
 
-void Axle3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
+void Axle3D::update_matrix()
 {
-       GL::Matrix matrix;
-
-       const Vector &pos = vehicle.get_position();
-       matrix.translate(pos.x, pos.y, pos.z);
-       matrix.rotate(vehicle.get_direction(), 0, 0, 1);
+       matrix = vehicle.Object3D::get_matrix();
 
        if(bogie)
        {
@@ -44,10 +25,8 @@ void Axle3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
                matrix.rotate(bogie->direction, 0, 0, 1);
        }
 
-       matrix.translate(axle.type->position, 0, axle.type->wheel_dia/2);
+       matrix.translate(axle.type->local_position, 0, axle.type->wheel_dia/2);
        matrix.rotate(axle.angle, 0, 1, 0);
-
-       renderer.matrix_stack() *= matrix;
 }
 
 } // namespace R2C2