3 This file is part of R²C²
4 Copyright © 2011 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/gl/matrix.h>
9 #include <msp/gl/renderer.h>
12 #include "vehicletype.h"
18 Bogie3D::Bogie3D(const Vehicle3D &v, unsigned b):
19 GL::ObjectInstance(*v.get_type().get_bogie_object(b)),
20 vehicle(v.get_vehicle()),
21 bogie(vehicle.get_bogie(b))
24 void Bogie3D::render(Msp::GL::Renderer &renderer, const GL::Tag &tag) const
26 if(!vehicle.get_track())
29 ObjectInstance::render(renderer, tag);
32 void Bogie3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const
36 const Vector &pos = vehicle.get_position();
37 matrix.translate(pos.x, pos.y, pos.z);
38 matrix.rotate(vehicle.get_direction(), 0, 0, 1);
40 matrix.translate(bogie.type->position, 0, 0);
41 float dir = bogie.direction;
42 if(bogie.type->rotate_object)
44 matrix.rotate(dir, 0, 0, 1);
46 renderer.matrix_stack() *= matrix;