00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00023
00024
00025
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 }