Panda3D
spotlight.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file spotlight.I
10  * @author mike
11  * @date 1999-02-04
12  */
13 
14 /**
15  *
16  */
17 INLINE Spotlight::CData::
18 CData() :
19  _exponent(50.0f),
20  _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
21  _attenuation(1.0f, 0.0f, 0.0f),
22  _max_distance(make_inf((PN_stdfloat)0))
23 {
24 }
25 
26 /**
27  *
28  */
29 INLINE Spotlight::CData::
30 CData(const Spotlight::CData &copy) :
31  _exponent(copy._exponent),
32  _specular_color(copy._specular_color),
33  _attenuation(copy._attenuation),
34  _max_distance(copy._max_distance)
35 {
36 }
37 
38 /**
39  * Returns the exponent that controls the amount of light falloff from the
40  * center of the spotlight. See set_exponent().
41  */
42 INLINE PN_stdfloat Spotlight::
43 get_exponent() const {
44  CDReader cdata(_cycler);
45  return cdata->_exponent;
46 }
47 
48 /**
49  * Sets the exponent that controls the amount of light falloff from the center
50  * of the spotlight. The light is attenuated by the cosine of the angle
51  * between the direction of the light and the direction of the point being
52  * lighted, raised to the power of this exponent. Thus, higher exponents
53  * result in a more focused light source, regardless of the field-of-view of
54  * the lens.
55  */
56 INLINE void Spotlight::
57 set_exponent(PN_stdfloat exponent) {
58  CDWriter cdata(_cycler);
59  cdata->_exponent = exponent;
60 }
61 
62 /**
63  * Returns the color of specular highlights generated by the light. This is
64  * usually the same as get_color().
65  */
66 INLINE const LColor &Spotlight::
67 get_specular_color() const {
68  if (_has_specular_color) {
69  CDReader cdata(_cycler);
70  return cdata->_specular_color;
71  } else {
72  return get_color();
73  }
74 }
75 
76 /**
77  * Sets the color of specular highlights generated by the light.
78  */
79 INLINE void Spotlight::
80 set_specular_color(const LColor &color) {
81  CDWriter cdata(_cycler);
82  _has_specular_color = true;
83  cdata->_specular_color = color;
84 }
85 
86 /**
87  * Clears a custom specular color setting, meaning that the specular color
88  * will now come from the color.
89  */
90 INLINE void Spotlight::
92  _has_specular_color = false;
93 }
94 
95 /**
96  * Returns the terms of the attenuation equation for the light. These are, in
97  * order, the constant, linear, and quadratic terms based on the distance from
98  * the point to the vertex.
99  */
100 INLINE const LVecBase3 &Spotlight::
101 get_attenuation() const {
102  CDReader cdata(_cycler);
103  return cdata->_attenuation;
104 }
105 
106 /**
107  * Sets the terms of the attenuation equation for the light. These are, in
108  * order, the constant, linear, and quadratic terms based on the distance from
109  * the point to the vertex.
110  */
111 INLINE void Spotlight::
112 set_attenuation(const LVecBase3 &attenuation) {
113  CDWriter cdata(_cycler);
114  cdata->_attenuation = attenuation;
115 }
116 
117 /**
118  * Returns the maximum distance at which the light has any effect, as previously
119  * specified by set_max_distance.
120  */
121 INLINE PN_stdfloat Spotlight::
122 get_max_distance() const {
123  CDReader cdata(_cycler);
124  return cdata->_max_distance;
125 }
126 
127 /**
128  * Sets the radius of the light's sphere of influence. Beyond this distance, the
129  * light may be attenuated to zero, if this is supported by the shader.
130  */
131 INLINE void Spotlight::
132 set_max_distance(PN_stdfloat max_distance) {
133  CDWriter cdata(_cycler);
134  cdata->_max_distance = max_distance;
135 }
PN_stdfloat get_exponent() const final
For spotlights, returns the exponent that controls the amount of light falloff from the center of the...
set_attenuation
Sets the terms of the attenuation equation for the light.
Definition: spotlight.h:60
set_exponent
Sets the exponent that controls the amount of light falloff from the center of the spotlight.
Definition: spotlight.h:51
set_specular_color
Sets the color of specular highlights generated by the light.
Definition: spotlight.h:56
void clear_specular_color()
Clears a custom specular color setting, meaning that the specular color will now come from the color.
Definition: spotlight.I:91
get_color
Returns the basic color of the light.
Definition: light.h:49
const LVecBase3 & get_attenuation() const final
Returns the terms of the attenuation equation for the light.
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
set_max_distance
Sets the radius of the light's sphere of influence.
Definition: spotlight.h:64