00001 // Filename: spotlight.I 00002 // Created by: mike (04eb99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: Spotlight::CData::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE Spotlight::CData:: 00022 CData() : 00023 _exponent(50.0f), 00024 _specular_color(1.0f, 1.0f, 1.0f, 1.0f), 00025 _attenuation(1.0f, 0.0f, 0.0f) 00026 { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: Spotlight::CData::Copy Constructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 INLINE Spotlight::CData:: 00035 CData(const Spotlight::CData ©) : 00036 _exponent(copy._exponent), 00037 _specular_color(copy._specular_color), 00038 _attenuation(copy._attenuation) 00039 { 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: Spotlight::get_exponent 00044 // Access: Public 00045 // Description: Returns the exponent that controls the amount of 00046 // light falloff from the center of the spotlight. See 00047 // set_exponent(). 00048 //////////////////////////////////////////////////////////////////// 00049 INLINE PN_stdfloat Spotlight:: 00050 get_exponent() const { 00051 CDReader cdata(_cycler); 00052 return cdata->_exponent; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: Spotlight::set_exponent 00057 // Access: Public 00058 // Description: Sets the exponent that controls the amount of light 00059 // falloff from the center of the spotlight. The light 00060 // is attenuated by the cosine of the angle between the 00061 // direction of the light and the direction of the point 00062 // being lighted, raised to the power of this exponent. 00063 // Thus, higher exponents result in a more focused light 00064 // source, regardless of the field-of-view of the lens. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE void Spotlight:: 00067 set_exponent(PN_stdfloat exponent) { 00068 CDWriter cdata(_cycler); 00069 cdata->_exponent = exponent; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: Spotlight::get_specular_color 00074 // Access: Public 00075 // Description: Returns the color of specular highlights generated by 00076 // the light. 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE const LColor &Spotlight:: 00079 get_specular_color() const { 00080 CDReader cdata(_cycler); 00081 return cdata->_specular_color; 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function: Spotlight::set_specular_color 00086 // Access: Public 00087 // Description: Sets the color of specular highlights generated by 00088 // the light. 00089 //////////////////////////////////////////////////////////////////// 00090 INLINE void Spotlight:: 00091 set_specular_color(const LColor &color) { 00092 CDWriter cdata(_cycler); 00093 cdata->_specular_color = color; 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: Spotlight::get_attenuation 00098 // Access: Public 00099 // Description: Returns the terms of the attenuation equation for the 00100 // light. These are, in order, the constant, linear, 00101 // and quadratic terms based on the distance from the 00102 // point to the vertex. 00103 //////////////////////////////////////////////////////////////////// 00104 INLINE const LVecBase3 &Spotlight:: 00105 get_attenuation() const { 00106 CDReader cdata(_cycler); 00107 return cdata->_attenuation; 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: Spotlight::set_attenuation 00112 // Access: Public 00113 // Description: Sets the terms of the attenuation equation for the 00114 // light. These are, in order, the constant, linear, 00115 // and quadratic terms based on the distance from the 00116 // point to the vertex. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE void Spotlight:: 00119 set_attenuation(const LVecBase3 &attenuation) { 00120 CDWriter cdata(_cycler); 00121 cdata->_attenuation = attenuation; 00122 }