[372] | 1 | #ifndef _SceneGraph_H__
|
---|
| 2 | #define _SceneGraph_H__
|
---|
| 3 |
|
---|
| 4 | #include <string>
|
---|
| 5 | #include "Containers.h"
|
---|
| 6 | #include "AxisAlignedBox3.h"
|
---|
[2609] | 7 | #include "Matrix4x4.h"
|
---|
[372] | 8 |
|
---|
[860] | 9 | namespace GtpVisibilityPreprocessor {
|
---|
[2600] | 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 | { |
---|
[372] | 17 | public:
|
---|
| 18 |
|
---|
[2600] | 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 | |
---|
[2610] | 39 | ~SceneGraphInterior(); |
---|
| 40 | |
---|
[2600] | 41 | //protected: |
---|
| 42 | |
---|
[2601] | 43 | SceneGraphNodeContainer mChildren; |
---|
[2600] | 44 | }; |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | /** Scene graph leaf node. |
---|
| 48 | */ |
---|
| 49 | class SceneGraphLeaf: public SceneGraphNode |
---|
| 50 | { |
---|
| 51 | public: |
---|
| 52 | |
---|
[2609] | 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;} |
---|
[2600] | 59 | virtual bool IsLeaf() const { return true; } |
---|
| 60 | virtual void UpdateBox();
|
---|
| 61 | |
---|
[2609] | 62 | ObjectContainer mGeometry; |
---|
[2606] | 63 | |
---|
[2609] | 64 | protected: |
---|
[2600] | 65 | |
---|
[2609] | 66 | bool mIsDynamic; |
---|
| 67 | Matrix4x4 mTrafo; |
---|
[2600] | 68 | }; |
---|
[372] | 69 |
|
---|
[2600] | 70 |
|
---|
| 71 |
|
---|
[2609] | 72 | /** Scene graph class
|
---|
| 73 | */
|
---|
| 74 | class SceneGraph
|
---|
| 75 | {
|
---|
[372] | 76 |
|
---|
| 77 | public:
|
---|
[1002] | 78 |
|
---|
[1328] | 79 | SceneGraph();
|
---|
[1002] | 80 | ~SceneGraph();
|
---|
[1328] | 81 |
|
---|
[2176] | 82 | bool Export(const std::string filename);
|
---|
[372] | 83 |
|
---|
[2601] | 84 | int CollectObjects(ObjectContainer &instances);
|
---|
[492] | 85 |
|
---|
[1328] | 86 | int AssignObjectIds();
|
---|
[492] | 87 |
|
---|
[1328] | 88 | void GetStatistics(int &intersectables, int &faces) const;
|
---|
[372] | 89 |
|
---|
[1328] | 90 | AxisAlignedBox3 GetBox() const { return mRoot->mBox; }
|
---|
| 91 | /** Exports binary version of the scene.
|
---|
| 92 | */
|
---|
[2176] | 93 | void ExportScene(const std::string filename);
|
---|
[1328] | 94 | /** Loads binary version of the scene.
|
---|
| 95 | */
|
---|
[2176] | 96 | void LoadScene(const std::string filename);
|
---|
[1166] | 97 |
|
---|
[2601] | 98 | SceneGraphInterior *GetRoot();
|
---|
[1328] | 99 |
|
---|
[2601] | 100 | //void SetRoot(SceneGraphNode *sgNnode);
|
---|
| 101 | void SetRoot(SceneGraphInterior *sgNnode);
|
---|
[1328] | 102 |
|
---|
[2601] | 103 | void AddChild(SceneGraphNode *node);
|
---|
[1958] | 104 |
|
---|
[2601] | 105 | int GetSize() const;
|
---|
| 106 |
|
---|
[372] | 107 | protected:
|
---|
[1328] | 108 |
|
---|
[2601] | 109 | SceneGraphInterior *mRoot;
|
---|
[372] | 110 | };
|
---|
| 111 |
|
---|
| 112 |
|
---|
[860] | 113 | }
|
---|
[372] | 114 |
|
---|
| 115 | #endif
|
---|