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):
24 track.get_layout().get_path_scene().add(*this);
29 track.get_layout().get_path_scene().remove(*this);
32 void Path3D::set_automatic()
37 void Path3D::set_path(unsigned p)
39 if(!(track.get_track().get_type().get_paths()&(1<<p)))
40 throw InvalidParameterValue("Invalid path");
45 void Path3D::set_mask(unsigned p)
47 if(p&~track.get_track().get_type().get_paths())
48 throw InvalidParameterValue("Invalid path mask");
53 void Path3D::set_color(const GL::Color &c)
58 void Path3D::render(const GL::Tag &tag) const
62 unsigned mask = (automatic ? 1<<track.get_track().get_active_path() : paths);
63 mask &= track.get_track().get_type().get_paths();
67 GL::PushMatrix push_mat;
70 glColor4f(color.r, color.g, color.b, color.a);
71 for(unsigned i=0; mask; ++i, mask>>=1)
73 track.get_type().get_path_mesh(i).draw();
77 } // namespace Marklin