-/* $Id$
-
-This file is part of R²C²
-Copyright © 2011 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
-#include <msp/gl/matrix.h>
-#include <msp/gl/renderer.h>
#include "bogie.h"
#include "vehicle.h"
#include "vehicletype.h"
namespace R2C2 {
Bogie3D::Bogie3D(const Vehicle3D &v, unsigned b):
- GL::ObjectInstance(*v.get_type().get_bogie_object(b)),
- vehicle(v.get_vehicle()),
- bogie(vehicle.get_bogie(b))
+ VehiclePart3D(v, *v.get_type().get_bogie_object(b)),
+ bogie(vehicle.get_vehicle().get_bogie(b))
{ }
-void Bogie3D::render(Msp::GL::Renderer &renderer, const GL::Tag &tag) const
-{
- if(!vehicle.get_track())
- return;
-
- ObjectInstance::render(renderer, tag);
-}
-
-void Bogie3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const
+void Bogie3D::update_matrix()
{
- GL::Matrix matrix;
-
- const Vector &pos = vehicle.get_position();
- matrix.translate(pos.x, pos.y, pos.z);
- matrix.rotate(vehicle.get_direction(), 0, 0, 1);
+ matrix = vehicle.Object3D::get_matrix();
matrix.translate(bogie.type->position, 0, 0);
- float dir = bogie.direction;
+ Angle dir = bogie.direction;
if(bogie.type->rotate_object)
- dir += M_PI;
+ dir += Angle::half_turn();
matrix.rotate(dir, 0, 0, 1);
-
- renderer.matrix_stack() *= matrix;
}
} // namespace R2C2