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/Animation.h" 00018 00019 #ifdef _DEBUG 00020 # ifndef new 00021 # define new new(__FILE__, __LINE__) 00022 # define _DEFINED_DBGNEW // restrict the 'new' macro to this header file only 00023 # endif 00024 #endif 00025 00026 namespace nvsg 00027 { 00028 class VNVector; 00029 00031 00032 template<typename T> class FramedAnimation : public Animation<T> 00033 { 00034 public: 00036 00037 static const FramedAnimation<T> * create( void ); 00038 00040 00041 static const FramedAnimation<T> * createFromBase( const Animation<T> &rhs 00042 ); 00043 00045 00046 virtual const FramedAnimation<T> * clone( void ) const; 00047 00049 00050 virtual void setNumberOfFrames( size_t count ); 00051 00053 00054 virtual T & operator[]( size_t i ); 00055 00056 //-- Functions reimplemented from Animation -- 00057 virtual size_t getNumberOfFrames( void ) const; 00058 virtual const T & operator[]( size_t i ) const; 00059 00060 protected: 00062 NVSG_API FramedAnimation( void ); 00063 00065 NVSG_API FramedAnimation( const Animation<T> &rhs ); 00066 00068 NVSG_API FramedAnimation( const FramedAnimation<T> &rhs ); 00069 00071 virtual ~FramedAnimation( void ); 00072 00073 private: 00074 std::vector<T> m_values; 00075 }; 00076 00077 template<typename T> FramedAnimation<T>::~FramedAnimation( void ) 00078 { 00079 __TRACE(); 00080 } 00081 00082 template<typename T> const FramedAnimation<T> * FramedAnimation<T>::create( void ) 00083 { 00084 __TRACE(); 00085 return( new FramedAnimation<T> ); 00086 } 00087 00088 template<typename T> const FramedAnimation<T> * FramedAnimation<T>::createFromBase( const Animation<T> &rhs ) 00089 { 00090 __TRACE(); 00091 return( new FramedAnimation<T>( rhs ) ); 00092 } 00093 00094 template<typename T> const FramedAnimation<T> * FramedAnimation<T>::clone( void ) const 00095 { 00096 __TRACE(); 00097 return( new FramedAnimation<T>( *this ) ); 00098 } 00099 00100 template<typename T> void FramedAnimation<T>::setNumberOfFrames( size_t count ) 00101 { 00102 __TRACE(); 00103 m_values.resize( count ); 00104 } 00105 00106 template<typename T> T & FramedAnimation<T>::operator[]( size_t i ) 00107 { 00108 __TRACE(); 00109 __ASSERT( i < m_values.size() ); 00110 return( m_values[i] ); 00111 } 00112 00113 template<typename T> size_t FramedAnimation<T>::getNumberOfFrames( void ) const 00114 { 00115 __TRACE(); 00116 return( m_values.size() ); 00117 } 00118 00119 template<typename T> const T & FramedAnimation<T>::operator[]( size_t i ) const 00120 { 00121 __TRACE(); 00122 __ASSERT( i < m_values.size() ); 00123 return( m_values[i] ); 00124 } 00125 } 00126 00127 #ifdef _DEFINED_DBGNEW 00128 # undef new 00129 #endif