[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 |
|
---|
[2678] | 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 | {
|
---|
[372] | 20 | public:
|
---|
| 21 |
|
---|
[2600] | 22 | virtual ~SceneGraphNode();
|
---|
[2678] | 23 | virtual bool IsLeaf() const = 0;
|
---|
| 24 |
|
---|
[2600] | 25 | virtual void UpdateBox() = 0;
|
---|
[2678] | 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; }
|
---|
[2600] | 42 | virtual void UpdateBox();
|
---|
[2678] | 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:
|
---|
[2702] | 57 | /** Copy constructor.
|
---|
| 58 | */
|
---|
| 59 | SceneGraphLeaf(SceneGraphLeaf const&);
|
---|
[2678] | 60 | SceneGraphLeaf();
|
---|
| 61 | SceneGraphLeaf(bool isDynamic);
|
---|
| 62 | ~SceneGraphLeaf();
|
---|
[2615] | 63 |
|
---|
| 64 | void LoadTransform(const Matrix4x4 &m);
|
---|
| 65 |
|
---|
| 66 | void GetTransform(Matrix4x4 &m) const;
|
---|
| 67 |
|
---|
| 68 | virtual AxisAlignedBox3 GetBox() const;
|
---|
[2694] | 69 | /** Returns the box without the trafo.
|
---|
| 70 | */
|
---|
| 71 | virtual AxisAlignedBox3 GetOriginalBox() const;
|
---|
[2678] | 72 |
|
---|
| 73 | virtual void ApplyTransform(const Matrix4x4 &trafo);
|
---|
| 74 | virtual bool IsDynamic() const { return mIsDynamic;}
|
---|
| 75 | virtual bool IsLeaf() const { return true; }
|
---|
[2600] | 76 | virtual void UpdateBox();
|
---|
[2621] | 77 |
|
---|
[2678] | 78 | SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
|
---|
[372] | 79 |
|
---|
[2702] | 80 | const Matrix4x4 &GetTransformation() const { return mTrafo; }
|
---|
| 81 |
|
---|
| 82 | //void SetGeometry(ObjectContainer *geometry);
|
---|
| 83 |
|
---|
| 84 | /// used as actual pvs entry: note should be pointer to geometry!!
|
---|
[2678] | 85 | ObjectContainer mGeometry;
|
---|
[2702] | 86 |
|
---|
| 87 |
|
---|
[2678] | 88 | protected:
|
---|
[2600] | 89 |
|
---|
[2678] | 90 | SceneGraphLeafIntersectable *mIntersectable;
|
---|
[2600] | 91 |
|
---|
[2678] | 92 | bool mIsDynamic;
|
---|
| 93 | Matrix4x4 mTrafo;
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 |
|
---|
[2609] | 98 | /** Scene graph class
|
---|
| 99 | */
|
---|
| 100 | class SceneGraph
|
---|
| 101 | {
|
---|
[372] | 102 |
|
---|
| 103 | public:
|
---|
[1002] | 104 |
|
---|
[1328] | 105 | SceneGraph();
|
---|
[1002] | 106 | ~SceneGraph();
|
---|
[1328] | 107 |
|
---|
[2176] | 108 | bool Export(const std::string filename);
|
---|
[372] | 109 |
|
---|
[2601] | 110 | int CollectObjects(ObjectContainer &instances);
|
---|
[492] | 111 |
|
---|
[1328] | 112 | int AssignObjectIds();
|
---|
[492] | 113 |
|
---|
[1328] | 114 | void GetStatistics(int &intersectables, int &faces) const;
|
---|
[372] | 115 |
|
---|
[2615] | 116 | AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); }
|
---|
[1328] | 117 | /** Exports binary version of the scene.
|
---|
| 118 | */
|
---|
[2176] | 119 | void ExportScene(const std::string filename);
|
---|
[1328] | 120 | /** Loads binary version of the scene.
|
---|
| 121 | */
|
---|
[2176] | 122 | void LoadScene(const std::string filename);
|
---|
[1166] | 123 |
|
---|
[2601] | 124 | SceneGraphInterior *GetRoot();
|
---|
[1328] | 125 |
|
---|
[2601] | 126 | //void SetRoot(SceneGraphNode *sgNnode);
|
---|
| 127 | void SetRoot(SceneGraphInterior *sgNnode);
|
---|
[1328] | 128 |
|
---|
[2601] | 129 | void AddChild(SceneGraphNode *node);
|
---|
[1958] | 130 |
|
---|
[2601] | 131 | int GetSize() const;
|
---|
| 132 |
|
---|
[372] | 133 | protected:
|
---|
[1328] | 134 |
|
---|
[2601] | 135 | SceneGraphInterior *mRoot;
|
---|
[372] | 136 | };
|
---|
| 137 |
|
---|
| 138 |
|
---|
[860] | 139 | }
|
---|
[372] | 140 |
|
---|
| 141 | #endif
|
---|