Panda3D
spotlight.I
1 // Filename: spotlight.I
2 // Created by: mike (04eb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: Spotlight::CData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE Spotlight::CData::
22 CData() :
23  _exponent(50.0f),
24  _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
25  _attenuation(1.0f, 0.0f, 0.0f)
26 {
27 }
28 
29 ////////////////////////////////////////////////////////////////////
30 // Function: Spotlight::CData::Copy Constructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 INLINE Spotlight::CData::
35 CData(const Spotlight::CData &copy) :
36  _exponent(copy._exponent),
37  _specular_color(copy._specular_color),
38  _attenuation(copy._attenuation)
39 {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: Spotlight::get_exponent
44 // Access: Public, Final
45 // Description: Returns the exponent that controls the amount of
46 // light falloff from the center of the spotlight. See
47 // set_exponent().
48 ////////////////////////////////////////////////////////////////////
49 INLINE PN_stdfloat Spotlight::
50 get_exponent() const {
51  CDReader cdata(_cycler);
52  return cdata->_exponent;
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: Spotlight::set_exponent
57 // Access: Public
58 // Description: Sets the exponent that controls the amount of light
59 // falloff from the center of the spotlight. The light
60 // is attenuated by the cosine of the angle between the
61 // direction of the light and the direction of the point
62 // being lighted, raised to the power of this exponent.
63 // Thus, higher exponents result in a more focused light
64 // source, regardless of the field-of-view of the lens.
65 ////////////////////////////////////////////////////////////////////
66 INLINE void Spotlight::
67 set_exponent(PN_stdfloat exponent) {
68  CDWriter cdata(_cycler);
69  cdata->_exponent = exponent;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: Spotlight::get_specular_color
74 // Access: Public, Final
75 // Description: Returns the color of specular highlights generated by
76 // the light.
77 ////////////////////////////////////////////////////////////////////
78 INLINE const LColor &Spotlight::
80  CDReader cdata(_cycler);
81  return cdata->_specular_color;
82 }
83 
84 ////////////////////////////////////////////////////////////////////
85 // Function: Spotlight::set_specular_color
86 // Access: Public
87 // Description: Sets the color of specular highlights generated by
88 // the light.
89 ////////////////////////////////////////////////////////////////////
90 INLINE void Spotlight::
92  CDWriter cdata(_cycler);
93  cdata->_specular_color = color;
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: Spotlight::get_attenuation
98 // Access: Public, Final
99 // Description: Returns the terms of the attenuation equation for the
100 // light. These are, in order, the constant, linear,
101 // and quadratic terms based on the distance from the
102 // point to the vertex.
103 ////////////////////////////////////////////////////////////////////
104 INLINE const LVecBase3 &Spotlight::
106  CDReader cdata(_cycler);
107  return cdata->_attenuation;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: Spotlight::set_attenuation
112 // Access: Public
113 // Description: Sets the terms of the attenuation equation for the
114 // light. These are, in order, the constant, linear,
115 // and quadratic terms based on the distance from the
116 // point to the vertex.
117 ////////////////////////////////////////////////////////////////////
118 INLINE void Spotlight::
119 set_attenuation(const LVecBase3 &attenuation) {
120  CDWriter cdata(_cycler);
121  cdata->_attenuation = attenuation;
122 }
void set_attenuation(const LVecBase3 &attenuation)
Sets the terms of the attenuation equation for the light.
Definition: spotlight.I:119
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
PN_stdfloat get_exponent() const FINAL
Returns the exponent that controls the amount of light falloff from the center of the spotlight...
Definition: spotlight.I:50
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
const LColor & get_specular_color() const FINAL
Returns the color of specular highlights generated by the light.
Definition: spotlight.I:79
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_specular_color(const LColor &color)
Sets the color of specular highlights generated by the light.
Definition: spotlight.I:91
const LVecBase3 & get_attenuation() const FINAL
Returns the terms of the attenuation equation for the light.
Definition: spotlight.I:105
void set_exponent(PN_stdfloat exponent)
Sets the exponent that controls the amount of light falloff from the center of the spotlight...
Definition: spotlight.I:67