Panda3D
Loading...
Searching...
No Matches
polylightNode.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 polylightNode.I
10 * @author sshodhan
11 * @date 2004-06-02
12 */
13
14/**
15 * Returns true if the two lights are equivalent that is, all their properties
16 * are same
17 */
18INLINE bool PolylightNode::
19operator == (const PolylightNode &other) const {
20 return (compare_to(other) == 0);
21}
22
23/**
24 * Returns true if the two lights are not equivalent.
25 */
26INLINE bool PolylightNode::
27operator != (const PolylightNode &other) const {
28 return (compare_to(other) != 0);
29}
30
31/**
32 * Returns true if this PolylightNode sorts before the other one, false
33 * otherwise. The sorting order of two nonequivalent PolylightNodes is
34 * consistent but undefined, and is useful only for storing PolylightNodes in
35 * a sorted container like an STL set.
36 */
37INLINE bool PolylightNode::
38operator < (const PolylightNode &other) const {
39 return (compare_to(other) < 0);
40}
41
42/**
43 * Is this light is enabled/disabled?
44 */
45INLINE bool PolylightNode::
46is_enabled() const {
47 return _enabled;
48}
49
50/**
51 * Enable this light
52 */
53INLINE void PolylightNode::
54enable(){
55 _enabled=true;
56}
57
58/**
59 * Disable this light
60 */
61INLINE void PolylightNode::
62disable(){
63 _enabled=false;
64}
65
66/**
67 * Set this light's position
68 */
69INLINE void PolylightNode::
70set_pos(const LPoint3 &position) {
71 _position = position;
72}
73
74/**
75 * Set this light's position
76 */
77INLINE void PolylightNode::
78set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z){
79 _position[0]=x;
80 _position[1]=y;
81 _position[2]=z;
82}
83
84/**
85 * Returns position as a LPoint3
86 */
87INLINE LPoint3 PolylightNode::
88get_pos() const {
89 return _position;
90}
91
92/**
93 * Set radius of the spherical light volume
94 */
95INLINE void PolylightNode::
96set_radius(PN_stdfloat r){
97 _radius=r;
98}
99
100/**
101 * Get radius of the spherical light volume
102 */
103INLINE PN_stdfloat PolylightNode::
104get_radius() const {
105 return _radius;
106}
107
108/**
109 * Set ALINEAR or AQUADRATIC attenuation
110 */
112set_attenuation(PolylightNode::Attenuation_Type type){
113 nassertr(type == ALINEAR || type == AQUADRATIC,false);
114 _attenuation_type=type;
115 return true;
116
117}
118
119/**
120 * Get "linear" or "quadratic" attenuation type
121 */
122INLINE PolylightNode::Attenuation_Type PolylightNode::
123get_attenuation() const {
124 return _attenuation_type;
125}
126
127/**
128 * Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance +
129 * a2*distance*distance)
130 */
132set_a0(PN_stdfloat a0){
133 _a0=a0;
134}
135
136/**
137 * Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance +
138 * a2*distance*distance)
139 */
141set_a1(PN_stdfloat a1){
142 _a1=a1;
143}
144
145/**
146 * Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance +
147 * a2*distance*distance)
148 */
150set_a2(PN_stdfloat a2){
151 _a2=a2;
152}
153
154/**
155 * Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance +
156 * a2*distance*distance)
157 */
158INLINE PN_stdfloat PolylightNode::
159get_a0() const {
160 return _a0;
161}
162
163/**
164 * Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance +
165 * a2*distance*distance)
166 */
167INLINE PN_stdfloat PolylightNode::
168get_a1() const {
169 return _a1;
170}
171
172/**
173 * Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance +
174 * a2*distance*distance)
175 */
176INLINE PN_stdfloat PolylightNode::
177get_a2() const {
178 return _a2;
179}
180
181/**
182 * Set flickering to true so at every loop this light's color is varied based
183 * on flicker_type
184 */
186flicker_on(){
187 _flickering=true;
188}
189
190/**
191 * Turn flickering off
192 */
195 _flickering=false;
196}
197
198/**
199 * Check is this light is flickering
200 */
202is_flickering() const {
203 return _flickering;
204}
205
206/**
207 * Flicker type can be FRANDOM or FSIN At a later point there might be a
208 * FCUSTOM Custom flicker will be a set of fix points recorded by animating
209 * the light's intensity
210 */
212set_flicker_type(PolylightNode::Flicker_Type type){
213 nassertr(type == FRANDOM || type == FSIN,false);
214
215 _flicker_type=type;
216 return true;
217}
218
219/**
220 * Returns FRANDOM or FSIN
221 */
222INLINE PolylightNode::Flicker_Type PolylightNode::
223get_flicker_type() const {
224 return _flicker_type;
225}
226
227/**
228 * Set the offset value for the random and sin flicker variations... used to
229 * tweak the flicker This value is added to the variation
230 */
232set_offset(PN_stdfloat offset){
233 _offset=offset;
234}
235
236/**
237 * Get the offset value for the random and sin flicker variations
238 */
239INLINE PN_stdfloat PolylightNode::
240get_offset() const {
241 return _offset;
242}
243
244/**
245 * Set the scale value for the random and sin flicker variations... used to
246 * tweak the flicker This value is multiplied with the variation
247 */
249set_scale(PN_stdfloat scale){
250 _scale=scale;
251}
252
253/**
254 * Get the scale value for the random and sin flicker variations
255 */
256INLINE PN_stdfloat PolylightNode::
257get_scale() const {
258 return _scale;
259}
260
261/**
262 * Set the step size for the sin function in flicker This is the increment
263 * size for the value supplied to the sin function
264 */
266set_step_size(PN_stdfloat step){
267 _step_size=step;
268}
269
270/**
271 * Get the step size for the sin function in flicker This is the increment
272 * size for the value supplied to the sin function
273 */
274INLINE PN_stdfloat PolylightNode::
275get_step_size() const {
276 return _step_size;
277}
278
279/**
280 * Set the light's color...
281 */
283set_color(const LColor &color) {
284 // PandaNode::set_attrib(ColorAttrib::make_flat(color));
285 _color = color;
286}
287
288/**
289 * Set the light's color... 3 floats between 0 and 1
290 */
292set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) {
293 /*
294 LColor color;
295 color[0] = r;
296 color[1] = g;
297 color[2] = b;
298 color[3] = 1.0;
299 PandaNode::set_attrib(ColorAttrib::make_flat(color));
300 */
301 _color[0] = r;
302 _color[1] = g;
303 _color[2] = b;
304 _color[3] = 1.0;
305}
306
307/**
308 * Returns the light's color as LColor
309 */
310INLINE LColor PolylightNode::
311get_color() const {
312 return _color;
313}
314
315/**
316 * This differs from get_color in that when applying the light color we need
317 * to make sure that a color flattening external to the PolylightNode is not
318 * ignored.
319 */
320INLINE LColor PolylightNode::
321get_color_scenegraph() const {
322
323 const RenderAttrib *attrib =
324 PandaNode::get_attrib(ColorAttrib::get_class_type());
325 if (attrib != nullptr) {
326 const ColorAttrib *ca = DCAST(ColorAttrib, attrib);
327 if (ca->get_color_type() == ColorAttrib::T_flat) {
328 return ca->get_color();
329 }
330 }
331
332 return _color;
333
334}
335
336
337/**
338 * Set frequency of sin flicker
339 */
341set_freq(PN_stdfloat f) {
342 _sin_freq=f;
343}
344
345/**
346 * Get frequency of sin flicker
347 */
348INLINE PN_stdfloat PolylightNode::
349get_freq() const {
350 return _sin_freq;
351}
Indicates what color should be applied to renderable geometry.
Definition colorAttrib.h:27
get_color
If the type is T_flat or T_off, this returns the color that will be applied to geometry.
Definition colorAttrib.h:47
get_color_type
Returns the type of color specified by this ColorAttrib.
Definition colorAttrib.h:46
A PolylightNode.
Attenuation_Type get_attenuation() const
Get "linear" or "quadratic" attenuation type.
LPoint3 get_pos() const
Returns position as a LPoint3.
PN_stdfloat get_offset() const
Get the offset value for the random and sin flicker variations.
bool is_enabled() const
Is this light is enabled/disabled?
PN_stdfloat get_a2() const
Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
void enable()
Enable this light.
void flicker_off()
Turn flickering off.
void set_pos(const LPoint3 &position)
Set this light's position.
PN_stdfloat get_scale() const
Get 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...
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...
void set_a2(PN_stdfloat a2)
Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
void flicker_on()
Set flickering to true so at every loop this light's color is varied based on flicker_type.
PN_stdfloat get_radius() const
Get radius of the spherical light volume.
void set_radius(PN_stdfloat r)
Set radius of the spherical light volume.
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 ...
bool operator==(const PolylightNode &other) const
Returns true if the two lights are equivalent that is, all their properties are same.
void set_offset(PN_stdfloat offset)
Set the offset value for the random and sin flicker variations... used to tweak the flicker This valu...
void set_a1(PN_stdfloat a1)
Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
bool operator!=(const PolylightNode &other) const
Returns true if the two lights are not equivalent.
void set_freq(PN_stdfloat f)
Set frequency of sin flicker.
void set_a0(PN_stdfloat a0)
Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Flicker_Type get_flicker_type() const
Returns FRANDOM or FSIN.
LColor get_color() const
Returns the light's color as LColor.
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_flickering() const
Check is this light is flickering.
PN_stdfloat get_a1() const
Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
PN_stdfloat get_a0() const
Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
bool set_attenuation(Attenuation_Type type)
Set ALINEAR or AQUADRATIC attenuation.
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...
PN_stdfloat get_freq() const
Get frequency of sin flicker.
void set_color(const LColor &color)
Set the light's color...
void disable()
Disable this light.
void set_scale(PN_stdfloat scale)
Set the scale value for the random and sin flicker variations... used to tweak the flicker This value...
bool operator<(const PolylightNode &other) const
Returns true if this PolylightNode sorts before the other one, false otherwise.
This is the base class for a number of render attributes (other than transform) that may be set on sc...