]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/bogie.cpp
Remove a queued block reservation if the block is released
[r2c2.git] / source / 3d / bogie.cpp
index 234bd88a403559b795db56f86ae655064ef31296..24fa85d3e799b1c888894ffe882a49137c378510 100644 (file)
@@ -1,12 +1,3 @@
-/* $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"
@@ -16,34 +7,19 @@ using namespace Msp;
 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 Point &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