Panda3D
pointLight.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 pointLight.I
10  * @author mike
11  * @date 1999-02-04
12  */
13 
14 /**
15  *
16  */
17 INLINE PointLight::CData::
18 CData() :
19  _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
20  _attenuation(1.0f, 0.0f, 0.0f),
21  _max_distance(make_inf((PN_stdfloat)0)),
22  _point(0.0f, 0.0f, 0.0f)
23 {
24 }
25 
26 /**
27  *
28  */
29 INLINE PointLight::CData::
30 CData(const PointLight::CData &copy) :
31  _specular_color(copy._specular_color),
32  _attenuation(copy._attenuation),
33  _max_distance(copy._max_distance),
34  _point(copy._point)
35 {
36 }
37 
38 /**
39  * Returns the color of specular highlights generated by the light. This is
40  * usually the same as get_color().
41  */
42 INLINE const LColor &PointLight::
43 get_specular_color() const {
44  if (_has_specular_color) {
45  CDReader cdata(_cycler);
46  return cdata->_specular_color;
47  } else {
48  return get_color();
49  }
50 }
51 
52 /**
53  * Sets the color of specular highlights generated by the light.
54  */
55 INLINE void PointLight::
56 set_specular_color(const LColor &color) {
57  CDWriter cdata(_cycler);
58  _has_specular_color = true;
59  cdata->_specular_color = color;
60 }
61 
62 /**
63  * Clears a custom specular color setting, meaning that the specular color
64  * will now come from the color.
65  */
66 INLINE void PointLight::
68  _has_specular_color = false;
69 }
70 
71 /**
72  * Returns the terms of the attenuation equation for the light. These are, in
73  * order, the constant, linear, and quadratic terms based on the distance from
74  * the point to the vertex.
75  */
76 INLINE const LVecBase3 &PointLight::
77 get_attenuation() const {
78  CDReader cdata(_cycler);
79  return cdata->_attenuation;
80 }
81 
82 /**
83  * Sets the terms of the attenuation equation for the light. These are, in
84  * order, the constant, linear, and quadratic terms based on the distance from
85  * the point to the vertex.
86  */
87 INLINE void PointLight::
88 set_attenuation(const LVecBase3 &attenuation) {
89  CDWriter cdata(_cycler);
90  cdata->_attenuation = attenuation;
91 }
92 
93 /**
94  * Returns the maximum distance at which the light has any effect, as previously
95  * specified by set_max_distance.
96  */
97 INLINE PN_stdfloat PointLight::
98 get_max_distance() const {
99  CDReader cdata(_cycler);
100  return cdata->_max_distance;
101 }
102 
103 /**
104  * Sets the radius of the light's sphere of influence. Beyond this distance, the
105  * light may be attenuated to zero, if this is supported by the shader.
106  */
107 INLINE void PointLight::
108 set_max_distance(PN_stdfloat max_distance) {
109  CDWriter cdata(_cycler);
110  cdata->_max_distance = max_distance;
111 }
112 
113 /**
114  * Returns the point in space at which the light is located. This is local to
115  * the coordinate space in which the light is assigned, and is usually 0.
116  */
117 INLINE const LPoint3 &PointLight::
118 get_point() const {
119  CDReader cdata(_cycler);
120  return cdata->_point;
121 }
122 
123 /**
124  * Sets the point in space at which the light is located. Usually 0.
125  */
126 INLINE void PointLight::
127 set_point(const LPoint3 &point) {
128  CDWriter cdata(_cycler);
129  cdata->_point = point;
130  mark_viz_stale();
131 }
set_specular_color
Sets the color of specular highlights generated by the light.
Definition: pointLight.h:45
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.
set_attenuation
Sets the terms of the attenuation equation for the light.
Definition: pointLight.h:49
set_point
Sets the point in space at which the light is located.
Definition: pointLight.h:57
set_max_distance
Sets the radius of the light's sphere of influence.
Definition: pointLight.h:53
const LVecBase3 & get_attenuation() const final
Returns the terms of the attenuation equation for the light.
get_color
Returns the basic color of the light.
Definition: light.h:49
void clear_specular_color()
Clears a custom specular color setting, meaning that the specular color will now come from the color.
Definition: pointLight.I:67