Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglNode.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglNode.hpp
00021  *  Created: 30 December 1997
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 // foward reference this stuff
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    // See sglObject::printInfo() for details.
00288    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00289 
00290 protected:
00291    virtual void computeBound() = 0; // this node only - no traversal
00292    virtual void computeBoundsRecursiveDown(); // downward trav
00293 
00294    // bit or the dirty bits with the given mask
00295    virtual void dirty(unsigned char mask);
00296 
00297    // used by the clone traversal
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    // not implemented
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

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001