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 | |
---|
12 | /** Basic scene graph node, we are interested only in bounding boxes and topology |
---|
13 | of the scene graph |
---|
14 | */ |
---|
15 | class SceneGraphNode |
---|
16 | { |
---|
17 | public:
|
---|
18 |
|
---|
19 | virtual ~SceneGraphNode();
|
---|
20 | virtual bool IsLeaf() const = 0; |
---|
21 | |
---|
22 | virtual void UpdateBox() = 0;
|
---|
23 | |
---|
24 | //protected: |
---|
25 | |
---|
26 | AxisAlignedBox3 mBox; |
---|
27 | }; |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | /** Scene graph interior node. |
---|
32 | */ |
---|
33 | class SceneGraphInterior: public SceneGraphNode |
---|
34 | { |
---|
35 | public: |
---|
36 | virtual bool IsLeaf() const { return false; } |
---|
37 | virtual void UpdateBox();
|
---|
38 | |
---|
39 | ~SceneGraphInterior(); |
---|
40 | |
---|
41 | //protected: |
---|
42 | |
---|
43 | SceneGraphNodeContainer mChildren; |
---|
44 | }; |
---|
45 | |
---|
46 | |
---|
47 | /** Scene graph leaf node. |
---|
48 | */ |
---|
49 | class SceneGraphLeaf: public SceneGraphNode |
---|
50 | { |
---|
51 | public: |
---|
52 | |
---|
53 | SceneGraphLeaf(bool isDynamic = false): |
---|
54 | mIsDynamic(isDynamic){} |
---|
55 | ~SceneGraphLeaf(); |
---|
56 | |
---|
57 | virtual void Transform(const Matrix4x4 &trafo); |
---|
58 | virtual bool IsDynamic() const { return mIsDynamic;} |
---|
59 | virtual bool IsLeaf() const { return true; } |
---|
60 | virtual void UpdateBox();
|
---|
61 | |
---|
62 | ObjectContainer mGeometry; |
---|
63 | |
---|
64 | protected: |
---|
65 | |
---|
66 | bool mIsDynamic; |
---|
67 | Matrix4x4 mTrafo; |
---|
68 | }; |
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 | /** Scene graph class
|
---|
73 | */
|
---|
74 | class SceneGraph
|
---|
75 | {
|
---|
76 |
|
---|
77 | public:
|
---|
78 |
|
---|
79 | SceneGraph();
|
---|
80 | ~SceneGraph();
|
---|
81 |
|
---|
82 | bool Export(const std::string filename);
|
---|
83 |
|
---|
84 | int CollectObjects(ObjectContainer &instances);
|
---|
85 |
|
---|
86 | int AssignObjectIds();
|
---|
87 |
|
---|
88 | void GetStatistics(int &intersectables, int &faces) const;
|
---|
89 |
|
---|
90 | AxisAlignedBox3 GetBox() const { return mRoot->mBox; }
|
---|
91 | /** Exports binary version of the scene.
|
---|
92 | */
|
---|
93 | void ExportScene(const std::string filename);
|
---|
94 | /** Loads binary version of the scene.
|
---|
95 | */
|
---|
96 | void LoadScene(const std::string filename);
|
---|
97 |
|
---|
98 | SceneGraphInterior *GetRoot();
|
---|
99 |
|
---|
100 | //void SetRoot(SceneGraphNode *sgNnode);
|
---|
101 | void SetRoot(SceneGraphInterior *sgNnode);
|
---|
102 |
|
---|
103 | void AddChild(SceneGraphNode *node);
|
---|
104 |
|
---|
105 | int GetSize() const;
|
---|
106 |
|
---|
107 | protected:
|
---|
108 |
|
---|
109 | SceneGraphInterior *mRoot;
|
---|
110 | };
|
---|
111 |
|
---|
112 |
|
---|
113 | }
|
---|
114 |
|
---|
115 | #endif
|
---|