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(ShadowVolumeGen *shadowgen, unsigned int camera, 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 void GetNodes(const Node *node, vector<const SceneNode*> &nodes) const;
00079
00081 void GetConnections(const Node *node,
00082 vector<pair<const SceneNode*,const SceneNode*> > &connections) const;
00083
00084 private:
00085 void RenderWalk(SceneNode *node, int depth, unsigned int cameracode, ShadowVolumeGen *shadowgen, Mode rendermode);
00086 void GetBoundingBox(SceneNode *node, dMatrix mat, dBoundingBox &result);
00087 bool FrustumClip(SceneNode *node);
00088 void CohenSutherland(const dVector &p, char &cs);
00089
00090 DepthSorter m_DepthSorter;
00091 dMatrix m_TopTransform;
00092 };
00093
00094 }
00095
00096 #endif