Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE Spotlight::CData::
18CData() :
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 */
29INLINE Spotlight::CData::
30CData(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 */
42INLINE PN_stdfloat Spotlight::
43get_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 */
56INLINE void Spotlight::
57set_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 */
66INLINE const LColor &Spotlight::
67get_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 */
79INLINE void Spotlight::
80set_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 */
90INLINE 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 */
100INLINE const LVecBase3 &Spotlight::
101get_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 */
111INLINE void Spotlight::
112set_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 */
121INLINE PN_stdfloat Spotlight::
122get_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 */
131INLINE void Spotlight::
132set_max_distance(PN_stdfloat max_distance) {
133 CDWriter cdata(_cycler);
134 cdata->_max_distance = max_distance;
135}
get_color
Returns the basic color of the light.
Definition light.h:49
get_specular_color
Returns the color of specular highlights generated by the light.
Definition spotlight.h:56
get_exponent
Returns the exponent that controls the amount of light falloff from the center of the spotlight.
Definition spotlight.h:51
get_attenuation
Returns 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_max_distance
Sets the radius of the light's sphere of influence.
Definition spotlight.h:64
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_max_distance
Returns the maximum distance at which the light has any effect, as previously specified by set_max_di...
Definition spotlight.h:64
set_specular_color
Sets the color of specular highlights generated by the light.
Definition spotlight.h:56
set_attenuation
Sets the terms of the attenuation equation for the light.
Definition spotlight.h:60