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

Revision 2636, 2.5 KB checked in by bittner, 16 years ago (diff)

moving objects partially functional

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
[2615]11class SceneGraphLeafIntersectable;
[2621]12class CKTB;
[2600]13
[2621]14
[2600]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();
23        virtual bool IsLeaf() const = 0;
24
25        virtual void UpdateBox() = 0;
26
[2615]27        virtual AxisAlignedBox3 GetBox() const { return mBox; }
[2600]28
[2615]29protected:
30
[2600]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; }
42        virtual void UpdateBox();
43
[2610]44        ~SceneGraphInterior();
45
[2600]46//protected:
47
[2601]48        SceneGraphNodeContainer mChildren;
[2600]49};
50
51
52/** Scene graph leaf node.
53*/
54class SceneGraphLeaf: public SceneGraphNode
55{
56public:
57
[2615]58        SceneGraphLeaf();
59        SceneGraphLeaf(bool isDynamic);
[2609]60        ~SceneGraphLeaf();
[2615]61       
62        void LoadTransform(const Matrix4x4 &m);
63
64        void GetTransform(Matrix4x4 &m) const;
65
66        virtual AxisAlignedBox3 GetBox() const;
[2609]67
[2615]68        virtual void ApplyTransform(const Matrix4x4 &trafo);
[2609]69        virtual bool IsDynamic() const { return mIsDynamic;}
[2600]70        virtual bool IsLeaf() const { return true; }
71        virtual void UpdateBox();
[2621]72
73#if DYNAMIC_OBJECTS_HACK
74        void RebuildKtbTree();
75        SceneGraphLeafIntersectable *GetIntersectable() { return mIntersectable; }
[2615]76#endif
[2621]77
[2615]78        /// used as actual pvs entry
[2609]79        ObjectContainer mGeometry;
[2636]80  const Matrix4x4 &GetTransformation() const { return mTrafo; }
[2609]81protected:
[2621]82
83#if DYNAMIC_OBJECTS_HACK
84       
[2615]85        SceneGraphLeafIntersectable *mIntersectable;
[2621]86        CKTB *mKtbTree;
87
[2615]88#endif
[2621]89
[2609]90        bool mIsDynamic;
91        Matrix4x4 mTrafo;
[2600]92};
[372]93
[2600]94
95
[2609]96/** Scene graph class
97*/
98class SceneGraph
99{
[372]100
101public:
[1002]102
[1328]103        SceneGraph();
[1002]104        ~SceneGraph();
[1328]105       
[2176]106        bool Export(const std::string filename);
[372]107 
[2601]108        int CollectObjects(ObjectContainer &instances);
[492]109 
[1328]110        int AssignObjectIds();
[492]111 
[1328]112        void GetStatistics(int &intersectables, int &faces) const;
[372]113
[2615]114        AxisAlignedBox3 GetBox() const { return mRoot->GetBox(); }
[1328]115        /** Exports binary version of the scene.
116        */
[2176]117        void ExportScene(const std::string filename);
[1328]118        /** Loads binary version of the scene.
119        */
[2176]120        void LoadScene(const std::string filename);
[1166]121
[2601]122        SceneGraphInterior *GetRoot();
[1328]123
[2601]124        //void SetRoot(SceneGraphNode *sgNnode);
125        void SetRoot(SceneGraphInterior *sgNnode);
[1328]126
[2601]127        void AddChild(SceneGraphNode *node);
[1958]128
[2601]129        int GetSize() const;
130
[372]131protected:
[1328]132
[2601]133         SceneGraphInterior *mRoot;
[372]134};
135
136
[860]137}
[372]138
139#endif
Note: See TracBrowser for help on using the repository browser.