Panda3D
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  */
17 INLINE Light::CData::
18 CData() :
19  _color(1.0f, 1.0f, 1.0f, 1.0f),
20  _viz_geom_stale(true)
21 {
22 }
23 
24 /**
25  *
26  */
27 INLINE Light::CData::
28 CData(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  */
38 INLINE Light::
39 Light() :
40  _priority(0),
41  _has_color_temperature(true),
42  _color_temperature(6500)
43 {
44 }
45 
46 /**
47  *
48  */
49 INLINE Light::
50 Light(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  */
61 INLINE const LColor &Light::
62 get_color() const {
63  CDReader cdata(_cycler);
64  return cdata->_color;
65 }
66 
67 /**
68  * Sets the basic color of the light.
69  */
70 INLINE void Light::
71 set_color(const LColor &color) {
72  CDWriter cdata(_cycler);
73  cdata->_color = color;
74  _has_color_temperature = false;
75  mark_viz_stale();
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 INLINE bool Light::
84  return _has_color_temperature;
85 }
86 
87 /**
88  * Returns the basic color temperature of the light, assuming
89  * has_color_temperature() returns true.
90  */
91 INLINE PN_stdfloat Light::
92 get_color_temperature() const {
93  nassertr(_has_color_temperature, _color_temperature);
94  return _color_temperature;
95 }
96 
97 /**
98  * Changes the relative importance of this light relative to the other lights
99  * that are applied simultaneously.
100  *
101  * The priority number is used to decide which of the requested lights are to
102  * be selected for rendering when more lights are requested than the hardware
103  * will support. The highest-priority n lights are selected for rendering.
104  *
105  * This is similar to TextureStage::set_priority().
106  */
107 INLINE void Light::
108 set_priority(int priority) {
109  _priority = priority;
110 
111  // Update the global flag to indicate that all LightAttribs in the world
112  // must now re-sort their lists.
113  _sort_seq++;
114 }
115 
116 /**
117  * Returns the priority associated with this light. See set_priority().
118  */
119 INLINE int Light::
120 get_priority() const {
121  return _priority;
122 }
123 
124 /**
125  * Returns a global sequence number that is incremented any time any Light in
126  * the world changes sort or priority. This is used by LightAttrib to
127  * determine when it is necessary to re-sort its internal array of stages.
128  */
129 INLINE UpdateSeq Light::
131  return _sort_seq;
132 }
133 
134 /**
135  * Indicates that the internal visualization object will need to be updated.
136  */
137 INLINE void Light::
138 mark_viz_stale() {
139  CDWriter cdata(_cycler);
140  cdata->_viz_geom_stale = true;
141 }
set_color
Sets the basic color of the light.
Definition: light.h:49
The abstract interface to all kinds of lights.
Definition: light.h:38
set_priority
Changes the relative importance of this light relative to the other lights that are applied simultane...
Definition: light.h:64
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:83
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:130
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37