00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018 #include "Tree.h"
00019 #include "Primitive.h"
00020 #include "State.h"
00021 #include "ShadowVolumeGen.h"
00022 #include "DepthSorter.h"
00023
00024 using namespace std;
00025
00026 #ifndef N_SCENEGRAPH
00027 #define N_SCENEGRAPH
00028
00029 namespace Fluxus
00030 {
00031
00036 class SceneNode : public Node
00037 {
00038 public:
00039 SceneNode(Primitive *p) : Prim(p) {}
00040 virtual ~SceneNode() { if (Prim) delete Prim; }
00041 Primitive *Prim;
00042 };
00043
00044 istream &operator>>(istream &s, SceneNode &o);
00045 ostream &operator<<(ostream &s, SceneNode &o);
00046
00049 class SceneGraph : public Tree
00050 {
00051 public:
00052 SceneGraph();
00053 ~SceneGraph();
00054
00055 enum Mode{RENDER,SELECT};
00056
00059 void Render(Mode rendermode=RENDER);
00060
00062 virtual void Clear();
00063
00068 void Detach(SceneNode *node);
00069
00071 dMatrix GetGlobalTransform(const SceneNode *node) const;
00072
00075 void GetBoundingBox(SceneNode *node, dBoundingBox &result);
00076
00078 ShadowVolumeGen *GetShadowVolumeGen() { return &m_ShadowVolumeGen; }
00079
00081 void GetNodes(const Node *node, vector<const SceneNode*> &nodes) const;
00082
00084 void GetConnections(const Node *node,
00085 vector<pair<const SceneNode*,const SceneNode*> > &connections) const;
00086
00087 private:
00088 void RenderWalk(SceneNode *node, int depth, Mode rendermode);
00089 void GetBoundingBox(SceneNode *node, dMatrix mat, dBoundingBox &result);
00090 bool FrustumClip(SceneNode *node);
00091 void CohenSutherland(const dVector &p, char &cs);
00092
00093 ShadowVolumeGen m_ShadowVolumeGen;
00094 DepthSorter m_DepthSorter;
00095 dMatrix m_TopTransform;
00096 };
00097
00098 }
00099
00100 #endif