1 #include <msp/gl/matrix.h>
2 #include <msp/gl/renderer.h>
5 #include "vehicletype.h"
11 Axle3D::Axle3D(const Vehicle3D &v, unsigned a):
12 GL::ObjectInstance(*v.get_type().get_fixed_axle_object(a)),
13 vehicle(v.get_vehicle()),
15 axle(vehicle.get_fixed_axle(a))
18 Axle3D::Axle3D(const Vehicle3D &v, unsigned b, unsigned a):
19 GL::ObjectInstance(*v.get_type().get_bogie_axle_object(b, a)),
20 vehicle(v.get_vehicle()),
21 bogie(&vehicle.get_bogie(b)),
25 void Axle3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
27 if(!vehicle.get_track())
30 ObjectInstance::render(renderer, tag);
33 void Axle3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
37 const Vector &pos = vehicle.get_position();
38 matrix.translate(pos.x, pos.y, pos.z);
39 matrix.rotate(vehicle.get_rotation(), 0, 0, 1);
43 matrix.translate(bogie->type->position, 0, 0);
44 matrix.rotate(bogie->direction, 0, 0, 1);
47 matrix.translate(axle.type->position, 0, axle.type->wheel_dia/2);
48 matrix.rotate(axle.angle, 0, 1, 0);
50 renderer.matrix_stack() *= matrix;