X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicletype.h;h=31b6992a134773c474cf1ab2868b054ccbcaca83;hb=18c529dfdd34e07f4f6021151ddce29fa85437bc;hp=a12d3f4f1ea1b4cc513cad45ecbcbfe64cb9e586;hpb=ce8be590703fdc0709863f0ee9695f40b6adb200;p=r2c2.git diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index a12d3f4..31b6992 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -1,23 +1,16 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_VEHICLETYPE_H_ #define LIBR2C2_VEHICLETYPE_H_ #include -#include "articlenumber.h" #include "geometry.h" +#include "objecttype.h" namespace R2C2 { -class VehicleType +class VehicleType: public ObjectType { public: - class Loader: public Msp::DataFile::ObjectLoader + class Loader: public Msp::DataFile::DerivedObjectLoader { private: std::map rod_tags; @@ -25,6 +18,7 @@ public: public: Loader(VehicleType &); private: + virtual void finish(); void axle(); void bogie(); void function(unsigned, const std::string &); @@ -34,6 +28,8 @@ public: void width(float); }; + struct Bogie; + struct Axle { class Loader: public Msp::DataFile::ObjectLoader @@ -45,6 +41,9 @@ public: void wheel_diameter(float); }; + unsigned index; + Bogie *bogie; + float local_position; float position; float wheel_dia; bool powered; @@ -53,29 +52,30 @@ public: Axle(); }; - typedef std::vector AxleArray; - struct Bogie { class Loader: public Msp::DataFile::ObjectLoader { + private: + VehicleType &parent; + public: - Loader(Bogie &); + Loader(VehicleType &, Bogie &); private: void axle(); void position(float); }; + unsigned index; float position; - AxleArray axles; + unsigned first_axle; + std::vector axles; std::string object; bool rotate_object; Bogie(); }; - typedef std::vector BogieArray; - struct Rod { enum Anchor @@ -116,45 +116,49 @@ public: Anchor pivot; unsigned pivot_index; unsigned pivot_index2; - Point pivot_point; + Vector pivot_point; Limit limit; int connect_index; - Point connect_point; - Point connect_offset; + Vector connect_point; + Vector connect_offset; std::string object; bool mirror_object; Rod(); }; + typedef std::vector AxleArray; + typedef std::vector BogieArray; typedef std::vector RodArray; + typedef std::map FunctionMap; private: - ArticleNumber art_nr; - std::string name; bool locomotive; - std::map functions; + FunctionMap functions; + bool swap_direction; float length; float width; float height; AxleArray axles; + std::vector fixed_axles; BogieArray bogies; RodArray rods; std::string object; + bool rotate_object; public: VehicleType(const ArticleNumber &); - const ArticleNumber &get_article_number() const { return art_nr; } - const std::string &get_name() const { return name; } bool is_locomotive() const { return locomotive; } unsigned get_max_function() const; - const std::map &get_functions() const { return functions; } + const FunctionMap &get_functions() const { return functions; } + bool get_swap_direction() const { return swap_direction; } float get_length() const { return length; } float get_width() const { return width; } float get_height() const { return height; } const AxleArray &get_axles() const { return axles; } const Axle &get_axle(unsigned) const; + const Axle &get_fixed_axle(unsigned) const; const BogieArray &get_bogies() const { return bogies; } const Bogie &get_bogie(unsigned) const; const Axle &get_bogie_axle(unsigned, unsigned) const; @@ -163,6 +167,7 @@ public: float get_front_axle_offset() const; float get_back_axle_offset() const; const std::string &get_object() const { return object; } + bool get_rotate_object() const { return rotate_object; } }; } // namespace R2C2