]> git.tdb.fi Git - r2c2.git/blobdiff - source/3d/tracktype.cpp
Move track appearance properties into a separate class
[r2c2.git] / source / 3d / tracktype.cpp
index f6b3d5fb8b053635cbb1732c9885860f59cc61e6..d664c3948ef7a1c9bf54998a4abe661c45b2568e 100644 (file)
@@ -9,21 +9,22 @@ using namespace Msp;
 
 namespace R2C2 {
 
-TrackType3D::TrackType3D(Catalogue3D &cat3d, const TrackType &tt):
-       catalogue(cat3d),
+TrackType3D::TrackType3D(Catalogue3D &c, const TrackType &tt):
+       ObjectType3D(c),
        mesh(0),
        object(0),
        own_data(false)
 {
-       const Catalogue &cat = cat3d.get_catalogue();
+       const TrackAppearance &appearance = tt.get_appearance();
+       const Catalogue &cat = catalogue.get_catalogue();
        const vector<TrackPart> &parts = tt.get_parts();
 
-       const Profile &ballast_profile = cat.get_ballast_profile();
+       const Profile &ballast_profile = appearance.get_ballast_profile();
        const Vector &ballast_min = ballast_profile.get_min_coords();
        const Vector &ballast_max = ballast_profile.get_max_coords();
        float ballast_h = ballast_max.y-ballast_min.y;
 
-       const Profile &rail_profile = cat.get_rail_profile();
+       const Profile &rail_profile = appearance.get_rail_profile();
        const Vector &rail_min = rail_profile.get_min_coords();
        const Vector &rail_max = rail_profile.get_max_coords();
        float rail_h = rail_max.y-rail_min.y;
@@ -53,7 +54,7 @@ TrackType3D::TrackType3D(Catalogue3D &cat3d, const TrackType &tt):
 
                object = new GL::Object;
                object->set_mesh(mesh);
-               object->set_technique(&catalogue.get<GL::Technique>(cat.get_track_technique()));
+               object->set_technique(&catalogue.get<GL::Technique>(appearance.get_technique()));
 
                own_data = true;
        }
@@ -117,8 +118,8 @@ void TrackType3D::build_part(const TrackPart &part, const Profile &profile, cons
        unsigned n_vertices = profile.get_n_vertices();
        for(unsigned i=0; i<=nsegs; ++i)
        {
-               TrackPoint basep = part.get_point(i*plen/nsegs);
-               Transform trans = Transform::rotation(basep.dir, Vector(0, 0, 1));
+               OrientedPoint basep = part.get_point(i*plen/nsegs);
+               Transform trans = Transform::rotation(basep.rotation, Vector(0, 0, 1));
 
                for(unsigned j=0; j<n_vertices; ++j)
                {
@@ -126,7 +127,7 @@ void TrackType3D::build_part(const TrackPart &part, const Profile &profile, cons
                        Vector p(0, -v.pos.x, v.pos.y);
                        if(mirror)
                                p.y = -p.y;
-                       p = basep.pos+trans.transform(offset+p);
+                       p = basep.position+trans.transform(offset+p);
 
                        Vector n(0, -v.normal.x, v.normal.y);
                        if(mirror)