X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2F3d%2Fbogie.cpp;fp=source%2F3d%2Fbogie.cpp;h=de7d1bbac2b270d35bbd52a69a38703c365d8fae;hb=4b7008978ce5b67e7e1db14b4a359e4ab1881bbd;hp=0000000000000000000000000000000000000000;hpb=fa7cc825ea7aee9328ecd03b67617847fd128f85;p=r2c2.git diff --git a/source/3d/bogie.cpp b/source/3d/bogie.cpp new file mode 100644 index 0000000..de7d1bb --- /dev/null +++ b/source/3d/bogie.cpp @@ -0,0 +1,46 @@ +/* $Id$ + +This file is part of R²C² +Copyright © 2011 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#include +#include +#include "bogie.h" +#include "vehicle.h" +#include "vehicletype.h" + +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)) +{ } + +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 +{ + 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.translate(bogie.type->position, 0, 0); + matrix.rotate(bogie.direction, 0, 0, 1); + + renderer.matrix_stack() *= matrix; +} + +} // namespace R2C2