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

LightSource.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/Animation.h"
00018 #include "nvsg/Node.h"
00019 #include "nvmath/Quatf.h"
00020 #include "nvmath/Trafo.h"
00021 
00022 namespace nvsg
00023 {
00025 
00050   class LightSource : public Node
00051   {
00052     public:
00054 
00058       NVSG_API const nvmath::Vec3f& getAmbientColor( void ) const;
00059 
00061 
00064       NVSG_API void setAmbientColor( const nvmath::Vec3f &c   
00065                                    );
00066 
00068 
00072       NVSG_API const nvmath::Vec3f& getDiffuseColor( void ) const;
00073 
00075 
00078       NVSG_API void setDiffuseColor( const nvmath::Vec3f &c   
00079                                    );
00080 
00082 
00086       NVSG_API const nvmath::Vec3f& getSpecularColor( void ) const;
00087 
00089 
00092       NVSG_API void setSpecularColor( const nvmath::Vec3f &c    
00093                                     );
00094 
00096 
00098       NVSG_API float getIntensity( void ) const;
00099 
00101 
00102       NVSG_API void setIntensity( float i   
00103                                 );
00104 
00106 
00107       NVSG_API const Animation<nvmath::Trafo> * getAnimation( void ) const;
00108 
00110       NVSG_API void setAnimation( const Animation<nvmath::Trafo> * pAnimation   
00111                                 );
00112 
00114 
00115       NVSG_API void setAnimationFrame( size_t frame   
00116                                      );
00117 
00119 
00120       NVSG_API virtual size_t getNumberOfFrames( void ) const;
00121 
00123       NVSG_API void setPosition( const nvmath::Vec3f & position    
00124                                );
00125 
00127 
00128       NVSG_API const nvmath::Vec3f & getPosition( void ) const;
00129 
00131 
00133       NVSG_API nvmath::Vec3f getDirection( void ) const;
00134 
00136 
00138       NVSG_API void setDirection( const nvmath::Vec3f & direction    
00139                                 );
00140 
00142 
00143       NVSG_API const nvmath::Quatf & getOrientation( void ) const;
00144 
00146       NVSG_API void setOrientation( const nvmath::Quatf & orientation  
00147                                   );
00148 
00150 
00151       NVSG_API nvmath::Mat44f getTransformationMatrix( void ) const;
00152 
00154 
00155       NVSG_API nvmath::Mat44f getInverse( void ) const;
00156 
00158 
00159       NVSG_API virtual bool isDataShared( void )  const;
00160 
00162 
00163       NVSG_API virtual DataID getDataID( void )     const;
00164       
00166 
00167       NVSG_API virtual bool containsLight( void ) const;
00168 
00169     protected:
00171       NVSG_API LightSource( void );
00172 
00174       NVSG_API LightSource( const LightSource& rhs );
00175 
00177       NVSG_API virtual ~LightSource(void);
00178 
00180 
00182       NVSG_API virtual bool calcBoundingSphere( void ) const;
00183 
00184     private:
00185       nvmath::Trafo m_trafo;
00186   
00187       float m_intensity;
00188       nvmath::Vec3f m_ambientColor;
00189       nvmath::Vec3f m_diffuseColor;
00190       nvmath::Vec3f m_specularColor;
00191 
00192       const Animation<nvmath::Trafo>  * m_animation; // animation working on a Trafo
00193       size_t              m_currentFrame;
00194   };
00195 
00196   inline bool LightSource::calcBoundingSphere( void ) const
00197   {
00198     __TRACE();
00199     return( false );
00200   }
00201 
00202   inline const nvmath::Vec3f& LightSource::getAmbientColor( void ) const
00203   {
00204     __TRACE();
00205     return( m_ambientColor );
00206   }
00207 
00208   inline const nvmath::Vec3f& LightSource::getDiffuseColor( void ) const
00209   {
00210     __TRACE();
00211     return( m_diffuseColor );
00212   }
00213 
00214   inline const nvmath::Vec3f& LightSource::getSpecularColor( void ) const
00215   {
00216     __TRACE();
00217     return( m_specularColor );
00218   }
00219 
00220   inline float LightSource::getIntensity( void ) const
00221   {
00222     __TRACE();
00223     return( m_intensity );
00224   }
00225 
00226   inline void LightSource::setAmbientColor( const nvmath::Vec3f &c )
00227   {
00228     __TRACE();
00229     m_ambientColor = c;
00230   }
00231 
00232   inline void LightSource::setDiffuseColor( const nvmath::Vec3f &c )
00233   {
00234     __TRACE();
00235     m_diffuseColor = c;
00236   }
00237 
00238   inline void LightSource::setSpecularColor( const nvmath::Vec3f &c )
00239   {
00240     __TRACE();
00241     m_specularColor = c;
00242   }
00243 
00244   inline void LightSource::setIntensity( float i )
00245   {
00246     __TRACE();
00247     m_intensity = i;
00248   }
00249 
00250   inline  const nvmath::Vec3f & LightSource::getPosition( void ) const
00251   {
00252     __TRACE();
00253     return m_trafo.getTranslation();
00254   }
00255 
00256   inline  void  LightSource::setPosition( const nvmath::Vec3f & position )
00257   {
00258     __TRACE();
00259     m_trafo.setTranslation(position);
00260     invalidateBoundingSphere();
00261   }
00262 
00263   inline nvmath::Vec3f LightSource::getDirection( void ) const
00264   {
00265     __TRACE();
00266     return m_trafo.getOrientation() * nvmath::Vec3f (0.f, 0.f, -1.f);
00267   }
00268   
00269   inline const nvmath::Quatf & LightSource::getOrientation( void ) const
00270   {
00271     __TRACE();
00272     return m_trafo.getOrientation();
00273   }
00274 
00275   inline void LightSource::setOrientation( const nvmath::Quatf & orientation )
00276   {
00277     __TRACE();
00278     m_trafo.setOrientation(orientation);
00279     invalidateBoundingSphere();
00280   }
00281 
00282   inline  nvmath::Mat44f LightSource::getTransformationMatrix( void ) const
00283   {
00284     __TRACE();
00285     return m_trafo.getMatrix();
00286   }
00287 
00288   inline nvmath::Mat44f LightSource::getInverse( void ) const
00289   {
00290     __TRACE();
00291     return m_trafo.getInverse();
00292   }
00293 
00294   inline const Animation<nvmath::Trafo> * LightSource::getAnimation( void ) const
00295   {
00296     __TRACE();
00297     return( m_animation );
00298   }
00299 
00300   inline size_t LightSource::getNumberOfFrames( void ) const
00301   {
00302     __TRACE();
00303     return( m_animation ? m_animation->getNumberOfFrames() : 0 );
00304   }
00305 } //  namespace nvsg
00306 

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