Dragonfly  4.3
A text-based game engine
SceneGraph.h
1 ///
2 /// A scene graph
3 ///
4 
5 #ifndef __SCENE_GRAPH_H__
6 #define __SCENE_GRAPH_H__
7 
8 #include "Object.h"
9 #include "ObjectList.h"
10 
11 namespace df {
12 
13 const int MAX_ALTITUDE = 4;
14 
15 class SceneGraph {
16 
17  private:
18  ObjectList m_active_objects; ///< All active Objects.
19  ObjectList m_solid_objects; ///< Solid Objects.
20  ObjectList m_visible_objects[MAX_ALTITUDE+1]; ///< Visible Objects.
21  ObjectList m_inactive_objects; ///< All inactive Objects.
22 
23  public:
24  SceneGraph();
25 
26  /// Insert Object into SceneGraph.
27  int insertObject(Object *p_o);
28 
29  /// Remove Object from SceneGraph.
30  int removeObject(Object *p_o);
31 
32  /// Return all active Objects. Empty list if none.
33  ObjectList activeObjects() const;
34 
35  /// Return all active, solid Objects. Empty list if none.
36  ObjectList solidObjects() const;
37 
38  /// Return all active, visible Objects at altitude. Empty list if none.
39  ObjectList visibleObjects(int altitude) const;
40 
41  /// Return all inactive Objects. Empty list if none.
43 
44  /// Re-position Object in SceneGraph to new altitude.
45  /// Return 0 if ok, else -1.
46  int updateAltitude(Object *p_o, int new_alt);
47 
48  /// Re-position Object in SceneGraph to new solidness.
49  /// Return 0 if ok, else -1.
50  int updateSolidness(Object *p_o, Solidness new_solidness);
51 
52  /// Re-position Object in SceneGraph to new visibility.
53  /// Return 0 if ok, else -1.
54  int updateVisible(Object *p_vo, bool new_visible);
55 
56  /// Re-position Object in SceneGraph to new activeness.
57  /// Return 0 if ok, else -1.
58  int updateActive(Object *p_o, bool new_active);
59 };
60 
61 } // end of namespace df
62 #endif // __SCENE_GRAPH_H__
Solidness
Types of solidness of Object.
Definition: Object.h:26
Definition: SceneGraph.h:15
ObjectList m_visible_objects[MAX_ALTITUDE+1]
Visible Objects.
Definition: SceneGraph.h:20
int updateAltitude(Object *p_o, int new_alt)
Re-position Object in SceneGraph to new altitude.
Definition: ObjectList.h:15
A 2-d bounding box.
Definition: Box.h:10
int updateVisible(Object *p_vo, bool new_visible)
Re-position Object in SceneGraph to new visibility.
ObjectList m_solid_objects
Solid Objects.
Definition: SceneGraph.h:19
int removeObject(Object *p_o)
Remove Object from SceneGraph.
ObjectList m_inactive_objects
All inactive Objects.
Definition: SceneGraph.h:21
Definition: Object.h:59
ObjectList inactiveObjects() const
Return all inactive Objects. Empty list if none.
int insertObject(Object *p_o)
Insert Object into SceneGraph.
ObjectList m_active_objects
All active Objects.
Definition: SceneGraph.h:18
int updateActive(Object *p_o, bool new_active)
Re-position Object in SceneGraph to new activeness.
ObjectList visibleObjects(int altitude) const
Return all active, visible Objects at altitude. Empty list if none.
ObjectList activeObjects() const
Return all active Objects. Empty list if none.
int updateSolidness(Object *p_o, Solidness new_solidness)
Re-position Object in SceneGraph to new solidness.
ObjectList solidObjects() const
Return all active, solid Objects. Empty list if none.