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 */
29class 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
97public:
98 LColor flicker() const;
99 virtual PandaNode *make_copy() const;
100 virtual void xform(const LMatrix4 &mat);
101
102private:
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
120public:
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
125protected:
126 static TypedWritable *make_from_bam(const FactoryParams &params);
127 void fillin(DatagramIterator &scan, BamReader *manager);
128
129
130
131public:
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
145private:
146 static TypeHandle _type_handle;
147};
148
149#include "polylightNode.I"
150
151#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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 ...
LColor flicker() const
If flickering is on, the do_poly_light function in PolylightNodeEffect will compute this light's colo...
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)
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...
PolylightNode(const std::string &name)
Use PolylightNode() to construct a new PolylightNode object.
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...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...