1 | #ifndef _SceneGraph_H__
|
---|
2 | #define _SceneGraph_H__
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | #include "Containers.h"
|
---|
6 | #include "AxisAlignedBox3.h"
|
---|
7 | #include "Matrix4x4.h"
|
---|
8 |
|
---|
9 | namespace GtpVisibilityPreprocessor {
|
---|
10 |
|
---|
11 | class SceneGraphLeafIntersectable;
|
---|
12 | class CKTB;
|
---|
13 |
|
---|
14 |
|
---|
15 | /** Basic scene graph node, we are interested only in bounding boxes and topology
|
---|
16 | of the scene graph
|
---|
17 | */
|
---|
18 | class SceneGraphNode
|
---|
19 | {
|
---|
20 | public:
|
---|
21 |
|
---|
22 | virtual ~SceneGraphNode();
|
---|
23 | virtual bool IsLeaf() const = 0;
|
---|
24 |
|
---|
25 | virtual void UpdateBox() = 0;
|
---|
26 |
|
---|
27 | virtual AxisAlignedBox3 GetBox() const { return mBox; }
|
---|
28 |
|
---|
29 | protected:
|
---|
30 |
|
---|
31 | AxisAlignedBox3 mBox;
|
---|
32 | };
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | /** Scene graph interior node.
|
---|
37 | */
|
---|
38 | class SceneGraphInterior: public SceneGraphNode
|
---|
39 | {
|
---|
40 | public:
|
---|
41 | virtual bool IsLeaf() const { return false; }
|
---|
42 | virtual void UpdateBox();
|
---|
43 |
|
---|
44 | ~SceneGraphInterior();
|
---|
45 |
|
---|
46 | //protected:
|
---|
47 |
|
---|
48 | SceneGraphNodeContainer mChildren;
|
---|
49 | };
|
---|
50 |
|
---|
51 |
|
---|
52 | /** Scene graph leaf node.
|
---|
53 | */
|
---|
54 | class SceneGraphLeaf: public SceneGraphNode
|
---|
55 | {
|
---|
56 | public:
|
---|
57 | /** Copy constructor.
|
---|
58 | */
|
---|
59 | SceneGraphLeaf(SceneGraphLeaf const&);
|
---|
60 | SceneGraphLeaf();
|
---|
61 | SceneGraphLeaf(bool isDynamic);
|
---|
62 | ~SceneGraphLeaf();
|
---|
63 |
|
---|
64 | void LoadTransform(const Matrix4x4 &m);
|
---|
65 |
|
---|
66 | void GetTransform(Matrix4x4 &m) const;
|
---|
67 |
|
---|
68 | virtual AxisAlignedBox3 GetBox() const;
|
---|
69 | /** Returns the box without the trafo.
|
---|
70 | */
|
---|
71 | virtual AxisAlignedBox3 GetOriginalBox() const;
|
---|
72 |
|
---|
73 | virtual void ApplyTransform(const Matrix4x4 &trafo);
|
---|
74 | virtual bool IsDynamic() const { return mIsDynamic;}
|
---|
75 | virtual bool IsLeaf() const { return true; }
|
---|
76 | virtual void UpdateBox();
|
---|
77 |
|
---|
78 | bool HasChanged() { return mHasChanged; }
|
---|
79 |
|
---|
80 | void SetHasChanged(bool hasChanged) {mHasChanged = hasChanged;}
|
---|
81 | SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
|
---|
82 |
|
---|
83 | const Matrix4x4 &GetTransformation() const { return mTrafo; }
|
---|
84 |
|
---|
85 | //void SetGeometry(ObjectContainer *geometry);
|
---|
86 |
|
---|
87 | /// used as actual pvs entry: note should be pointer to geometry!!
|
---|
88 | ObjectContainer mGeometry;
|
---|
89 |
|
---|
90 | protected:
|
---|
91 |
|
---|
92 | SceneGraphLeafIntersectable *mIntersectable;
|
---|
93 |
|
---|
94 | bool mIsDynamic;
|
---|
95 | bool mHasChanged;
|
---|
96 |
|
---|
97 | Matrix4x4 mTrafo;
|
---|
98 |
|
---|
99 | bool mDeleteGeometry;
|
---|
100 | };
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 | /** Scene graph class
|
---|
105 | */
|
---|
106 | class SceneGraph
|
---|
107 | {
|
---|
108 |
|
---|
109 | public:
|
---|
110 |
|
---|
111 | SceneGraph();
|
---|
112 | ~SceneGraph();
|
---|
113 |
|
---|
114 | bool Export(const std::string filename);
|
---|
115 |
|
---|
116 | int CollectObjects(ObjectContainer &instances);
|
---|
117 |
|
---|
118 | int AssignObjectIds();
|
---|
119 |
|
---|
120 | void GetStatistics(int &intersectables, int &faces) const;
|
---|
121 |
|
---|
122 | AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); }
|
---|
123 | /** Exports binary version of the scene.
|
---|
124 | */
|
---|
125 | void ExportScene(const std::string filename);
|
---|
126 | /** Loads binary version of the scene.
|
---|
127 | */
|
---|
128 | void LoadScene(const std::string filename);
|
---|
129 |
|
---|
130 | SceneGraphInterior *GetRoot();
|
---|
131 |
|
---|
132 | //void SetRoot(SceneGraphNode *sgNnode);
|
---|
133 | void SetRoot(SceneGraphInterior *sgNnode);
|
---|
134 |
|
---|
135 | void AddChild(SceneGraphNode *node);
|
---|
136 |
|
---|
137 | int GetSize() const;
|
---|
138 |
|
---|
139 | protected:
|
---|
140 |
|
---|
141 | SceneGraphInterior *mRoot;
|
---|
142 | };
|
---|
143 |
|
---|
144 |
|
---|
145 | }
|
---|
146 |
|
---|
147 | #endif
|
---|