]> git.mxchange.org Git - flightgear.git/blob - src/Main/model.hxx
Started support for animations. Currently, the only supported type
[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     };
43     string name;
44     Type type;
45     ssgTransform * transform;
46     sgMat4 matrix;
47     SGPropertyNode * prop;
48     float position;
49     float center_x;
50     float center_y;
51     float center_z;
52     float axis_x;
53     float axis_y;
54     float axis_z;
55   };
56
57   Animation read_animation (const SGPropertyNode * node);
58   void do_animation (Animation &animation, long elapsed_ms);
59
60   SGPropertyNode * _props;
61   ssgEntity * _model;
62   ssgSelector * _selector;
63   ssgTransform * _position;
64
65   SGTimeStamp _last_timestamp;
66   SGTimeStamp _current_timestamp;
67
68   vector<Animation> _animations;
69
70 };
71
72 extern FGAircraftModel current_model;
73
74 #endif // __MODEL_HXX
75