Panda3D
Loading...
Searching...
No Matches
light.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 light.I
10 * @author drose
11 * @date 2002-03-26
12 */
13
14/**
15 *
16 */
17INLINE Light::CData::
18CData() :
19 _color(1.0f, 1.0f, 1.0f, 1.0f),
20 _viz_geom_stale(true)
21{
22}
23
24/**
25 *
26 */
27INLINE Light::CData::
28CData(const Light::CData &copy) :
29 _color(copy._color),
30 _viz_geom(copy._viz_geom),
31 _viz_geom_stale(copy._viz_geom_stale)
32{
33}
34
35/**
36 *
37 */
38INLINE Light::
39Light() :
40 _priority(0),
41 _has_color_temperature(true),
42 _color_temperature(6500)
43{
44}
45
46/**
47 *
48 */
49INLINE Light::
50Light(const Light &copy) :
51 _priority(copy._priority),
52 _has_color_temperature(copy._has_color_temperature),
53 _color_temperature(copy._color_temperature),
54 _cycler(copy._cycler)
55{
56}
57
58/**
59 * Returns the basic color of the light.
60 */
61INLINE const LColor &Light::
62get_color() const {
63 CDReader cdata(_cycler);
64 return cdata->_color;
65}
66
67/**
68 * Sets the basic color of the light.
69 */
70INLINE void Light::
71set_color(const LColor &color) {
72 CDWriter cdata(_cycler);
73 cdata->_color = color;
74 cdata->_viz_geom_stale = true;
75 _has_color_temperature = false;
76}
77
78/**
79 * Returns true if the color was specified as a temperature in kelvins, and
80 * get_color_temperature is defined.
81 *
82 * @since 1.10.0
83 */
84INLINE bool Light::
86 return _has_color_temperature;
87}
88
89/**
90 * Returns the basic color temperature of the light, assuming
91 * has_color_temperature() returns true.
92 *
93 * @since 1.10.0
94 */
95INLINE PN_stdfloat Light::
97 nassertr(_has_color_temperature, _color_temperature);
98 return _color_temperature;
99}
100
101/**
102 * Changes the relative importance of this light relative to the other lights
103 * that are applied simultaneously.
104 *
105 * The priority number is used to decide which of the requested lights are to
106 * be selected for rendering when more lights are requested than the hardware
107 * will support. The highest-priority n lights are selected for rendering.
108 *
109 * This is similar to TextureStage::set_priority().
110 */
111INLINE void Light::
112set_priority(int priority) {
113 _priority = priority;
114
115 // Update the global flag to indicate that all LightAttribs in the world
116 // must now re-sort their lists.
117 _sort_seq++;
118}
119
120/**
121 * Returns the priority associated with this light. See set_priority().
122 */
123INLINE int Light::
124get_priority() const {
125 return _priority;
126}
127
128/**
129 * Returns a global sequence number that is incremented any time any Light in
130 * the world changes sort or priority. This is used by LightAttrib to
131 * determine when it is necessary to re-sort its internal array of stages.
132 */
134get_sort_seq() {
135 return _sort_seq;
136}
137
138/**
139 * Indicates that the internal visualization object will need to be updated.
140 */
141INLINE void Light::
142mark_viz_stale() {
143 CDWriter cdata(_cycler);
144 cdata->_viz_geom_stale = true;
145}
The abstract interface to all kinds of lights.
Definition light.h:38
get_color_temperature
Returns the basic color temperature of the light, assuming has_color_temperature() returns true.
Definition light.h:55
set_priority
Changes the relative importance of this light relative to the other lights that are applied simultane...
Definition light.h:64
get_color
Returns the basic color of the light.
Definition light.h:49
set_color
Sets the basic color of the light.
Definition light.h:49
bool has_color_temperature() const
Returns true if the color was specified as a temperature in kelvins, and get_color_temperature is def...
Definition light.I:85
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any Light in the world changes sort or ...
Definition light.I:134
get_priority
Returns the priority associated with this light.
Definition light.h:64
This is a sequence number that increments monotonically.
Definition updateSeq.h:37