15 #include "polylightNode.h" 16 #include "config_pgraph.h" 18 #include "clockObject.h" 19 #include "bamReader.h" 20 #include "bamWriter.h" 22 #include "datagramIterator.h" 83 _position = _position * mat;
88 _radius = length(radius_v);
89 mark_internal_bounds_stale();
105 PN_stdfloat variation= 0.0;
112 if (_flicker_type == FRANDOM) {
114 variation = (rand()%100);
117 pgraph_cat.info() <<
"Random Variation: " << variation << endl;
118 }
else if (_flicker_type == FSIN) {
120 variation = sinf(now*_sin_freq);
122 pgraph_cat.info() <<
"Variation: " << variation << endl;
126 }
else if (_flicker_type == FCUSTOM) {
152 pgraph_cat.debug() <<
"Color R:" << r <<
"; G:" << g <<
"; B:" << b << endl;
174 if (_enabled != other._enabled) {
175 return _enabled ? 1 :-1;
178 if (_radius != other._radius) {
179 return _radius < other._radius ? -1 :1;
183 if (position != other_position) {
184 return position < other_position ? -1 :1;
189 if (color != other_color) {
190 return color < other_color ? -1 :1;
193 if (_attenuation_type != other._attenuation_type) {
194 return _attenuation_type < other._attenuation_type ? -1 :1;
197 if (_a0 != other._a0) {
198 return _a0 < other._a0 ? -1 :1;
201 if (_a1 != other._a1) {
202 return _a1 < other._a1 ? -1 :1;
205 if (_a2 != other._a2) {
206 return _a2 < other._a2 ? -1 :1;
209 if (_flickering != other._flickering) {
210 return _flickering ? 1 :-1;
213 if (_flicker_type != other._flicker_type) {
214 return _flicker_type < other._flicker_type ? -1 :1;
217 if (_offset != other._offset) {
218 return _offset < other._offset ? -1 :1;
221 if (_scale != other._scale) {
222 return _scale < other._scale ? -1 :1;
225 if (_step_size != other._step_size) {
226 return _step_size < other._step_size ? -1 :1;
229 if (_sin_freq != other._sin_freq) {
230 return _sin_freq < other._sin_freq ? -1 :1;
262 color.set(_color[0], _color[1], _color[2]);
281 parse_params(params, scan, manager);
282 light->fillin(scan, manager);
296 PandaNode::fillin(scan, manager);
312 output(ostream &out)
const {
313 out << get_type() <<
":";
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
virtual void xform(const LMatrix4 &mat)
Transforms the contents of this node by the indicated matrix, if it means anything to do so...
static const LMatrix4f & ident_mat()
Returns an identity matrix.
A basic node of the scene graph or data graph.
This is the base class for all three-component vectors and points.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
PolylightNode(const string &name)
Use PolylightNode() to construct a new PolylightNode object.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
bool almost_equal(const LMatrix4f &other, float threshold) const
Returns true if two matrices are memberwise equal within a specified tolerance.
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
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 ...
PN_stdfloat get_radius() const
Get radius of the spherical light volume.
Base class for objects that can be written to and read from Bam files.
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...
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
static void register_with_read_factory()
Tells the BamReader how to create objects of type PolylightNode.
double get_frame_time(Thread *current_thread=Thread::get_current_thread()) const
Returns the time in seconds as of the last time tick() was called (typically, this will be as of the ...
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
void set_pos(const LPoint3 &position)
Set this light's position.
virtual PandaNode * make_copy() const
Returns a newly-allocated Node that is a shallow copy of this one.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
LPoint3 get_pos() const
Returns position as a LPoint3.
This is a 4-by-4 transform matrix.
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
bool set_attenuation(Attenuation_Type type)
Set ALINEAR or AQUADRATIC attenuation.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
LColor flicker() const
If flickering is on, the do_poly_light function in PolylightNodeEffect will compute this light's colo...
This is the base class for all three-component vectors and points.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void set_color(const LColor &color)
Set the light's color...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
LColor get_color() const
Returns the light's color as LColor.