3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/gl/matrix.h>
9 #include "libmarklin/tracktype.h"
13 #include "tracktype.h"
19 Path3D::Path3D(const Track3D &t):
25 track.get_layout().get_path_scene().add(*this);
30 track.get_layout().get_path_scene().remove(*this);
33 void Path3D::set_automatic()
38 void Path3D::set_path(unsigned p)
40 if(!(track.get_track().get_type().get_paths()&(1<<p)))
41 throw InvalidParameterValue("Invalid path");
46 void Path3D::set_mask(unsigned p)
48 if(p&~track.get_track().get_type().get_paths())
49 throw InvalidParameterValue("Invalid path mask");
54 void Path3D::set_color(const GL::Color &c)
59 void Path3D::set_layer(float l)
61 z_offs = l*track.get_track().get_layout().get_catalogue().get_gauge()*0.01;
64 void Path3D::render(const GL::Tag &tag) const
68 unsigned mask = (automatic ? 1<<track.get_track().get_active_path() : paths);
69 mask &= track.get_track().get_type().get_paths();
73 GL::PushMatrix push_mat;
75 GL::translate(0, 0, z_offs);
77 glColor4f(color.r, color.g, color.b, color.a);
78 for(unsigned i=0; mask; ++i, mask>>=1)
80 track.get_type().get_path_mesh(i).draw();
84 } // namespace Marklin