3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_VEHICLE_H_
9 #define LIBR2C2_VEHICLE_H_
39 TrackPosition(Track *, unsigned, float);
41 TrackPoint get_point() const;
53 const VehicleType &type;
56 TrackPosition track_pos;
59 std::vector<float> bogie_dirs;
60 std::vector<std::vector<float> > axle_angles;
61 std::vector<Rod> rods;
62 unsigned front_sensor;
66 Vehicle(Layout &, const VehicleType &);
69 const VehicleType &get_type() const { return type; }
71 void attach_back(Vehicle &);
72 void attach_front(Vehicle &);
75 Vehicle *get_next() const { return next; }
76 Vehicle *get_previous() const { return prev; }
78 void place(Track &, unsigned, float, PlaceMode = CENTER);
81 Track *get_track() const { return track_pos.track; }
82 unsigned get_entry() const { return track_pos.ep; }
83 float get_offset() const { return track_pos.offs; }
84 const Point &get_position() const { return position; }
85 float get_direction() const { return direction; }
86 float get_axle_angle(unsigned) const;
87 float get_bogie_direction(unsigned) const;
88 float get_bogie_axle_angle(unsigned, unsigned) const;
89 const Point &get_rod_position(unsigned) const;
90 float get_rod_angle(unsigned) const;
92 void update_position();
93 void update_position_from(const Vehicle &);
94 void propagate_position();
95 void propagate_forward();
96 void propagate_backward();
97 void check_sensor(float, unsigned &);
98 void turn_axles(float);
101 void adjust_for_distance(TrackPosition &, TrackPosition &, float, float = 0.5) const;
102 TrackPoint get_point(const Point &, const Point &, float = 0.5) const;
103 TrackPoint get_point(const TrackPosition &, float, float = 0.5) const;