1 #include <msp/gl/matrix.h>
2 #include <msp/gl/renderer.h>
3 #include "libr2c2/tracktype.h"
14 Path3D::Path3D(const Track3D &t):
20 track.get_layout().get_path_scene().add(*this);
25 track.get_layout().get_path_scene().remove(*this);
28 void Path3D::set_automatic()
33 void Path3D::set_path(unsigned p)
35 if(!(track.get_track().get_type().get_paths()&(1<<p)))
36 throw invalid_argument("Path3D::set_path");
41 void Path3D::set_mask(unsigned p)
43 if(p&~track.get_track().get_type().get_paths())
44 throw invalid_argument("Path3D::set_mask");
49 void Path3D::set_color(const GL::Color &c)
54 void Path3D::set_layer(float l)
56 z_offs = l*track.get_track().get_layout().get_catalogue().get_gauge()*0.01;
59 long Path3D::get_instance_key() const
61 return reinterpret_cast<long>(&track.get_type());
64 void Path3D::render(GL::Renderer &renderer, 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::MatrixStack::Push push_mtx(renderer.matrix_stack());
74 GL::Matrix matrix = track.create_matrix();
75 matrix.translate(0, 0, z_offs);
76 renderer.matrix_stack() *= matrix;
78 glColor4f(color.r, color.g, color.b, color.a);
79 for(unsigned i=0; mask; ++i, mask>>=1)
81 track.get_type().get_path_mesh(i).draw(renderer);