SceneGraph.h

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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

Generated on Wed Sep 17 21:16:30 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1