1 // model-mgr.hxx - manage user-specified 3D models.
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
7 #define __MODELMGR_HXX 1
12 #include <simgear/compiler.h> // for SG_USING_STD
13 #include <simgear/structure/subsystem_mgr.hxx>
15 // Don't pull in headers, since we don't need them here.
17 class SGModelPlacement;
21 * Manage a list of user-specified models.
23 class FGModelMgr : public SGSubsystem
28 * A dynamically-placed model using properties.
30 * The model manager uses the property nodes to update the model's
31 * position and orientation; any of the property node pointers may
32 * be set to zero to avoid update. Normally, a caller should
33 * load the model by instantiating SGModelPlacement with the path
34 * to the model or its XML wrapper, then assign any relevant
35 * property node pointers.
37 * @see SGModelPlacement
38 * @see FGModelMgr#add_instance
44 SGModelPlacement * model;
45 SGPropertyNode_ptr node;
46 SGPropertyNode_ptr lon_deg_node;
47 SGPropertyNode_ptr lat_deg_node;
48 SGPropertyNode_ptr elev_ft_node;
49 SGPropertyNode_ptr roll_deg_node;
50 SGPropertyNode_ptr pitch_deg_node;
51 SGPropertyNode_ptr heading_deg_node;
56 virtual ~FGModelMgr ();
59 virtual void shutdown ();
62 virtual void unbind ();
63 virtual void update (double dt);
65 virtual void add_model (SGPropertyNode * node);
68 * Add an instance of a dynamic model to the manager.
70 * NOTE: pointer ownership is transferred to the model manager!
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.
77 virtual void add_instance (Instance * instance);
81 * Remove an instance of a dynamic model from the manager.
83 * NOTE: the manager will delete the instance as well.
85 virtual void remove_instance (Instance * instance);
87 static const char* subsystemName() { return "model-manager"; }
90 * Listener class that adds models at runtime.
92 class Listener : public SGPropertyChangeListener
95 Listener(FGModelMgr *mgr) : _mgr(mgr) {}
96 virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child);
97 virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child);
103 SGPropertyNode_ptr _models;
104 std::auto_ptr<Listener> _listener;
106 std::vector<Instance *> _instances;
110 #endif // __MODELMGR_HXX