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 Rod3D::Rod3D(const Vehicle3D &v, unsigned r):
19 GL::ObjectInstance(*v.get_type().get_rod_object(r)),
20 vehicle(v.get_vehicle()),
21 rod(vehicle.get_rod(r))
24 void Rod3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
26 if(!vehicle.get_track())
29 ObjectInstance::render(renderer, tag);
32 void Rod3D::setup_render(GL::Renderer &renderer, const GL::Tag &) const
35 const Vector &pos = vehicle.get_position();
36 matrix.translate(pos.x, pos.y, pos.z);
37 matrix.rotate(vehicle.get_direction(), 0, 0, 1);
39 matrix.translate(rod.position.x, rod.position.y, rod.position.z);
40 if(rod.type->mirror_object)
41 matrix.scale(1, -1, 1);
42 matrix.rotate(rod.angle, 0, -1, 0);
44 renderer.matrix_stack() *= matrix;