]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/trackpart.h
Make use of the mspmath library
[r2c2.git] / source / libr2c2 / trackpart.h
1 #ifndef LIBR2C2_TRACKPART_H_
2 #define LIBR2C2_TRACKPART_H_
3
4 #include <msp/datafile/objectloader.h>
5 #include "geometry.h"
6
7 namespace R2C2 {
8
9 class TrackPart
10 {
11 public:
12         class Loader: public Msp::DataFile::ObjectLoader<TrackPart>
13         {
14         public:
15                 Loader(TrackPart &);
16         private:
17                 virtual void finish();
18                 void start(float, float, float);
19         };
20
21 private:
22         Vector pos;
23         Angle dir;
24         float length;
25         float radius;
26         unsigned path;
27         bool dead_end;
28         TrackPart *links[2];
29
30 public:
31         TrackPart();
32
33         float get_length() const;
34         bool is_curved() const { return radius; }
35         TrackPoint get_point(float) const;
36         TrackPoint get_nearest_point(const Vector &) const;
37         unsigned get_path() const { return path; }
38         bool is_dead_end() const { return dead_end; }
39         void check_link(TrackPart &);
40         TrackPart *get_link(unsigned) const;
41         bool collide_ray(const Vector &, const Vector &, float) const;
42 };
43
44 } // namespace R2C2
45
46 #endif