]> git.mxchange.org Git - flightgear.git/blob - src/Model/modelmgr.hxx
I have added Aaron Wilson's virtual 3d runway projection to the HUD.
[flightgear.git] / src / Model / modelmgr.hxx
1 // model-mgr.hxx - manage user-specified 3D models.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __MODELMGR_HXX
7 #define __MODELMGR_HXX 1
8
9 #ifndef __cplusplus
10 # error This library requires C++
11 #endif
12
13 #include <vector>
14
15 #include <simgear/compiler.h>   // for SG_USING_STD
16 #include <simgear/structure/subsystem_mgr.hxx>
17
18 SG_USING_STD(vector);
19
20 // Don't pull in headers, since we don't need them here.
21 class ssgSelector;
22 class SGPropertyNode;
23 class SGModelPlacement;
24
25
26 /**
27  * Manage a list of user-specified models.
28  */
29 class FGModelMgr : public SGSubsystem
30 {
31 public:
32
33   /**
34    * A dynamically-placed model using properties.
35    *
36    * The model manager uses the property nodes to update the model's
37    * position and orientation; any of the property node pointers may
38    * be set to zero to avoid update.  Normally, a caller should
39    * load the model by instantiating SGModelPlacement with the path
40    * to the model or its XML wrapper, then assign any relevant
41    * property node pointers.
42    *
43    * @see SGModelPlacement
44    * @see FGModelMgr#add_instance
45    */
46   struct Instance
47   {
48     Instance ();
49     virtual ~Instance ();
50     SGModelPlacement * model;
51     SGPropertyNode * lon_deg_node;
52     SGPropertyNode * lat_deg_node;
53     SGPropertyNode * elev_ft_node;
54     SGPropertyNode * roll_deg_node;
55     SGPropertyNode * pitch_deg_node;
56     SGPropertyNode * heading_deg_node;
57   };
58
59   FGModelMgr ();
60   virtual ~FGModelMgr ();
61
62   virtual void init ();
63   virtual void bind ();
64   virtual void unbind ();
65   virtual void update (double dt);
66
67   /**
68    * Add an instance of a dynamic model to the manager.
69    *
70    * NOTE: pointer ownership is transferred to the model manager!
71    *
72    * The caller is responsible for setting up the Instance structure
73    * as required.  The model manager will continuously update the
74    * location and orientation of the model based on the current
75    * values of the properties.
76    */
77   virtual void add_instance (Instance * instance);
78
79
80   /**
81    * Remove an instance of a dynamic model from the manager.
82    *
83    * NOTE: the manager will delete the instance as well.
84    */
85   virtual void remove_instance (Instance * instance);
86
87   virtual void draw ();
88
89 private:
90
91   vector<Instance *> _instances;
92
93   ssgSelector * _selector;
94
95 };
96
97 #endif // __MODELMGR_HXX