]> git.mxchange.org Git - flightgear.git/blob - src/Main/model.hxx
Added min/max parameters to clamp range of movement. These are
[flightgear.git] / src / Main / model.hxx
1 // model.hxx - manage a 3D aircraft model.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __MODEL_HXX
7 #define __MODEL_HXX 1
8
9 #ifndef __cplusplus
10 # error This library requires C++
11 #endif
12
13 #include <string>
14 #include <vector>
15
16 SG_USING_STD(string);
17 SG_USING_STD(vector);
18
19 #include "fgfs.hxx"
20 #include <simgear/misc/props.hxx>
21 #include <simgear/timing/timestamp.hxx>
22
23 class FGAircraftModel : public FGSubsystem
24 {
25 public:
26
27   FGAircraftModel ();
28   virtual ~FGAircraftModel ();
29
30   virtual void init ();
31   virtual void bind ();
32   virtual void unbind ();
33   virtual void update (int dt);
34
35 private:
36
37   struct Animation
38   {
39     enum Type {
40       None,
41       Spin,
42       Rotate
43     };
44     string name;
45     Type type;
46     ssgTransform * transform;
47     sgMat4 matrix;
48     SGPropertyNode * prop;
49     float factor;
50     float offset;
51     float position;
52     bool has_min;
53     float min;
54     bool has_max;
55     float max;
56     sgVec3 center;
57     sgVec3 axis;
58     void setRotation ();
59   };
60
61   Animation read_animation (const string &object_name,
62                             const SGPropertyNode * node);
63   void do_animation (Animation &animation, long elapsed_ms);
64
65   ssgEntity * _model;
66   ssgSelector * _selector;
67   ssgTransform * _position;
68
69   SGTimeStamp _last_timestamp;
70   SGTimeStamp _current_timestamp;
71
72   vector<Animation> _animations;
73
74 };
75
76 extern FGAircraftModel current_model;
77
78 #endif // __MODEL_HXX
79