]> git.mxchange.org Git - flightgear.git/blob - src/Model/modelmgr.hxx
Moved random ground cover object management code (userdata.[ch]xx) over
[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
17 #include <Main/fgfs.hxx>        // for FGSubsystem
18
19 SG_USING_STD(vector);
20
21 // Don't pull in headers, since we don't need them here.
22 class ssgSelector;
23 class SGPropertyNode;
24 class SGModelPlacement;
25
26
27 /**
28  * Manage a list of user-specified models.
29  */
30 class FGModelMgr : public FGSubsystem
31 {
32 public:
33
34   /**
35    * A dynamically-placed model using properties.
36    *
37    * The model manager uses the property nodes to update the model's
38    * position and orientation; any of the property node pointers may
39    * be set to zero to avoid update.  Normally, a caller should
40    * load the model by instantiating SGModelPlacement with the path
41    * to the model or its XML wrapper, then assign any relevant
42    * property node pointers.
43    *
44    * @see SGModelPlacement
45    * @see FGModelMgr#add_instance
46    */
47   struct Instance
48   {
49     Instance ();
50     virtual ~Instance ();
51     SGModelPlacement * model;
52     SGPropertyNode * lon_deg_node;
53     SGPropertyNode * lat_deg_node;
54     SGPropertyNode * elev_ft_node;
55     SGPropertyNode * roll_deg_node;
56     SGPropertyNode * pitch_deg_node;
57     SGPropertyNode * heading_deg_node;
58   };
59
60   FGModelMgr ();
61   virtual ~FGModelMgr ();
62
63   virtual void init ();
64   virtual void bind ();
65   virtual void unbind ();
66   virtual void update (double dt);
67
68   /**
69    * Add an instance of a dynamic model to the manager.
70    *
71    * NOTE: pointer ownership is transferred to the model manager!
72    *
73    * The caller is responsible for setting up the Instance structure
74    * as required.  The model manager will continuously update the
75    * location and orientation of the model based on the current
76    * values of the properties.
77    */
78   virtual void add_instance (Instance * instance);
79
80
81   /**
82    * Remove an instance of a dynamic model from the manager.
83    *
84    * NOTE: the manager will delete the instance as well.
85    */
86   virtual void remove_instance (Instance * instance);
87
88   virtual void draw ();
89
90 private:
91
92   vector<Instance *> _instances;
93
94   ssgSelector * _selector;
95
96 };
97
98 #endif // __MODELMGR_HXX