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

Drawable.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/Object.h"
00018 
00019 //  forward declarations
00020 namespace nvmath
00021 {
00022   class Sphere3f;
00023 }
00024 namespace nvsg
00025 {
00026   class GeoNode;
00027 }
00028 
00029 namespace nvsg
00030 {
00032 
00033   class Drawable : public Object
00034   {
00035     public:
00036       // ! Resolve construction of the right drawable type through late binding.
00038       NVSG_API virtual const Drawable * clone( void ) const = 0;
00039 
00041 
00043       NVSG_API virtual bool isBoundingSphereValid( void ) const = 0;
00044 
00046 
00050       NVSG_API virtual const nvmath::Sphere3f & getBoundingSphere( void ) const = 0;
00051 
00053       NVSG_API void invalidateNumberOfFrames( void ) const;
00054 
00056 
00057       NVSG_API virtual size_t getNumberOfFrames( void ) const;
00058 
00060 
00061       NVSG_API size_t getNumberOfOwners( void ) const;
00062 
00064 
00065       NVSG_API const GeoNode * getOwner( size_t index    
00066                                        ) const;
00067 
00068       //--  Functions reimplemented from Object  --
00069       NVSG_API virtual DataID getDataID( void ) const;
00070       NVSG_API virtual bool isDataShared( void ) const;
00071 
00072     protected:
00074       NVSG_API Drawable( void );
00075       // Copy constructor
00076       NVSG_API Drawable( const Drawable& );
00077 
00079       NVSG_API virtual ~Drawable( void );
00080 
00082       NVSG_API virtual void invalidateBoundingSphere( void ) const;
00083 
00084     private:
00085       // A Drawable can be the child of more than one parent. The child-to-parent connection 
00086       // is used, for example, when invalidating the owner GeoNode's BoundingSphere while 
00087       // invalidating the BoundingSphere of a Drawable.
00088       friend class GeoNode;
00089       void addOwner( const GeoNode * node );
00090       void removeOwner( const GeoNode * node );
00091 
00092     private:
00093       std::vector<const GeoNode*>  m_owners;   
00094   };
00095 
00096   inline size_t Drawable::getNumberOfOwners( void ) const
00097   {
00098      __TRACE();
00099     return( m_owners.size() );
00100   }
00101 
00102   inline const GeoNode * Drawable::getOwner( size_t index ) const
00103   {
00104     __TRACE();
00105     __ASSERT( index < m_owners.size() );   
00106     return( m_owners[index] );
00107   }
00108 } // namespace nvsg
00109 

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