3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
9 #include <msp/gl/matrix.h>
12 #include "vehicletype.h"
18 Vehicle3D::Vehicle3D(Layout3D &l, Vehicle &v):
21 type(layout.get_catalogue().get_vehicle(vehicle.get_type()))
23 layout.add_vehicle(*this);
24 layout.get_scene().add(*this);
27 Vehicle3D::~Vehicle3D()
29 layout.remove_vehicle(*this);
30 layout.get_scene().remove(*this);
33 Point Vehicle3D::get_node() const
35 Point p = vehicle.get_position();
36 return Point(p.x, p.y, p.z+0.01+vehicle.get_type().get_height());
39 void Vehicle3D::render(const GL::Tag &tag) const
43 GL::PushMatrix push_mat;
45 const Point &pos = vehicle.get_position();
46 GL::translate(pos.x, pos.y, pos.z+0.01);
47 GL::rotate(vehicle.get_direction()*180/M_PI, 0, 0, 1);
49 type.get_body_mesh().draw();
53 } // namespace Marklin