Panda3D

Loading...
Searching...
No Matches
polylightNode.h
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.h
10 * @author sshodhan
11 * @date 2004-06-02
12 */
13
14#ifndef POLYLIGHTNODE_H
15#define POLYLIGHTNODE_H
16
17#include "pandabase.h"
18
19#include "luse.h"
20#include "nodePath.h"
21#include "pmap.h"
22#include "pnotify.h"
23#include "pandaNode.h"
24#include "colorAttrib.h"
25
26/**
27 * A PolylightNode
28 */
29 class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{
30// private:
31
32
33PUBLISHED:
34 /*
35 // This was the old constructor... interrogate would generate a separate
36 // wrapper for each parameter... so its better to have a simpler constructor
37 // and require the programmer to use set_* methods.
38 PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0,
39 PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0,
40 PN_stdfloat radius=50.0, string attenuation_type= "linear",
41 bool flickering =false, string flicker_type="random");
42 */
43
44 enum Flicker_Type {
45 FRANDOM,
46 FSIN,
47 FCUSTOM,
48 };
49
50 enum Attenuation_Type {
51 ALINEAR,
52 AQUADRATIC,
53 };
54
55 explicit PolylightNode(const std::string &name);
56 INLINE void enable();
57 INLINE void disable();
58 INLINE void set_pos(const LPoint3 &position);
59 INLINE void set_pos(PN_stdfloat x,PN_stdfloat y, PN_stdfloat z);
60 INLINE LPoint3 get_pos() const;
61 INLINE void set_color(const LColor &color);
62 INLINE void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b);
63 INLINE LColor get_color() const;
64 INLINE LColor get_color_scenegraph() const;
65 INLINE void set_radius(PN_stdfloat r);
66 INLINE PN_stdfloat get_radius() const;
67 INLINE bool set_attenuation(Attenuation_Type type);
68 INLINE Attenuation_Type get_attenuation() const;
69 INLINE void set_a0(PN_stdfloat a0);
70 INLINE void set_a1(PN_stdfloat a1);
71 INLINE void set_a2(PN_stdfloat a2);
72 INLINE PN_stdfloat get_a0() const;
73 INLINE PN_stdfloat get_a1() const;
74 INLINE PN_stdfloat get_a2() const;
75 INLINE void flicker_on();
76 INLINE void flicker_off();
77 INLINE bool is_flickering() const;
78 INLINE bool set_flicker_type(Flicker_Type type);
79 INLINE Flicker_Type get_flicker_type() const;
80 INLINE void set_offset(PN_stdfloat offset);
81 INLINE PN_stdfloat get_offset() const;
82 INLINE void set_scale(PN_stdfloat scale);
83 INLINE PN_stdfloat get_scale() const;
84 INLINE void set_step_size(PN_stdfloat step) ;
85 INLINE PN_stdfloat get_step_size() const;
86 INLINE void set_freq(PN_stdfloat f);
87 INLINE PN_stdfloat get_freq() const;
88
89 // Comparison methods
90 INLINE bool operator == (const PolylightNode &other) const;
91 INLINE bool operator != (const PolylightNode &other) const;
92 INLINE bool operator < (const PolylightNode &other) const;
93 int compare_to(const PolylightNode &other) const;
94
95 INLINE bool is_enabled() const;
96
97 public:
98 LColor flicker() const;
99 virtual PandaNode *make_copy() const;
100 virtual void xform(const LMatrix4 &mat);
101
102 private:
103 bool _enabled;
104 LPoint3 _position;
105 LColor _color;
106 PN_stdfloat _radius;
107 Attenuation_Type _attenuation_type;
108 PN_stdfloat _a0;
109 PN_stdfloat _a1;
110 PN_stdfloat _a2;
111 bool _flickering;
112 Flicker_Type _flicker_type;
113 PN_stdfloat _offset;
114 PN_stdfloat _scale;
115 PN_stdfloat _step_size;
116 PN_stdfloat _sin_freq;
117 // PN_stdfloat _speed; PN_stdfloat fixed_points
118
119
120 public:
121 static void register_with_read_factory();
122 virtual void write_datagram(BamWriter *manager, Datagram &dg);
123 virtual void output(std::ostream &out) const;
124
125 protected:
126 static TypedWritable *make_from_bam(const FactoryParams &params);
127 void fillin(DatagramIterator &scan, BamReader *manager);
128
129
130
131 public:
132 static TypeHandle get_class_type() {
133 return _type_handle;
134 }
135 static void init_type() {
136 PandaNode::init_type();
137 register_type(_type_handle, "PolylightNode",
138 PandaNode::get_class_type());
139 }
140 virtual TypeHandle get_type() const {
141 return get_class_type();
142 }
143 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
144
145 private:
146 static TypeHandle _type_handle;
147};
148
149#include "polylightNode.I"
150
151#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
PandaNode::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
Definition pandaNode.cxx:3593
PandaNode::xform
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
Definition pandaNode.cxx:304
PandaNode::make_copy
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition pandaNode.cxx:481
PandaNode::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition pandaNode.cxx:3602
PolylightNode::get_attenuation
Attenuation_Type get_attenuation() const
Get "linear" or "quadratic" attenuation type.
Definition polylightNode.I:123
PolylightNode::get_pos
LPoint3 get_pos() const
Returns position as a LPoint3.
Definition polylightNode.I:88
PolylightNode::get_offset
PN_stdfloat get_offset() const
Get the offset value for the random and sin flicker variations.
Definition polylightNode.I:240
PolylightNode::is_enabled
bool is_enabled() const
Is this light is enabled/disabled?
Definition polylightNode.I:46
PolylightNode::get_a2
PN_stdfloat get_a2() const
Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:177
PolylightNode::enable
void enable()
Enable this light.
Definition polylightNode.I:54
PolylightNode::flicker_off
void flicker_off()
Turn flickering off.
Definition polylightNode.I:194
PolylightNode::set_pos
void set_pos(const LPoint3 &position)
Set this light's position.
Definition polylightNode.I:70
PolylightNode::get_scale
PN_stdfloat get_scale() const
Get the scale value for the random and sin flicker variations.
Definition polylightNode.I:257
PolylightNode::get_color_scenegraph
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...
Definition polylightNode.I:321
PolylightNode::set_step_size
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...
Definition polylightNode.I:266
PolylightNode::set_a2
void set_a2(PN_stdfloat a2)
Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:150
PolylightNode::flicker_on
void flicker_on()
Set flickering to true so at every loop this light's color is varied based on flicker_type.
Definition polylightNode.I:186
PolylightNode::get_radius
PN_stdfloat get_radius() const
Get radius of the spherical light volume.
Definition polylightNode.I:104
PolylightNode::set_radius
void set_radius(PN_stdfloat r)
Set radius of the spherical light volume.
Definition polylightNode.I:96
PolylightNode::set_flicker_type
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 ...
Definition polylightNode.I:212
PolylightNode::flicker
LColor flicker() const
If flickering is on, the do_poly_light function in PolylightNodeEffect will compute this light's colo...
Definition polylightNode.cxx:88
PolylightNode::set_offset
void set_offset(PN_stdfloat offset)
Set the offset value for the random and sin flicker variations... used to tweak the flicker This valu...
Definition polylightNode.I:232
PolylightNode::set_a1
void set_a1(PN_stdfloat a1)
Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:141
PolylightNode::set_freq
void set_freq(PN_stdfloat f)
Set frequency of sin flicker.
Definition polylightNode.I:341
PolylightNode::set_a0
void set_a0(PN_stdfloat a0)
Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:132
PolylightNode::get_flicker_type
Flicker_Type get_flicker_type() const
Returns FRANDOM or FSIN.
Definition polylightNode.I:223
PolylightNode::get_color
LColor get_color() const
Returns the light's color as LColor.
Definition polylightNode.I:311
PolylightNode::get_step_size
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...
Definition polylightNode.I:275
PolylightNode::PolylightNode
PolylightNode(const std::string &name)
Use PolylightNode() to construct a new PolylightNode object.
Definition polylightNode.cxx:32
PolylightNode::is_flickering
bool is_flickering() const
Check is this light is flickering.
Definition polylightNode.I:202
PolylightNode::get_a1
PN_stdfloat get_a1() const
Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:168
PolylightNode::get_a0
PN_stdfloat get_a0() const
Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
Definition polylightNode.I:159
PolylightNode::set_attenuation
bool set_attenuation(Attenuation_Type type)
Set ALINEAR or AQUADRATIC attenuation.
Definition polylightNode.I:112
PolylightNode::compare_to
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...
Definition polylightNode.cxx:153
PolylightNode::get_freq
PN_stdfloat get_freq() const
Get frequency of sin flicker.
Definition polylightNode.I:349
PolylightNode::set_color
void set_color(const LColor &color)
Set the light's color...
Definition polylightNode.I:283
PolylightNode::disable
void disable()
Disable this light.
Definition polylightNode.I:62
PolylightNode::set_scale
void set_scale(PN_stdfloat scale)
Set the scale value for the random and sin flicker variations... used to tweak the flicker This value...
Definition polylightNode.I:249
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
colorAttrib.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
nodePath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandaNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
polylightNode.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22