]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicletype.h
Rename Point to Vector
[r2c2.git] / source / libr2c2 / vehicletype.h
index b97fb921519212f8b74e7d1681514ed3dacd4971..97942af02c2381eec34e4fc5fb1fd5a11dd47379 100644 (file)
@@ -10,6 +10,7 @@ Distributed under the GPL
 
 #include <msp/datafile/objectloader.h>
 #include "articlenumber.h"
+#include "geometry.h"
 
 namespace R2C2 {
 
@@ -18,6 +19,9 @@ class VehicleType
 public:
        class Loader: public Msp::DataFile::ObjectLoader<VehicleType>
        {
+       private:
+               std::map<std::string, unsigned> rod_tags;
+
        public:
                Loader(VehicleType &);
        private:
@@ -26,6 +30,7 @@ public:
                void function(unsigned, const std::string &);
                void height(float);
                void length(float);
+               void rod();
                void width(float);
        };
 
@@ -48,6 +53,8 @@ public:
                Axle();
        };
 
+       typedef std::vector<Axle> AxleArray;
+
        struct Bogie
        {
                class Loader: public Msp::DataFile::ObjectLoader<Bogie>
@@ -60,13 +67,68 @@ public:
                };
 
                float position;
-               std::vector<Axle> axles;
+               AxleArray axles;
                std::string object;
                bool rotate_object;
 
                Bogie();
        };
 
+       typedef std::vector<Bogie> BogieArray;
+
+       struct Rod
+       {
+               enum Anchor
+               {
+                       BODY,
+                       AXLE,
+                       BOGIE_AXLE,
+                       ROD
+               };
+
+               enum Limit
+               {
+                       FIXED,
+                       ROTATE,
+                       SLIDE_X
+               };
+
+               class Loader: public Msp::DataFile::ObjectLoader<Rod>
+               {
+               private:
+                       const std::map<std::string, unsigned> &tags;
+                       std::string tag;
+
+               public:
+                       Loader(Rod &, const std::map<std::string, unsigned> &);
+                       const std::string &get_tag() const { return tag; }
+               private:
+                       void connect(const std::string &, float, float, float, float);
+                       void limit(Limit);
+                       void pivot_body();
+                       void pivot_axle(unsigned);
+                       void pivot_bogie_axle(unsigned, unsigned);
+                       void pivot_rod(const std::string &);
+                       void position(float, float, float);
+                       void set_tag(const std::string &);
+               };
+
+               Anchor pivot;
+               unsigned pivot_index;
+               unsigned pivot_index2;
+               Vector pivot_point;
+               Limit limit;
+               int connect_index;
+               Vector connect_point;
+               Vector connect_offset;
+               std::string object;
+               bool mirror_object;
+
+               Rod();
+       };
+
+       typedef std::vector<Rod> RodArray;
+
 private:
        ArticleNumber art_nr;
        std::string name;
@@ -75,8 +137,9 @@ private:
        float length;
        float width;
        float height;
-       std::vector<Axle> axles;
-       std::vector<Bogie> bogies;
+       AxleArray axles;
+       BogieArray bogies;
+       RodArray rods;
        std::string object;
 
 public:
@@ -90,8 +153,13 @@ public:
        float get_length() const { return length; }
        float get_width() const { return width; }
        float get_height() const { return height; }
-       const std::vector<Axle> &get_axles() const { return axles; }
-       const std::vector<Bogie> &get_bogies() const { return bogies; }
+       const AxleArray &get_axles() const { return axles; }
+       const Axle &get_axle(unsigned) const;
+       const BogieArray &get_bogies() const { return bogies; }
+       const Bogie &get_bogie(unsigned) const;
+       const Axle &get_bogie_axle(unsigned, unsigned) const;
+       const RodArray &get_rods() const { return rods; }
+       const Rod &get_rod(unsigned) const;
        float get_front_axle_offset() const;
        float get_back_axle_offset() const;
        const std::string &get_object() const { return object; }