Panda3D
 All Classes Functions Variables Enumerations
polylightNode.I
1 // Filename: PolylightNodeEffect.I
2 // Created by: sshodhan (02Jun04)
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 ////////////////////////////////////////////////////////////////////
18 // Function: PolylightNode::operator ==
19 // Access: Published
20 // Description: Returns true if the two lights are equivalent
21 // that is, all their properties are same
22 ////////////////////////////////////////////////////////////////////
23 INLINE bool PolylightNode::
24 operator == (const PolylightNode &other) const {
25  return (compare_to(other) == 0);
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: PolylightNode::operator !=
30 // Access: Published
31 // Description: Returns true if the two lights are not equivalent.
32 ////////////////////////////////////////////////////////////////////
33 INLINE bool PolylightNode::
34 operator != (const PolylightNode &other) const {
35  return (compare_to(other) != 0);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PolylightNode::operator <
40 // Access: Published
41 // Description: Returns true if this PolylightNode sorts before the other
42 // one, false otherwise. The sorting order of two
43 // nonequivalent PolylightNodes is consistent but undefined,
44 // and is useful only for storing PolylightNodes in a sorted
45 // container like an STL set.
46 ////////////////////////////////////////////////////////////////////
47 INLINE bool PolylightNode::
48 operator < (const PolylightNode &other) const {
49  return (compare_to(other) < 0);
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: PolylightNode::is_enabled
54 // Access: Published
55 // Description: Is this light is enabled/disabled?
56 ////////////////////////////////////////////////////////////////////
57 INLINE bool PolylightNode::
58 is_enabled() const {
59  return _enabled;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: PolylightNode::enable
64 // Access: Published
65 // Description: Enable this light
66 ////////////////////////////////////////////////////////////////////
67 INLINE void PolylightNode::
69  _enabled=true;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: PolylightNode::disable
74 // Access: Published
75 // Description: Disable this light
76 ////////////////////////////////////////////////////////////////////
77 INLINE void PolylightNode::
79  _enabled=false;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: PolylightNode::set_pos
84 // Access: Published
85 // Description: Set this light's position
86 ////////////////////////////////////////////////////////////////////
87 INLINE void PolylightNode::
88 set_pos(const LPoint3 &position) {
89  _position = position;
90 }
91 
92 ////////////////////////////////////////////////////////////////////
93 // Function: PolylightNode::set_pos
94 // Access: Published
95 // Description: Set this light's position
96 ////////////////////////////////////////////////////////////////////
97 INLINE void PolylightNode::
98 set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z){
99  _position[0]=x;
100  _position[1]=y;
101  _position[2]=z;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: PolylightNode::get_pos
106 // Access: Published
107 // Description: Returns position as a LPoint3
108 ////////////////////////////////////////////////////////////////////
110 get_pos() const {
111  return _position;
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: PolylightNode::set_radius
116 // Access: Published
117 // Description: Set radius of the spherical light volume
118 ////////////////////////////////////////////////////////////////////
119 INLINE void PolylightNode::
120 set_radius(PN_stdfloat r){
121  _radius=r;
122 }
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: PolylightNode::get_radius
126 // Access: Published
127 // Description: Get radius of the spherical light volume
128 ////////////////////////////////////////////////////////////////////
129 INLINE PN_stdfloat PolylightNode::
130 get_radius() const {
131  return _radius;
132 }
133 
134 ////////////////////////////////////////////////////////////////////
135 // Function: PolylightNode::set_attenuation
136 // Access: Published
137 // Description: Set ALINEAR or AQUADRATIC attenuation
138 ////////////////////////////////////////////////////////////////////
139 INLINE bool PolylightNode::
140 set_attenuation(PolylightNode::Attenuation_Type type){
141  nassertr(type == ALINEAR || type == AQUADRATIC,false);
142  _attenuation_type=type;
143  return true;
144 
145 }
146 
147 ////////////////////////////////////////////////////////////////////
148 // Function: PolylightNode::get_attenuation
149 // Access: Published
150 // Description: Get "linear" or "quadratic" attenuation type
151 ////////////////////////////////////////////////////////////////////
152 INLINE PolylightNode::Attenuation_Type PolylightNode::
154  return _attenuation_type;
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: PolylightNode::set_a0
159 // Access: Published
160 // Description: Set the quadratic attenuation factor a0
161 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
162 ////////////////////////////////////////////////////////////////////
163 INLINE void PolylightNode::
164 set_a0(PN_stdfloat a0){
165  _a0=a0;
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: PolylightNode::set_a1
170 // Access: Published
171 // Description: Set the quadratic attenuation factor a1
172 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
173 ////////////////////////////////////////////////////////////////////
174 INLINE void PolylightNode::
175 set_a1(PN_stdfloat a1){
176  _a1=a1;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: PolylightNode::set_a2
181 // Access: Published
182 // Description: Set the quadratic attenuation factor a2
183 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
184 ////////////////////////////////////////////////////////////////////
185 INLINE void PolylightNode::
186 set_a2(PN_stdfloat a2){
187  _a2=a2;
188 }
189 
190 ////////////////////////////////////////////////////////////////////
191 // Function: PolylightNode::get_a0
192 // Access: Published
193 // Description: Get the quadratic attenuation factor a0
194 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
195 ////////////////////////////////////////////////////////////////////
196 INLINE PN_stdfloat PolylightNode::
197 get_a0() const {
198  return _a0;
199 }
200 
201 ////////////////////////////////////////////////////////////////////
202 // Function: PolylightNode::get_a1
203 // Access: Published
204 // Description: Get the quadratic attenuation factor a1
205 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
206 ////////////////////////////////////////////////////////////////////
207 INLINE PN_stdfloat PolylightNode::
208 get_a1() const {
209  return _a1;
210 }
211 
212 ////////////////////////////////////////////////////////////////////
213 // Function: PolylightNode::get_a2
214 // Access: Published
215 // Description: Get the quadratic attenuation factor a2
216 // fd = 1 / ( a0 + a1*distance + a2*distance*distance)
217 ////////////////////////////////////////////////////////////////////
218 INLINE PN_stdfloat PolylightNode::
219 get_a2() const {
220  return _a2;
221 }
222 
223 ////////////////////////////////////////////////////////////////////
224 // Function: PolylightNode::flicker_on
225 // Access: Published
226 // Description: Set flickering to true so at every loop this light's
227 // color is varied based on flicker_type
228 ////////////////////////////////////////////////////////////////////
229 INLINE void PolylightNode::
231  _flickering=true;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: PolylightNode::flicker_off
236 // Access: Published
237 // Description: Turn flickering off
238 ////////////////////////////////////////////////////////////////////
239 INLINE void PolylightNode::
241  _flickering=false;
242 }
243 
244 ////////////////////////////////////////////////////////////////////
245 // Function: PolylightNode::is_flickering
246 // Access: Published
247 // Description: Check is this light is flickering
248 ////////////////////////////////////////////////////////////////////
249 INLINE bool PolylightNode::
250 is_flickering() const {
251  return _flickering;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: PolylightNode::set_flicker_type
256 // Access: Published
257 // Description: Flicker type can be FRANDOM or FSIN
258 // At a later point there might be a FCUSTOM
259 // Custom flicker will be a set of fix points recorded
260 // by animating the light's intensity
261 ////////////////////////////////////////////////////////////////////
262 INLINE bool PolylightNode::
263 set_flicker_type(PolylightNode::Flicker_Type type){
264  nassertr(type == FRANDOM || type == FSIN,false);
265 
266  _flicker_type=type;
267  return true;
268 }
269 
270 ////////////////////////////////////////////////////////////////////
271 // Function: PolylightNode::get_flicker_type
272 // Access: Published
273 // Description: Returns FRANDOM or FSIN
274 ////////////////////////////////////////////////////////////////////
275 INLINE PolylightNode::Flicker_Type PolylightNode::
277  return _flicker_type;
278 }
279 
280 ////////////////////////////////////////////////////////////////////
281 // Function: PolylightNode::set_offset
282 // Access: Published
283 // Description: Set the offset value for the random and sin
284 // flicker variations... used to tweak the flicker
285 // This value is added to the variation
286 ////////////////////////////////////////////////////////////////////
287 INLINE void PolylightNode::
288 set_offset(PN_stdfloat offset){
289  _offset=offset;
290 }
291 
292 ////////////////////////////////////////////////////////////////////
293 // Function: PolylightNode::get_offset
294 // Access: Published
295 // Description: Get the offset value for the random and sin
296 // flicker variations
297 ////////////////////////////////////////////////////////////////////
298 INLINE PN_stdfloat PolylightNode::
299 get_offset() const {
300  return _offset;
301 }
302 
303 ////////////////////////////////////////////////////////////////////
304 // Function: PolylightNode::set_scale
305 // Access: Published
306 // Description: Set the scale value for the random and sin
307 // flicker variations... used to tweak the flicker
308 // This value is multiplied with the variation
309 ////////////////////////////////////////////////////////////////////
310 INLINE void PolylightNode::
311 set_scale(PN_stdfloat scale){
312  _scale=scale;
313 }
314 
315 ////////////////////////////////////////////////////////////////////
316 // Function: PolylightNode::get_scale
317 // Access: Published
318 // Description: Get the scale value for the random and sin
319 // flicker variations
320 ////////////////////////////////////////////////////////////////////
321 INLINE PN_stdfloat PolylightNode::
322 get_scale() const {
323  return _scale;
324 }
325 
326 ////////////////////////////////////////////////////////////////////
327 // Function: PolylightNode::set_step_size
328 // Access: Published
329 // Description: Set the step size for the sin function in flicker
330 // This is the increment size for the value supplied
331 // to the sin function
332 ////////////////////////////////////////////////////////////////////
333 INLINE void PolylightNode::
334 set_step_size(PN_stdfloat step){
335  _step_size=step;
336 }
337 
338 ////////////////////////////////////////////////////////////////////
339 // Function: PolylightNode::get_step_size
340 // Access: Published
341 // Description: Get the step size for the sin function in flicker
342 // This is the increment size for the value supplied
343 // to the sin function
344 ////////////////////////////////////////////////////////////////////
345 INLINE PN_stdfloat PolylightNode::
346 get_step_size() const {
347  return _step_size;
348 }
349 
350 ////////////////////////////////////////////////////////////////////
351 // Function: PolylightNode::set_color
352 // Access: Published
353 // Description: Set the light's color...
354 ////////////////////////////////////////////////////////////////////
355 INLINE void PolylightNode::
357  //PandaNode::set_attrib(ColorAttrib::make_flat(color));
358  _color = color;
359 }
360 
361 ////////////////////////////////////////////////////////////////////
362 // Function: PolylightNode::set_color
363 // Access: Published
364 // Description: Set the light's color... 3 floats between 0 and 1
365 ////////////////////////////////////////////////////////////////////
366 INLINE void PolylightNode::
367 set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) {
368  /*
369  LColor color;
370  color[0] = r;
371  color[1] = g;
372  color[2] = b;
373  color[3] = 1.0;
374  PandaNode::set_attrib(ColorAttrib::make_flat(color));
375  */
376  _color[0] = r;
377  _color[1] = g;
378  _color[2] = b;
379  _color[3] = 1.0;
380 }
381 
382 ////////////////////////////////////////////////////////////////////
383 // Function: PolylightNode::get_color
384 // Access: Published
385 // Description: Returns the light's color as LColor
386 ////////////////////////////////////////////////////////////////////
387 INLINE LColor PolylightNode::
388 get_color() const {
389  return _color;
390 }
391 
392 ////////////////////////////////////////////////////////////////////
393 // Function: PolylightNode::get_color_scenegraph
394 // Access: Published
395 // Description: This differs from get_color in that when applying
396 // the light color we need to make sure that a color
397 // flattening external to the PolylightNode is not
398 // ignored.
399 ////////////////////////////////////////////////////////////////////
400 INLINE LColor PolylightNode::
402 
403  const RenderAttrib *attrib =
404  PandaNode::get_attrib(ColorAttrib::get_class_type());
405  if (attrib != (const RenderAttrib *)NULL) {
406  const ColorAttrib *ca = DCAST(ColorAttrib, attrib);
407  if (ca->get_color_type() == ColorAttrib::T_flat) {
408  return ca->get_color();
409  }
410  }
411 
412  return _color;
413 
414 }
415 
416 
417 ////////////////////////////////////////////////////////////////////
418 // Function: PolylightNode::set_freq
419 // Access: Published
420 // Description: Set frequency of sin flicker
421 ////////////////////////////////////////////////////////////////////
422 INLINE void PolylightNode::
423 set_freq(PN_stdfloat f) {
424  _sin_freq=f;
425 }
426 
427 ////////////////////////////////////////////////////////////////////
428 // Function: PolylightNode::get_freq
429 // Access: Published
430 // Description: Get frequency of sin flicker
431 ////////////////////////////////////////////////////////////////////
432 INLINE PN_stdfloat PolylightNode::
433 get_freq() const {
434  return _sin_freq;
435 }
void set_a2(PN_stdfloat a2)
Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
bool is_flickering() const
Check is this light is flickering.
bool operator!=(const PolylightNode &other) const
Returns true if the two lights are not equivalent.
Definition: polylightNode.I:34
PN_stdfloat get_a1() const
Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
void set_a0(PN_stdfloat a0)
Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
bool set_flicker_type(Flicker_Type type)
Flicker type can be FRANDOM or FSIN At a later point there might be a FCUSTOM Custom flicker will be ...
void set_freq(PN_stdfloat f)
Set frequency of sin flicker.
PN_stdfloat get_radius() const
Get radius of the spherical light volume.
Flicker_Type get_flicker_type() const
Returns FRANDOM or FSIN.
void disable()
Disable this light.
Definition: polylightNode.I:78
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
Type get_color_type() const
Returns the type of color specified by this ColorAttrib.
Definition: colorAttrib.I:46
PN_stdfloat get_scale() const
Get the scale value for the random and sin flicker variations.
Attenuation_Type get_attenuation() const
Get &quot;linear&quot; or &quot;quadratic&quot; attenuation type.
void set_radius(PN_stdfloat r)
Set radius of the spherical light volume.
PN_stdfloat get_offset() const
Get the offset value for the random and sin flicker variations.
void set_pos(const LPoint3 &position)
Set this light&#39;s position.
Definition: polylightNode.I:88
bool operator<(const PolylightNode &other) const
Returns true if this PolylightNode sorts before the other one, false otherwise.
Definition: polylightNode.I:48
bool operator==(const PolylightNode &other) const
Returns true if the two lights are equivalent that is, all their properties are same.
Definition: polylightNode.I:24
LColor get_color() const
Returns the light&#39;s color as LColor.
void set_step_size(PN_stdfloat step)
Set the step size for the sin function in flicker This is the increment size for the value supplied t...
const LColor & get_color() const
If the type is T_flat or T_off, this returns the color that will be applied to geometry.
Definition: colorAttrib.I:58
void flicker_on()
Set flickering to true so at every loop this light&#39;s color is varied based on flicker_type.
PN_stdfloat get_a0() const
Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
void flicker_off()
Turn flickering off.
bool set_attenuation(Attenuation_Type type)
Set ALINEAR or AQUADRATIC attenuation.
A PolylightNode.
Definition: polylightNode.h:31
void set_a1(PN_stdfloat a1)
Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
PN_stdfloat get_a2() const
Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance) ...
PN_stdfloat get_step_size() const
Get the step size for the sin function in flicker This is the increment size for the value supplied t...
bool is_enabled() const
Is this light is enabled/disabled?
Definition: polylightNode.I:58
PN_stdfloat get_freq() const
Get frequency of sin flicker.
void set_offset(PN_stdfloat offset)
Set the offset value for the random and sin flicker variations...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_scale(PN_stdfloat scale)
Set the scale value for the random and sin flicker variations...
LColor get_color_scenegraph() const
This differs from get_color in that when applying the light color we need to make sure that a color f...
LPoint3 get_pos() const
Returns position as a LPoint3.
Indicates what color should be applied to renderable geometry.
Definition: colorAttrib.h:30
void set_color(const LColor &color)
Set the light&#39;s color...
void enable()
Enable this light.
Definition: polylightNode.I:68
int compare_to(const PolylightNode &other) const
Returns a number less than zero if this PolylightNode sorts before the other one, greater than zero i...