]> git.mxchange.org Git - flightgear.git/blob - src/Main/model.hxx
A single transformation can now be applied to more than one object by
[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 string &object_name,
58                             const SGPropertyNode * node);
59   void do_animation (Animation &animation, long elapsed_ms);
60
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