]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.hxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / Model / modelmgr.hxx
index 1ea8aef6d5c274d0a93f9947bc3f07cf63243da7..664e48425da3b8f5d25ae26c99df93b5a3ea3b4d 100644 (file)
 
 #include <vector>
 
-#include <plib/ssg.h>
+#include <simgear/compiler.h>  // for SG_USING_STD
 
-#include <simgear/compiler.h>
-#include <simgear/misc/props.hxx>
-
-#include <Main/fgfs.hxx>
-
-#include "model.hxx"
+#include <Main/fgfs.hxx>       // for FGSubsystem
 
 SG_USING_STD(vector);
 
+// Don't pull in headers, since we don't need them here.
+class ssgSelector;
+class SGPropertyNode;
+class SGModelPlacement;
+
 
 /**
  * Manage a list of user-specified models.
@@ -30,23 +30,25 @@ SG_USING_STD(vector);
 class FGModelMgr : public FGSubsystem
 {
 public:
-  FGModelMgr ();
-  virtual ~FGModelMgr ();
-
-  virtual void init ();
-  virtual void bind ();
-  virtual void unbind ();
-  virtual void update (int dt);
-
-  virtual void draw ();
-
-private:
 
+  /**
+   * A dynamically-placed model using properties.
+   *
+   * The model manager uses the property nodes to update the model's
+   * position and orientation; any of the property node pointers may
+   * be set to zero to avoid update.  Normally, a caller should
+   * load the model by instantiating SGModelPlacement with the path
+   * to the model or its XML wrapper, then assign any relevant
+   * property node pointers.
+   *
+   * @see SGModelPlacement
+   * @see FGModelMgr#add_instance
+   */
   struct Instance
   {
     Instance ();
     virtual ~Instance ();
-    FG3DModel * model;
+    SGModelPlacement * model;
     SGPropertyNode * lon_deg_node;
     SGPropertyNode * lat_deg_node;
     SGPropertyNode * elev_ft_node;
@@ -55,15 +57,42 @@ private:
     SGPropertyNode * heading_deg_node;
   };
 
-  vector<Instance *> _instances;
+  FGModelMgr ();
+  virtual ~FGModelMgr ();
 
-  ssgRoot * _scene;
-  float _nearplane;
-  float _farplane;
+  virtual void init ();
+  virtual void bind ();
+  virtual void unbind ();
+  virtual void update (double dt);
+
+  /**
+   * Add an instance of a dynamic model to the manager.
+   *
+   * NOTE: pointer ownership is transferred to the model manager!
+   *
+   * The caller is responsible for setting up the Instance structure
+   * as required.  The model manager will continuously update the
+   * location and orientation of the model based on the current
+   * values of the properties.
+   */
+  virtual void add_instance (Instance * instance);
+
+
+  /**
+   * Remove an instance of a dynamic model from the manager.
+   *
+   * NOTE: the manager will delete the instance as well.
+   */
+  virtual void remove_instance (Instance * instance);
 
-};
+  virtual void draw ();
 
-#endif // __MODELMGR_HXX
+private:
+
+  vector<Instance *> _instances;
 
+  ssgSelector * _selector;
 
+};
 
+#endif // __MODELMGR_HXX