00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __SGL_NODE_HPP
00025 #define __SGL_NODE_HPP
00026
00027 #include <vector>
00028 #include <deque>
00029
00030 #include <sgl.h>
00031 #include <sglTimespec.hpp>
00032 #include <sglIntersect.hpp>
00033 #include <sglPick.hpp>
00034 #include <sglSphereBound.hpp>
00035 #include <sglObject.hpp>
00036 #include <sglFrustum.hpp>
00037 #include <sglMatrix.hpp>
00038
00039
00040 template <class T> class sglCull;
00041
00042 class sglGroup;
00043 class sglGeode;
00044 class sglDrawable;
00045 class sglGeoSet;
00046 class sglStatelet;
00047
00048
00049
00122
00123
00124 class SGL_DLL_API sglNode : public sglObject
00125 {
00126 public:
00128 sglNode();
00130 virtual ~sglNode();
00131
00135 unsigned int getNumParents() const { return m_parent_list.size(); }
00136
00142 sglGroup* getParent(unsigned int index) const;
00143
00155 void setBound(const sglSphereBound<float> *sphere, sglBound::ModeEnum mode);
00156
00162 const sglSphereBound<float> &getBound();
00163
00168 sglBound::ModeEnum getBoundMode() const {return m_bound_mode;}
00169
00171 const sglSphereBound<float> &getPrevBound() const { return m_sphere; }
00172
00174 struct PreDrawStruct
00175 {
00176 unsigned int m_frame_count;
00177 sglTimespec m_frame_time;
00178 };
00179
00190 virtual void preDraw(const PreDrawStruct &trav_state);
00191
00200 virtual void computeTxToParent(sglMat4f &) const {}
00201
00210 virtual void computeTxToParent(sglMat4d &) const {}
00211
00217 virtual sglBound::IntersectResultEnum intersect(sglIntersectf &) const
00218 {
00219 return sglBound::eOUTSIDE;
00220 }
00221
00227 virtual sglBound::IntersectResultEnum intersect(sglIntersectd &) const
00228 {
00229 return sglBound::eOUTSIDE;
00230 }
00231
00240 virtual void pick(sglPickf &, unsigned int) const {}
00241
00250 virtual void pick(sglPickd &, unsigned int) const {}
00251
00263 virtual void cull(sglCull<float> &trav_state,
00264 unsigned int cull_flags) const = 0;
00265
00277 virtual void cull(sglCull<double> &trav_state,
00278 unsigned int cull_flags) const = 0;
00279
00285 virtual sglNode *clone(unsigned int mode) const = 0;
00286
00287
00288 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00289
00290 protected:
00291 virtual void computeBound() = 0;
00292 virtual void computeBoundsRecursiveDown();
00293
00294
00295 virtual void dirty(unsigned char mask);
00296
00297
00298 void copyTo(sglNode *dst, unsigned int mode) const;
00299
00300 friend class sglDrawable;
00301
00302 private:
00303 friend class sglGroup;
00304 void addParent(sglGroup *parent);
00305 void removeParent(sglGroup *parent);
00306
00307
00308 sglNode(const sglNode &);
00309 sglNode &operator=(const sglNode &);
00310
00311 protected:
00312 sglSphereBound<float> m_sphere;
00313 sglBound::ModeEnum m_bound_mode;
00314
00315 enum DirtyEnum { eBOUND = 0x01, eDLIST = 0x02, eANIMATION = 0x04 };
00316 unsigned char m_dirty;
00317
00318 private:
00319 vector<sglGroup*> m_parent_list;
00320 };
00321
00322 #endif