Panda3D
directionalLight.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 directionalLight.I
10  * @author mike
11  * @date 1999-02-04
12  */
13 
14 /**
15  *
16  */
17 INLINE DirectionalLight::CData::
18 CData() :
19  _specular_color(1.0f, 1.0f, 1.0f, 1.0f),
20  _point(0.0f, 0.0f, 0.0f),
21  _direction(LVector3::forward())
22 {
23 }
24 
25 /**
26  *
27  */
28 INLINE DirectionalLight::CData::
29 CData(const DirectionalLight::CData &copy) :
30  _specular_color(copy._specular_color),
31  _point(copy._point),
32  _direction(copy._direction)
33 {
34 }
35 
36 /**
37  * Returns the color of specular highlights generated by the light. This is
38  * usually the same as get_color().
39  */
40 INLINE const LColor &DirectionalLight::
41 get_specular_color() const {
42  if (_has_specular_color) {
43  CDReader cdata(_cycler);
44  return cdata->_specular_color;
45  } else {
46  return get_color();
47  }
48 }
49 
50 /**
51  * Sets the color of specular highlights generated by the light.
52  */
53 INLINE void DirectionalLight::
54 set_specular_color(const LColor &color) {
55  CDWriter cdata(_cycler);
56  _has_specular_color = true;
57  cdata->_specular_color = color;
58 }
59 
60 /**
61  * Clears a custom specular color setting, meaning that the specular color
62  * will now come from the color.
63  */
64 INLINE void DirectionalLight::
66  _has_specular_color = false;
67 }
68 
69 /**
70  * Returns the point in space at which the light is located. This is local to
71  * the coordinate space in which the light is assigned.
72  *
73  * This actually has no bearing on the visual effect of the light, since the
74  * light is rendered as if it were infinitely far away. This is only used to
75  * create a visible representation of the light.
76  */
77 INLINE const LPoint3 &DirectionalLight::
78 get_point() const {
79  CDReader cdata(_cycler);
80  return cdata->_point;
81 }
82 
83 /**
84  * Sets the point in space at which the light is located.
85  */
86 INLINE void DirectionalLight::
87 set_point(const LPoint3 &point) {
88  CDWriter cdata(_cycler);
89  cdata->_point = point;
90  mark_viz_stale();
91 }
92 
93 /**
94  * Returns the direction in which the light is aimed. This is local to the
95  * coordinate space in which the light is assigned.
96  */
97 INLINE const LVector3 &DirectionalLight::
98 get_direction() const {
99  CDReader cdata(_cycler);
100  return cdata->_direction;
101 }
102 
103 /**
104  * Sets the direction in which the light is aimed.
105  */
106 INLINE void DirectionalLight::
107 set_direction(const LVector3 &direction) {
108  CDWriter cdata(_cycler);
109  cdata->_direction = direction;
110  mark_viz_stale();
111 }
set_specular_color
Sets the color of specular highlights generated by the light.
void clear_specular_color()
Clears a custom specular color setting, meaning that the specular color will now come from the color.
set_point
Sets the point in space at which the light is located.
get_color
Returns the basic color of the light.
Definition: light.h:49
set_direction
Sets the direction in which the light is aimed.
const LColor & get_specular_color() const final
Returns the color of specular highlights generated by the light.