Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions

PolylightNode Class Reference

A PolylightNode. More...

#include "polylightNode.h"

Inheritance diagram for PolylightNode:
PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Public Types

enum  Attenuation_Type { ALINEAR, AQUADRATIC }
enum  Flicker_Type { FRANDOM, FSIN, FCUSTOM }

Public Member Functions

 PolylightNode (const string &name)
 Use PolylightNode() to construct a new PolylightNode object.
int compare_to (const PolylightNode &other) const
 Returns a number less than zero if this PolylightNode sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.
void disable ()
 Disable this light.
void enable ()
 Enable this light.
LColor flicker () const
 If flickering is on, the do_poly_light function in PolylightNodeEffect will compute this light's color based on the variations applied in this function Variation can be sin or random Use offset, scale and step_size to tweak Future addition: custom function variations to flicker.
void flicker_off ()
 Turn flickering off.
void flicker_on ()
 Set flickering to true so at every loop this light's color is varied based on flicker_type.
virtual TypeHandle force_init_type ()
PN_stdfloat get_a0 () const
 Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
PN_stdfloat get_a1 () const
 Get 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)
Attenuation_Type get_attenuation () const
 Get "linear" or "quadratic" attenuation type.
LColor get_color () const
 Returns the light's color as LColor.
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 flattening external to the PolylightNode is not ignored.
Flicker_Type get_flicker_type () const
 Returns FRANDOM or FSIN.
PN_stdfloat get_freq () const
 Get frequency of sin flicker.
PN_stdfloat get_offset () const
 Get the offset value for the random and sin flicker variations.
LVecBase3 get_pos () const
 Returns position as a LPoint3.
PN_stdfloat get_radius () const
 Get radius of the spherical light volume.
PN_stdfloat get_scale () const
 Get the scale value for the random and sin flicker variations.
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 to the sin function.
virtual TypeHandle get_type () const
bool is_enabled () const
 Is this light is enabled/disabled?
bool is_flickering () const
 Check is this light is flickering.
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
bool operator!= (const PolylightNode &other) const
 Returns true if the two lights are not equivalent.
bool operator< (const PolylightNode &other) const
 Returns true if this PolylightNode sorts before the other one, false otherwise.
bool operator== (const PolylightNode &other) const
 Returns true if the two lights are equivalent that is, all their properties are same.
virtual void output (ostream &out) const
 Outputs the Namable.
void set_a0 (PN_stdfloat a0)
 Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
void set_a1 (PN_stdfloat a1)
 Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
void set_a2 (PN_stdfloat a2)
 Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)
bool set_attenuation (Attenuation_Type type)
 Set ALINEAR or AQUADRATIC attenuation.
void set_color (PN_stdfloat r, PN_stdfloat g, PN_stdfloat b)
 Set the light's color...
void set_color (const LColor &color)
 Set the light's color...
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 a set of fix points recorded by animating the light's intensity.
void set_freq (PN_stdfloat f)
 Set frequency of sin flicker.
void set_offset (PN_stdfloat offset)
 Set the offset value for the random and sin flicker variations...
void set_pos (const LVecBase3 &position)
 Set this light's position.
void set_pos (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
 Set this light's position.
void set_radius (PN_stdfloat r)
 Set radius of the spherical light volume.
void set_scale (PN_stdfloat scale)
 Set the scale value for the random and sin flicker variations...
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 to the sin function.
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 Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type PolylightNode.

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CompassEffect.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type CompassEffect is encountered in the Bam file.

Detailed Description

A PolylightNode.

Definition at line 31 of file polylightNode.h.


Constructor & Destructor Documentation

PolylightNode::PolylightNode ( const string &  name)

Use PolylightNode() to construct a new PolylightNode object.

Definition at line 36 of file polylightNode.cxx.

References set_attenuation(), set_color(), set_flicker_type(), and set_pos().

Referenced by make_copy(), and make_from_bam().


Member Function Documentation

int PolylightNode::compare_to ( const PolylightNode other) const

Returns a number less than zero if this PolylightNode sorts before the other one, greater than zero if it sorts after, or zero if they are equivalent.

Two PolylightNodes are considered equivalent if they consist of exactly the same properties Otherwise, they are different; different PolylightNodes will be ranked in a consistent but undefined ordering; the ordering is useful only for placing the PolylightNodes in a sorted container like an STL set.

Definition at line 148 of file polylightNode.cxx.

References get_color(), and get_pos().

Referenced by operator!=(), operator<(), and operator==().

void PolylightNode::disable ( ) [inline]

Disable this light.

Definition at line 78 of file polylightNode.I.

void PolylightNode::enable ( ) [inline]

Enable this light.

Definition at line 68 of file polylightNode.I.

void PolylightNode::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CompassEffect.

Reimplemented from PandaNode.

Definition at line 271 of file polylightNode.cxx.

References DatagramIterator::get_stdfloat(), LVecBase3f::read_datagram(), and set_color().

Referenced by make_from_bam().

LColor PolylightNode::flicker ( ) const

If flickering is on, the do_poly_light function in PolylightNodeEffect will compute this light's color based on the variations applied in this function Variation can be sin or random Use offset, scale and step_size to tweak Future addition: custom function variations to flicker.

Definition at line 78 of file polylightNode.cxx.

References get_color(), ClockObject::get_frame_time(), and ClockObject::get_global_clock().

void PolylightNode::flicker_off ( ) [inline]

Turn flickering off.

Definition at line 241 of file polylightNode.I.

void PolylightNode::flicker_on ( ) [inline]

Set flickering to true so at every loop this light's color is varied based on flicker_type.

Definition at line 231 of file polylightNode.I.

PN_stdfloat PolylightNode::get_a0 ( ) const [inline]

Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 198 of file polylightNode.I.

PN_stdfloat PolylightNode::get_a1 ( ) const [inline]

Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 209 of file polylightNode.I.

PN_stdfloat PolylightNode::get_a2 ( ) const [inline]

Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 220 of file polylightNode.I.

PolylightNode::Attenuation_Type PolylightNode::get_attenuation ( ) const [inline]

Get "linear" or "quadratic" attenuation type.

Definition at line 154 of file polylightNode.I.

LColor PolylightNode::get_color ( ) const [inline]

Returns the light's color as LColor.

Definition at line 389 of file polylightNode.I.

Referenced by compare_to(), and flicker().

LColor PolylightNode::get_color_scenegraph ( ) const [inline]

This differs from get_color in that when applying the light color we need to make sure that a color flattening external to the PolylightNode is not ignored.

Definition at line 402 of file polylightNode.I.

References PandaNode::get_attrib(), ColorAttrib::get_color(), and ColorAttrib::get_color_type().

PolylightNode::Flicker_Type PolylightNode::get_flicker_type ( ) const [inline]

Returns FRANDOM or FSIN.

Definition at line 277 of file polylightNode.I.

PN_stdfloat PolylightNode::get_freq ( ) const [inline]

Get frequency of sin flicker.

Definition at line 434 of file polylightNode.I.

PN_stdfloat PolylightNode::get_offset ( ) const [inline]

Get the offset value for the random and sin flicker variations.

Definition at line 300 of file polylightNode.I.

LVecBase3 PolylightNode::get_pos ( ) const [inline]

Returns position as a LPoint3.

Definition at line 111 of file polylightNode.I.

Referenced by compare_to().

PN_stdfloat PolylightNode::get_radius ( ) const [inline]

Get radius of the spherical light volume.

Definition at line 131 of file polylightNode.I.

Referenced by output().

PN_stdfloat PolylightNode::get_scale ( ) const [inline]

Get the scale value for the random and sin flicker variations.

Definition at line 323 of file polylightNode.I.

PN_stdfloat PolylightNode::get_step_size ( ) const [inline]

Get the step size for the sin function in flicker This is the increment size for the value supplied to the sin function.

Definition at line 347 of file polylightNode.I.

bool PolylightNode::is_enabled ( ) const [inline]

Is this light is enabled/disabled?

Definition at line 58 of file polylightNode.I.

bool PolylightNode::is_flickering ( ) const [inline]

Check is this light is flickering.

Definition at line 251 of file polylightNode.I.

PandaNode * PolylightNode::make_copy ( ) const [virtual]

Returns a newly-allocated Node that is a shallow copy of this one.

It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.

Reimplemented from PandaNode.

Definition at line 64 of file polylightNode.cxx.

References PolylightNode().

TypedWritable * PolylightNode::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type CompassEffect is encountered in the Bam file.

It should create the CompassEffect and extract its information from the file.

Reimplemented from PandaNode.

Definition at line 252 of file polylightNode.cxx.

References fillin(), and PolylightNode().

Referenced by register_with_read_factory().

bool PolylightNode::operator!= ( const PolylightNode other) const [inline]

Returns true if the two lights are not equivalent.

Definition at line 34 of file polylightNode.I.

References compare_to().

bool PolylightNode::operator< ( const PolylightNode other) const [inline]

Returns true if this PolylightNode sorts before the other one, false otherwise.

The sorting order of two nonequivalent PolylightNodes is consistent but undefined, and is useful only for storing PolylightNodes in a sorted container like an STL set.

Definition at line 48 of file polylightNode.I.

References compare_to().

bool PolylightNode::operator== ( const PolylightNode other) const [inline]

Returns true if the two lights are equivalent that is, all their properties are same.

Definition at line 24 of file polylightNode.I.

References compare_to().

void PolylightNode::output ( ostream &  out) const [virtual]

Outputs the Namable.

This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.

Reimplemented from PandaNode.

Definition at line 288 of file polylightNode.cxx.

References get_radius().

void PolylightNode::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type PolylightNode.

Reimplemented from PandaNode.

Definition at line 223 of file polylightNode.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

void PolylightNode::set_a0 ( PN_stdfloat  a0) [inline]

Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 165 of file polylightNode.I.

void PolylightNode::set_a1 ( PN_stdfloat  a1) [inline]

Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 176 of file polylightNode.I.

void PolylightNode::set_a2 ( PN_stdfloat  a2) [inline]

Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + a2*distance*distance)

Definition at line 187 of file polylightNode.I.

bool PolylightNode::set_attenuation ( PolylightNode::Attenuation_Type  type) [inline]

Set ALINEAR or AQUADRATIC attenuation.

Definition at line 141 of file polylightNode.I.

Referenced by PolylightNode().

void PolylightNode::set_color ( const LColor color) [inline]

Set the light's color...

Definition at line 357 of file polylightNode.I.

Referenced by fillin(), and PolylightNode().

void PolylightNode::set_color ( PN_stdfloat  r,
PN_stdfloat  g,
PN_stdfloat  b 
) [inline]

Set the light's color...

3 floats between 0 and 1

Definition at line 368 of file polylightNode.I.

bool PolylightNode::set_flicker_type ( PolylightNode::Flicker_Type  type) [inline]

Flicker type can be FRANDOM or FSIN At a later point there might be a FCUSTOM Custom flicker will be a set of fix points recorded by animating the light's intensity.

Definition at line 264 of file polylightNode.I.

Referenced by PolylightNode().

void PolylightNode::set_freq ( PN_stdfloat  f) [inline]

Set frequency of sin flicker.

Definition at line 424 of file polylightNode.I.

void PolylightNode::set_offset ( PN_stdfloat  offset) [inline]

Set the offset value for the random and sin flicker variations...

used to tweak the flicker This value is added to the variation

Definition at line 289 of file polylightNode.I.

void PolylightNode::set_pos ( PN_stdfloat  x,
PN_stdfloat  y,
PN_stdfloat  z 
) [inline]

Set this light's position.

Definition at line 99 of file polylightNode.I.

void PolylightNode::set_pos ( const LVecBase3 position) [inline]

Set this light's position.

Definition at line 88 of file polylightNode.I.

Referenced by PolylightNode().

void PolylightNode::set_radius ( PN_stdfloat  r) [inline]

Set radius of the spherical light volume.

Definition at line 121 of file polylightNode.I.

void PolylightNode::set_scale ( PN_stdfloat  scale) [inline]

Set the scale value for the random and sin flicker variations...

used to tweak the flicker This value is multiplied with the variation

Definition at line 312 of file polylightNode.I.

void PolylightNode::set_step_size ( PN_stdfloat  step) [inline]

Set the step size for the sin function in flicker This is the increment size for the value supplied to the sin function.

Definition at line 335 of file polylightNode.I.

void PolylightNode::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from PandaNode.

Definition at line 234 of file polylightNode.cxx.

References Datagram::add_stdfloat(), and LVecBase3f::write_datagram().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations