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

Group.h

Go to the documentation of this file.
00001 // Copyright NVIDIA Corporation 2002-2004
00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
00005 // AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 
00011 
00012 #pragma once
00013 
00015 #include "nvsgcommon.h"
00016 
00017 #include  "nvsg/Node.h"
00018 
00019 namespace nvsg
00020 {
00022 
00026   class Group : public Node
00027   {
00028     public:
00030 
00031       NVSG_API static const Group * create( void );
00032 
00034 
00035       NVSG_API static const Group * createFromBase( const Node &rhs  
00036                                                   );
00037 
00039 
00040       NVSG_API virtual const Group * clone( void ) const;
00041 
00043 
00044       NVSG_API virtual bool isDataShared( void ) const;
00045 
00047 
00048       NVSG_API virtual DataID getDataID( void ) const;
00049 
00051 
00052       NVSG_API size_t getNumberOfChildren( void ) const;
00053 
00055 
00061       NVSG_API size_t addChild( const Node * pChild                   
00062                               , size_t position = 0xFFFFFFFF    
00063                               );
00064       
00066 
00068       NVSG_API const Node * getChild( size_t index    
00069                                     ) const;
00070 
00072 
00076       NVSG_API bool removeChild( const Node * pChild   
00077                                );
00078 
00080 
00084       NVSG_API bool removeChild( size_t position    
00085                                );
00086 
00088 
00091       NVSG_API bool replaceChild( const Node * newChild   
00092                                 , const Node * oldChild   
00093                                 );
00094 
00096 
00099       NVSG_API bool replaceChild( const Node * newChild   
00100                                 , size_t position         
00101                                 );
00102       
00104 
00105       NVSG_API bool hasChild( const Node * node    
00106                             ) const;
00107 
00108       // Retrieve the index of the given node.
00115       NVSG_API bool getIndex( const Node * node   
00116                             , size_t & index      
00117                             ) const;
00118 
00120 
00121       NVSG_API virtual bool containsCgFx( void ) const;
00122 
00124 
00125       NVSG_API virtual void invalidateCgFxContainment( void );
00126 
00128 
00129       NVSG_API virtual bool containsLight( void ) const;
00130 
00132 
00133       NVSG_API virtual void invalidateLightContainment( void );
00134 
00136 
00138       NVSG_API virtual bool containsTransparentMaterial( void ) const;
00139 
00141 
00142       NVSG_API virtual void invalidateTransparentMaterialContainment( void );
00143 
00145 
00147       NVSG_API virtual bool containsTransparentTexture( void ) const;
00148 
00150 
00151       NVSG_API virtual void invalidateTransparentTextureContainment( void );
00152 
00154 
00155       NVSG_API virtual size_t getNumberOfFrames( void ) const;
00156 
00158 
00159       NVSG_API virtual void invalidateNumberOfFrames( void ) const;
00160 
00161     protected:
00163       NVSG_API Group( void );
00164 
00166       NVSG_API Group( const Node &rhs );
00167 
00169       NVSG_API Group( const Group& rhs );
00170 
00172       NVSG_API virtual ~Group(void);
00173 
00175 
00178       NVSG_API virtual bool calcBoundingSphere( void ) const;
00179 
00181 
00183       void  invalidateCaches( const Node *pChild    
00184                             , bool insert           
00185                             );
00186 
00187     private:
00188       std::vector<const Node*> m_children;       
00189 
00190       //  State caches
00191       mutable bool    m_containsCgFx;
00192       mutable bool    m_containsCgFxValid;
00193       mutable bool    m_containsLight;
00194       mutable bool    m_containsLightValid;
00195       mutable bool    m_containsTransparentMaterial;
00196       mutable bool    m_containsTransparentMaterialValid;
00197       mutable bool    m_containsTransparentTexture;
00198       mutable bool    m_containsTransparentTextureValid;
00199       mutable size_t  m_numberOfFrames;
00200       mutable bool    m_numberOfFramesValid;
00201   };
00202   
00203   inline size_t Group::getNumberOfChildren( void ) const
00204   {
00205     __TRACE();
00206     return( m_children.size() );
00207   }
00208 
00209   inline const Node * Group::getChild( size_t index ) const
00210   {
00211     __TRACE();
00212     __ASSERT(index<m_children.size()); // undefined behaviour for invalid index
00213     return m_children[index];
00214   }
00215 
00216   inline  void  Group::invalidateCaches( const Node *pChild, bool insert )
00217   {
00218     __TRACE();
00219     invalidateBoundingSphere();
00220     if ( pChild->containsCgFx() && ! ( insert && containsCgFx() ) )
00221     {
00222       invalidateCgFxContainment();
00223     }
00224     if ( pChild->containsLight() && ! ( insert && containsLight() ) )
00225     {
00226       invalidateLightContainment();
00227     }
00228     if ( pChild->containsTransparentMaterial() && ! ( insert && containsTransparentMaterial() ) )
00229     {
00230       invalidateTransparentMaterialContainment();
00231     }
00232     if ( pChild->containsTransparentTexture() && ! ( insert && containsTransparentTexture() ) )
00233     {
00234       invalidateTransparentTextureContainment();
00235     }
00236   }
00237 } //  namespace nvsg

Generated on Tue Mar 1 13:19:17 2005 for NVSGSDK by NVIDIA