]> git.mxchange.org Git - flightgear.git/blob - src/Main/model.hxx
- added an 'offset' parameter for animations (it's applied before
[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     sgVec3 center;
53     sgVec3 axis;
54     void setRotation ();
55   };
56
57   Animation read_animation (const SGPropertyNode * node);
58   void do_animation (Animation &animation, long elapsed_ms);
59
60   ssgEntity * _model;
61   ssgSelector * _selector;
62   ssgTransform * _position;
63
64   SGTimeStamp _last_timestamp;
65   SGTimeStamp _current_timestamp;
66
67   vector<Animation> _animations;
68
69 };
70
71 extern FGAircraftModel current_model;
72
73 #endif // __MODEL_HXX
74