1 #include <msp/gl/matrix.h>
2 #include <msp/gl/renderer.h>
3 #include "libr2c2/tracktype.h"
14 Path3D::Path3D(const Track3D &t):
15 Utility3D(t.get_layout()),
17 path(t.get_track().get_active_path()),
25 layout.get_path_scene().add(*this);
26 if(track.get_track().get_type().is_turnout())
27 track.get_track().signal_path_changed.connect(sigc::mem_fun(this, &Path3D::path_changed));
32 layout.get_path_scene().remove(*this);
35 void Path3D::set_automatic()
40 void Path3D::set_path(int p)
42 if(p>=0 && !(track.get_track().get_type().get_paths()&(1<<p)))
43 throw invalid_argument("Path3D::set_path");
49 void Path3D::set_side(int s)
51 side = (s<0 ? -1 : s>0 ? 1 : 0);
55 void Path3D::set_color(const GL::Color &c)
60 void Path3D::set_layer(float l)
62 z_offs = l*layout.get_layout().get_catalogue().get_gauge()*0.01;
65 void Path3D::path_changed(unsigned p)
74 void Path3D::update_mesh()
76 mesh = &track.get_type().get_path_mesh(path, side);
79 long Path3D::get_instance_key() const
81 return reinterpret_cast<long>(&track.get_type());
84 void Path3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
88 GL::MatrixStack::Push push_mtx(renderer.matrix_stack());
89 renderer.matrix_stack() *= track.Object3D::get_matrix();
90 renderer.matrix_stack() *= GL::Matrix::translation(0, 0, z_offs);
92 glColor4f(color.r, color.g, color.b, color.a);