Panda3D
light.I
1 // Filename: light.I
2 // Created by: drose (26Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: Light::CData::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE Light::CData::
22 CData() :
23  _color(1.0f, 1.0f, 1.0f, 1.0f),
24  _viz_geom_stale(true)
25 {
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: Light::CData::Copy Constructor
30 // Access: Public
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 INLINE Light::CData::
34 CData(const Light::CData &copy) :
35  _color(copy._color),
36  _viz_geom(copy._viz_geom),
37  _viz_geom_stale(copy._viz_geom_stale)
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: Light::Constructor
43 // Access: Public
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE Light::
47 Light() :
48  _priority(0)
49 {
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: Light::Copy Constructor
54 // Access: Public
55 // Description:
56 ////////////////////////////////////////////////////////////////////
57 INLINE Light::
58 Light(const Light &copy) :
59  _priority(copy._priority),
60  _cycler(copy._cycler)
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: Light::get_color
66 // Access: Published
67 // Description: Returns the basic color of the light.
68 ////////////////////////////////////////////////////////////////////
69 INLINE const LColor &Light::
70 get_color() const {
71  CDReader cdata(_cycler);
72  return cdata->_color;
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: Light::set_color
77 // Access: Published
78 // Description: Sets the basic color of the light.
79 ////////////////////////////////////////////////////////////////////
80 INLINE void Light::
82  CDWriter cdata(_cycler);
83  cdata->_color = color;
84  mark_viz_stale();
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: Light::set_priority
89 // Access: Published
90 // Description: Changes the relative importance of this light
91 // relative to the other lights that are applied
92 // simultaneously.
93 //
94 // The priority number is used to decide which of the
95 // requested lights are to be selected for rendering
96 // when more lights are requested than the hardware will
97 // support. The highest-priority n lights are selected
98 // for rendering.
99 //
100 // This is similar to TextureStage::set_priority().
101 ////////////////////////////////////////////////////////////////////
102 INLINE void Light::
103 set_priority(int priority) {
104  _priority = priority;
105 
106  // Update the global flag to indicate that all LightAttribs in the
107  // world must now re-sort their lists.
108  _sort_seq++;
109 }
110 
111 ////////////////////////////////////////////////////////////////////
112 // Function: Light::get_priority
113 // Access: Published
114 // Description: Returns the priority associated with this light. See
115 // set_priority().
116 ////////////////////////////////////////////////////////////////////
117 INLINE int Light::
118 get_priority() const {
119  return _priority;
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: Light::get_sort_seq
124 // Access: Public, Static
125 // Description: Returns a global sequence number that is incremented
126 // any time any Light in the world changes sort
127 // or priority. This is used by LightAttrib to
128 // determine when it is necessary to re-sort its
129 // internal array of stages.
130 ////////////////////////////////////////////////////////////////////
131 INLINE UpdateSeq Light::
133  return _sort_seq;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: Light::mark_viz_stale
138 // Access: Protected
139 // Description: Indicates that the internal visualization object will
140 // need to be updated.
141 ////////////////////////////////////////////////////////////////////
142 INLINE void Light::
143 mark_viz_stale() {
144  CDWriter cdata(_cycler);
145  cdata->_viz_geom_stale = true;
146 }
The abstract interface to all kinds of lights.
Definition: light.h:42
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void set_priority(int priority)
Changes the relative importance of this light relative to the other lights that are applied simultane...
Definition: light.I:103
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
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:132
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
int get_priority() const
Returns the priority associated with this light.
Definition: light.I:118
const LColor & get_color() const
Returns the basic color of the light.
Definition: light.I:70
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
void set_color(const LColor &color)
Sets the basic color of the light.
Definition: light.I:81