1 #include <msp/gl/matrix.h>
2 #include <msp/gl/renderer.h>
5 #include "vehicletype.h"
11 Bogie3D::Bogie3D(const Vehicle3D &v, unsigned b):
12 GL::ObjectInstance(*v.get_type().get_bogie_object(b)),
13 vehicle(v.get_vehicle()),
14 bogie(vehicle.get_bogie(b))
17 void Bogie3D::render(Msp::GL::Renderer &renderer, const GL::Tag &tag) const
19 if(!vehicle.get_track())
22 ObjectInstance::render(renderer, tag);
25 void Bogie3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const
29 const Vector &pos = vehicle.get_position();
30 matrix.translate(pos.x, pos.y, pos.z);
31 matrix.rotate(vehicle.get_rotation(), 0, 0, 1);
33 matrix.translate(bogie.type->position, 0, 0);
34 float dir = bogie.direction;
35 if(bogie.type->rotate_object)
37 matrix.rotate(dir, 0, 0, 1);
39 renderer.matrix_stack() *= matrix;