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 Axle3D::Axle3D(const Vehicle3D &v, unsigned a):
19 GL::ObjectInstance(*v.get_type().get_axle_object(a)),
20 vehicle(v.get_vehicle()),
22 axle(vehicle.get_axle(a))
25 Axle3D::Axle3D(const Vehicle3D &v, unsigned b, unsigned a):
26 GL::ObjectInstance(*v.get_type().get_bogie_axle_object(b, a)),
27 vehicle(v.get_vehicle()),
28 bogie(&vehicle.get_bogie(b)),
32 void Axle3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
34 if(!vehicle.get_track())
37 ObjectInstance::render(renderer, tag);
40 void Axle3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
44 const Vector &pos = vehicle.get_position();
45 matrix.translate(pos.x, pos.y, pos.z);
46 matrix.rotate(vehicle.get_direction(), 0, 0, 1);
50 matrix.translate(bogie->type->position, 0, 0);
51 matrix.rotate(bogie->direction, 0, 0, 1);
54 matrix.translate(axle.type->position, 0, axle.type->wheel_dia/2);
55 matrix.rotate(axle.angle, 0, 1, 0);
57 renderer.matrix_stack() *= matrix;