source: GTP/trunk/Lib/Vis/Preprocessing/src/SceneGraph.h @ 2615

Revision 2615, 2.3 KB checked in by mattausch, 16 years ago (diff)

did some stuff for the visualization

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