Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE PointLight::CData::
18CData() :
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 */
29INLINE PointLight::CData::
30CData(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 */
42INLINE const LColor &PointLight::
43get_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 */
55INLINE void PointLight::
56set_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 */
66INLINE 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 */
76INLINE const LVecBase3 &PointLight::
77get_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 */
87INLINE void PointLight::
88set_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 */
97INLINE PN_stdfloat PointLight::
98get_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 */
107INLINE void PointLight::
108set_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 */
117INLINE const LPoint3 &PointLight::
118get_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 */
126INLINE void PointLight::
127set_point(const LPoint3 &point) {
128 CDWriter cdata(_cycler);
129 cdata->_point = point;
130 mark_viz_stale();
131}
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
get_specular_color
Returns the color of specular highlights generated by the light.
Definition pointLight.h:45
set_specular_color
Sets the color of specular highlights generated by the light.
Definition pointLight.h:45
set_max_distance
Sets the radius of the light's sphere of influence.
Definition pointLight.h:53
get_point
Returns the point in space at which the light is located.
Definition pointLight.h:57
get_max_distance
Returns the maximum distance at which the light has any effect, as previously specified by set_max_di...
Definition pointLight.h:53
get_attenuation
Returns the terms of the attenuation equation for the light.
Definition pointLight.h:49
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