1 #include <msp/gl/matrix.h>
2 #include <msp/gl/renderer.h>
3 #include "libr2c2/tracktype.h"
13 Path3D::Path3D(const Track3D &t):
19 track.get_layout().get_path_scene().add(*this);
24 track.get_layout().get_path_scene().remove(*this);
27 void Path3D::set_automatic()
32 void Path3D::set_path(unsigned p)
34 if(!(track.get_track().get_type().get_paths()&(1<<p)))
35 throw InvalidParameterValue("Invalid path");
40 void Path3D::set_mask(unsigned p)
42 if(p&~track.get_track().get_type().get_paths())
43 throw InvalidParameterValue("Invalid path mask");
48 void Path3D::set_color(const GL::Color &c)
53 void Path3D::set_layer(float l)
55 z_offs = l*track.get_track().get_layout().get_catalogue().get_gauge()*0.01;
58 long Path3D::get_instance_key() const
60 return reinterpret_cast<long>(&track.get_type());
63 void Path3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
67 unsigned mask = (automatic ? 1<<track.get_track().get_active_path() : paths);
68 mask &= track.get_track().get_type().get_paths();
72 GL::MatrixStack::Push push_mtx(renderer.matrix_stack());
73 GL::Matrix matrix = track.get_matrix();
74 matrix.translate(0, 0, z_offs);
75 renderer.matrix_stack() *= matrix;
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(renderer);