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

SpotLight.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/LightSource.h"
00018 #include  "nvmath/Vec3f.h"
00019 
00020 namespace nvsg
00021 {
00022   /*  NOTE: A SpotLight does NOT contain a position or direction !
00023       As a special PointLight it is assumed to be positioned on the origin.
00024       Furthermore, it is assumed to be directed in the negative z-direction (just as a DirectedLight).
00025       Any changes to these must be performed by a Transform node.
00026   */
00027 
00029 
00040   class SpotLight : public LightSource
00041   {
00042     public:
00044 
00045       NVSG_API static const SpotLight * create( void );
00046 
00048 
00049       NVSG_API static const SpotLight * createFromBase( const LightSource &rhs  
00050                                                        );
00051 
00053 
00054       NVSG_API virtual const SpotLight * clone( void ) const;
00055 
00057 
00058       NVSG_API virtual bool isDataShared( void ) const;
00059 
00061 
00062       NVSG_API virtual DataID getDataID( void ) const;
00063 
00065 
00066       NVSG_API const nvmath::Vec3f& getAttenuation( void ) const;
00067 
00069 
00072       NVSG_API bool isAttenuated( void ) const;
00073 
00075 
00078       NVSG_API void  getAttenuation( float &c   
00079                                    , float &l   
00080                                    , float &q   
00081                                    ) const;
00082  
00084 
00087       NVSG_API void setAttenuation( float c   
00088                                   , float l   
00089                                   , float q   
00090                                   );
00091  
00093 
00095       NVSG_API float getCutoffAngle( void ) const;
00096 
00098 
00099       NVSG_API void setCutoffAngle( float ca    
00100                                  );
00101 
00103 
00106       NVSG_API float getFalloffExponent( void ) const;
00107 
00109 
00111       NVSG_API void setFalloffExponent( float fe    
00112                                       );
00113 
00114     protected:
00116       NVSG_API SpotLight( void );
00117 
00119       NVSG_API SpotLight( const LightSource &rhs );
00120 
00122       NVSG_API SpotLight( const SpotLight &rhs );
00123 
00125       NVSG_API virtual ~SpotLight( void );
00126 
00127     private:
00128       nvmath::Vec3f m_attenuation;
00129       float m_cutoffAngle;
00130       float m_falloffExponent;
00131   };
00132 
00133   inline  const nvmath::Vec3f&  SpotLight::getAttenuation()  const
00134   {
00135     __TRACE();
00136     return m_attenuation;
00137   }
00138 
00139   inline  void  SpotLight::getAttenuation( float &c, float &l, float &q )  const
00140   {
00141     __TRACE();
00142     c = m_attenuation[0];
00143     l = m_attenuation[1];
00144     q = m_attenuation[2];
00145   }
00146 
00147   inline  float SpotLight::getCutoffAngle( void )  const
00148   {
00149     __TRACE();
00150     return( m_cutoffAngle );
00151   }
00152 
00153   inline  float SpotLight::getFalloffExponent( void )  const
00154   {
00155     __TRACE();
00156     return( m_falloffExponent );
00157   }
00158 
00159   inline  bool  SpotLight::isAttenuated( void )  const
00160   {
00161     __TRACE();
00162     return(   ( m_attenuation[0] != 1.0f )
00163           ||  ( m_attenuation[1] != 0.0f )
00164           ||  ( m_attenuation[2] != 0.0f )
00165           );
00166   }
00167 
00168   inline  void  SpotLight::setAttenuation( float c, float l, float q )
00169   {
00170     __TRACE();
00171     m_attenuation[0] = c;
00172     m_attenuation[1] = l;
00173     m_attenuation[2] = q;
00174   }
00175 
00176   inline  void  SpotLight::setCutoffAngle( float ca )
00177   {
00178     __TRACE();
00179     m_cutoffAngle = ca;
00180   }
00181 
00182   inline  void  SpotLight::setFalloffExponent( float fe )
00183   {
00184     __TRACE();
00185     m_falloffExponent = fe;
00186   }
00187 } //  namespace nvsg

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