X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Fpath.cpp;h=f9e51f4974a790efa0fb51e141ee7256efebbd85;hb=57628dfb3e1874ab73c0c3df02043a4f57feb4b1;hp=44c54ab35dc8defbce1df8a4535100dacbd5b29d;hpb=621c5c938d70ba0d155e0eda91a708db0a52c0dc;p=r2c2.git diff --git a/source/3d/path.cpp b/source/3d/path.cpp index 44c54ab..f9e51f4 100644 --- a/source/3d/path.cpp +++ b/source/3d/path.cpp @@ -12,17 +12,24 @@ using namespace Msp; namespace R2C2 { Path3D::Path3D(const Track3D &t): + Utility3D(t.get_layout()), track(t), - paths(0), + path(t.get_track().get_active_path()), + side(0), automatic(true), + mesh(0), z_offs(0) { - track.get_layout().get_path_scene().add(*this); + update_mesh(); + + layout.get_path_scene().add(*this); + if(track.get_track().get_type().is_turnout()) + track.get_track().signal_path_changed.connect(sigc::mem_fun(this, &Path3D::path_changed)); } Path3D::~Path3D() { - track.get_layout().get_path_scene().remove(*this); + layout.get_path_scene().remove(*this); } void Path3D::set_automatic() @@ -30,20 +37,19 @@ void Path3D::set_automatic() automatic = true; } -void Path3D::set_path(unsigned p) +void Path3D::set_path(int p) { - if(!(track.get_track().get_type().get_paths()&(1<
=0 && !(track.get_track().get_type().get_paths()&(1<
0 ? 1 : 0);
+ update_mesh();
}
void Path3D::set_color(const GL::Color &c)
@@ -53,7 +59,21 @@ void Path3D::set_color(const GL::Color &c)
void Path3D::set_layer(float l)
{
- z_offs = l*track.get_track().get_layout().get_catalogue().get_gauge()*0.01;
+ z_offs = l*layout.get_layout().get_catalogue().get_gauge()*0.01;
+}
+
+void Path3D::path_changed(unsigned p)
+{
+ if(automatic)
+ {
+ path = p;
+ update_mesh();
+ }
+}
+
+void Path3D::update_mesh()
+{
+ mesh = &track.get_type().get_path_mesh(path, side);
}
long Path3D::get_instance_key() const
@@ -65,20 +85,12 @@ void Path3D::render(GL::Renderer &renderer, const GL::Tag &tag) const
{
if(tag=="unlit")
{
- unsigned mask = (automatic ? 1<