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

Revision 2709, 2.8 KB checked in by mattausch, 16 years ago (diff)

sheduling dynamic object only when necessary

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:
[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
[2709]78        bool HasChanged() { return mHasChanged; }
79
80        void SetHasChanged(bool hasChanged) {mHasChanged = hasChanged;}
[2678]81        SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
[372]82
[2702]83        const Matrix4x4 &GetTransformation() const { return mTrafo; }
84
85        //void SetGeometry(ObjectContainer *geometry);
86
87        /// used as actual pvs entry: note should be pointer to geometry!!
[2678]88        ObjectContainer mGeometry;
[2702]89
[2678]90protected:
[2600]91
[2678]92        SceneGraphLeafIntersectable *mIntersectable;
[2600]93
[2678]94        bool mIsDynamic;
[2709]95        bool mHasChanged;
96
[2678]97        Matrix4x4 mTrafo;
98};
99
100
101
[2609]102/** Scene graph class
103*/
104class SceneGraph
105{
[372]106
107public:
[1002]108
[1328]109        SceneGraph();
[1002]110        ~SceneGraph();
[1328]111       
[2176]112        bool Export(const std::string filename);
[372]113 
[2601]114        int CollectObjects(ObjectContainer &instances);
[492]115 
[1328]116        int AssignObjectIds();
[492]117 
[1328]118        void GetStatistics(int &intersectables, int &faces) const;
[372]119
[2615]120        AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); }
[1328]121        /** Exports binary version of the scene.
122        */
[2176]123        void ExportScene(const std::string filename);
[1328]124        /** Loads binary version of the scene.
125        */
[2176]126        void LoadScene(const std::string filename);
[1166]127
[2601]128        SceneGraphInterior *GetRoot();
[1328]129
[2601]130        //void SetRoot(SceneGraphNode *sgNnode);
131        void SetRoot(SceneGraphInterior *sgNnode);
[1328]132
[2601]133        void AddChild(SceneGraphNode *node);
[1958]134
[2601]135        int GetSize() const;
136
[372]137protected:
[1328]138
[2601]139         SceneGraphInterior *mRoot;
[372]140};
141
142
[860]143}
[372]144
145#endif
Note: See TracBrowser for help on using the repository browser.