]> git.mxchange.org Git - flightgear.git/blob - src/Main/model.hxx
Added rotation animations, and a factor parameter for scaling.
[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 position;
51     float center_x;
52     float center_y;
53     float center_z;
54     float axis_x;
55     float axis_y;
56     float axis_z;
57   };
58
59   Animation read_animation (const SGPropertyNode * node);
60   void do_animation (Animation &animation, long elapsed_ms);
61
62   SGPropertyNode * _props;
63   ssgEntity * _model;
64   ssgSelector * _selector;
65   ssgTransform * _position;
66
67   SGTimeStamp _last_timestamp;
68   SGTimeStamp _current_timestamp;
69
70   vector<Animation> _animations;
71
72 };
73
74 extern FGAircraftModel current_model;
75
76 #endif // __MODEL_HXX
77