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

Revision 2678, 2.5 KB checked in by mattausch, 16 years ago (diff)

started working on dynamic objects

RevLine 
[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]9namespace GtpVisibilityPreprocessor {
[2600]10
[2678]11class SceneGraphLeafIntersectable;
12class CKTB;
13
14
15/** Basic scene graph node, we are interested only in bounding boxes and topology
16    of the scene graph
17*/
18class SceneGraphNode
19{
[372]20public:
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
29protected:
30
31        AxisAlignedBox3 mBox;
32};
33 
34
35
36/** Scene graph interior node.
37*/
38class SceneGraphInterior: public SceneGraphNode
39{
40public:
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*/
54class SceneGraphLeaf: public SceneGraphNode
55{
56public:
57
58        SceneGraphLeaf();
59        SceneGraphLeaf(bool isDynamic);
60        ~SceneGraphLeaf();
[2615]61       
62        void LoadTransform(const Matrix4x4 &m);
63
64        void GetTransform(Matrix4x4 &m) const;
65
66        virtual AxisAlignedBox3 GetBox() const;
[2678]67
68        virtual void ApplyTransform(const Matrix4x4 &trafo);
69        virtual bool IsDynamic() const { return mIsDynamic;}
70        virtual bool IsLeaf() const { return true; }
[2600]71        virtual void UpdateBox();
[2621]72
[2678]73#if DYNAMIC_OBJECTS_HACK
74        SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
75#endif
[372]76
[2678]77        /// used as actual pvs entry
78        ObjectContainer mGeometry;
79  const Matrix4x4 &GetTransformation() const { return mTrafo; }
80protected:
[2600]81
[2678]82#if DYNAMIC_OBJECTS_HACK
83       
84        SceneGraphLeafIntersectable *mIntersectable;
85        CKTB *mKtbTree;
[2600]86
[2678]87#endif
88
89        bool mIsDynamic;
90        Matrix4x4 mTrafo;
91};
92
93
94
[2609]95/** Scene graph class
96*/
97class SceneGraph
98{
[372]99
100public:
[1002]101
[1328]102        SceneGraph();
[1002]103        ~SceneGraph();
[1328]104       
[2176]105        bool Export(const std::string filename);
[372]106 
[2601]107        int CollectObjects(ObjectContainer &instances);
[492]108 
[1328]109        int AssignObjectIds();
[492]110 
[1328]111        void GetStatistics(int &intersectables, int &faces) const;
[372]112
[2615]113        AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); }
[1328]114        /** Exports binary version of the scene.
115        */
[2176]116        void ExportScene(const std::string filename);
[1328]117        /** Loads binary version of the scene.
118        */
[2176]119        void LoadScene(const std::string filename);
[1166]120
[2601]121        SceneGraphInterior *GetRoot();
[1328]122
[2601]123        //void SetRoot(SceneGraphNode *sgNnode);
124        void SetRoot(SceneGraphInterior *sgNnode);
[1328]125
[2601]126        void AddChild(SceneGraphNode *node);
[1958]127
[2601]128        int GetSize() const;
129
[372]130protected:
[1328]131
[2601]132         SceneGraphInterior *mRoot;
[372]133};
134
135
[860]136}
[372]137
138#endif
Note: See TracBrowser for help on using the repository browser.