]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/path.cpp
Rename the project to R²C²
[r2c2.git] / source / 3d / path.cpp
index 1128b67bb9d61e9b4d0995da236650257e7b90f2..e4e0b92989172a64780753af467a80e8f90d9cf3 100644 (file)
@@ -1,12 +1,12 @@
 /* $Id$
 
-This file is part of the MSP Märklin suite
+This file is part of R²C²
 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
 Distributed under the GPL
 */
 
 #include <msp/gl/matrix.h>
-#include "libmarklin/tracktype.h"
+#include "libr2c2/tracktype.h"
 #include "layout.h"
 #include "path.h"
 #include "track.h"
@@ -14,12 +14,13 @@ Distributed under the GPL
 
 using namespace Msp;
 
-namespace Marklin {
+namespace R2C2 {
 
 Path3D::Path3D(const Track3D &t):
        track(t),
        paths(0),
-       automatic(true)
+       automatic(true),
+       z_offs(0)
 {
        track.get_layout().get_path_scene().add(*this);
 }
@@ -55,9 +56,14 @@ void Path3D::set_color(const GL::Color &c)
        color = c;
 }
 
+void Path3D::set_layer(float l)
+{
+       z_offs = l*track.get_track().get_layout().get_catalogue().get_gauge()*0.01;
+}
+
 void Path3D::render(const GL::Tag &tag) const
 {
-       if(tag==0)
+       if(tag=="unlit")
        {
                unsigned mask = (automatic ? 1<<track.get_track().get_active_path() : paths);
                mask &= track.get_track().get_type().get_paths();
@@ -66,6 +72,7 @@ void Path3D::render(const GL::Tag &tag) const
 
                GL::PushMatrix push_mat;
                track.apply_matrix();
+               GL::translate(0, 0, z_offs);
 
                glColor4f(color.r, color.g, color.b, color.a);
                for(unsigned i=0; mask; ++i, mask>>=1)
@@ -74,4 +81,4 @@ void Path3D::render(const GL::Tag &tag) const
        }
 }
 
-} // namespace Marklin
+} // namespace R2C2