Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions
LightAttrib Class Reference

Indicates which set of lights should be considered "on" to illuminate geometry at this level and below. More...

#include "lightAttrib.h"

Inheritance diagram for LightAttrib:
RenderAttrib TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Classes

class  BamAuxData

Public Types

typedef pvector< PT(PandaNode) > NodeList
enum  Operation { O_set, O_add, O_remove }

Public Member Functions

virtual int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
 CPT (RenderAttrib) add_light(Light *light) const
 CPT (RenderAttrib) remove_light(Light *light) const
 CPT (RenderAttrib) add_on_light(const NodePath &light) const
 CPT (RenderAttrib) remove_on_light(const NodePath &light) const
 CPT (RenderAttrib) add_off_light(const NodePath &light) const
 CPT (RenderAttrib) remove_off_light(const NodePath &light) const
 CPT (LightAttrib) filter_to_max(int max_lights) const
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
virtual TypeHandle force_init_type ()
Lightget_light (int n) const
 Returns the nth light listed in the attribute.
NodePath get_most_important_light () const
 Returns the most important light (that is, the light with the highest priority) in the LightAttrib, excluding any ambient lights.
int get_num_lights () const
 Returns the number of lights listed in the attribute.
int get_num_off_lights () const
 Returns the number of lights that are turned off by the attribute.
int get_num_on_lights () const
 Returns the number of lights that are turned on by the attribute.
NodePath get_off_light (int n) const
 Returns the nth light turned off by the attribute, sorted in arbitrary (pointer) order.
NodePath get_on_light (int n) const
 Returns the nth light turned on by the attribute, sorted in render order.
Operation get_operation () const
 Returns the basic operation type of the LightAttrib.
virtual int get_slot () const
virtual TypeHandle get_type () const
bool has_all_off () const
 Returns true if this attrib turns off all lights (although it may also turn some on).
bool has_light (Light *light) const
 Returns true if the indicated light is listed in the attrib, false otherwise.
bool has_off_light (const NodePath &light) const
 Returns true if the indicated light is turned off by the attrib, false otherwise.
bool has_on_light (const NodePath &light) const
 Returns true if the indicated light is turned on by the attrib, false otherwise.
bool is_identity () const
 Returns true if this is an identity attrib: it does not change the set of lights in use.
 MAKE_SEQ (get_on_lights, get_num_on_lights, get_on_light)
 MAKE_SEQ (get_off_lights, get_num_off_lights, get_off_light)
virtual void output (ostream &out) const
virtual void write (ostream &out, int indent_level) const
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 CPT (RenderAttrib) make(Operation op
static CPT (RenderAttrib) make(Operation op
static CPT (RenderAttrib) make(Operation op
static CPT (RenderAttrib) make(Operation op
static CPT (RenderAttrib) make_default()
static CPT (RenderAttrib) make()
static CPT (RenderAttrib) make_all_off()
static int get_class_slot ()
static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type LightAttrib.

Public Attributes

static Lightlight
static Lightlight1
static Light Lightlight2
static Light Light Lightlight3
static Light Light Light Lightlight4

Protected Member Functions

 LightAttrib ()
 Use LightAttrib::make() to construct a new LightAttrib object.
 LightAttrib (const LightAttrib &copy)
 Use LightAttrib::make() to construct a new LightAttrib object.
virtual int compare_to_impl (const RenderAttrib *other) const
 Intended to be overridden by derived LightAttrib types to return a unique number indicating whether this LightAttrib is equivalent to the other one.
virtual CPT (RenderAttrib) compose_impl(const RenderAttrib *other) const
virtual CPT (RenderAttrib) invert_compose_impl(const RenderAttrib *other) const
virtual CPT (RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const
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 LightAttrib.
virtual size_t get_hash_impl () const
 Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties.

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 LightAttrib is encountered in the Bam file.

Detailed Description

Indicates which set of lights should be considered "on" to illuminate geometry at this level and below.

A LightAttrib can either add lights or remove lights from the total set of "on" lights.

Definition at line 33 of file lightAttrib.h.


Constructor & Destructor Documentation

LightAttrib::LightAttrib ( ) [inline, protected]

Use LightAttrib::make() to construct a new LightAttrib object.

Definition at line 23 of file lightAttrib.I.

Referenced by make_from_bam().

LightAttrib::LightAttrib ( const LightAttrib copy) [inline, protected]

Use LightAttrib::make() to construct a new LightAttrib object.

The copy constructor is only defined to facilitate methods like add_on_light().

Definition at line 35 of file lightAttrib.I.


Member Function Documentation

int LightAttrib::compare_to_impl ( const RenderAttrib other) const [protected, virtual]

Intended to be overridden by derived LightAttrib types to return a unique number indicating whether this LightAttrib is equivalent to the other one.

This should return 0 if the two LightAttrib objects are equivalent, a number less than zero if this one should be sorted before the other one, and a number greater than zero otherwise.

This will only be called with two LightAttrib objects whose get_type() functions return the same.

Reimplemented from RenderAttrib.

Definition at line 698 of file lightAttrib.cxx.

References ordered_vector< Key, Compare >::begin(), NodePath::compare_to(), and ordered_vector< Key, Compare >::end().

int LightAttrib::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

Reimplemented from TypedWritable.

Definition at line 1021 of file lightAttrib.cxx.

References BamReader::get_aux_data().

void LightAttrib::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 LightAttrib.

Reimplemented from RenderAttrib.

Definition at line 1124 of file lightAttrib.cxx.

References DatagramIterator::get_bool(), DatagramIterator::get_uint16(), BamReader::read_pointers(), and BamReader::set_aux_data().

Referenced by make_from_bam().

void LightAttrib::finalize ( BamReader manager) [virtual]

Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.

Reimplemented from RenderAttrib.

Definition at line 1053 of file lightAttrib.cxx.

References BamReader::get_aux_data(), ordered_vector< Key, Compare >::push_back(), ordered_vector< Key, Compare >::reserve(), and ov_set< Key, Compare >::sort().

size_t LightAttrib::get_hash_impl ( ) const [protected, virtual]

Intended to be overridden by derived RenderAttrib types to return a unique hash for these particular properties.

RenderAttribs that compare the same with compare_to_impl(), above, should return the same hash; RenderAttribs that compare differently should return a different hash.

Reimplemented from RenderAttrib.

Definition at line 766 of file lightAttrib.cxx.

References integer_hash< Key, Compare >::add_hash(), NodePath::add_hash(), ordered_vector< Key, Compare >::begin(), and ordered_vector< Key, Compare >::end().

Light * LightAttrib::get_light ( int  n) const

Returns the nth light listed in the attribute.

This method is now deprecated. LightAttribs nowadays have a separate list of on_lights and off_lights, so this method doesn't make sense. Query the lists independently.

Definition at line 296 of file lightAttrib.cxx.

References PandaNode::as_light(), get_num_off_lights(), get_off_light(), get_on_light(), and NodePath::node().

Returns the most important light (that is, the light with the highest priority) in the LightAttrib, excluding any ambient lights.

Returns an empty NodePath if no non-ambient lights are found.

Definition at line 569 of file lightAttrib.cxx.

References PandaNode::as_light(), PandaNode::is_ambient_light(), NodePath::is_empty(), and NodePath::node().

Returns the number of lights listed in the attribute.

This method is now deprecated. LightAttribs nowadays have a separate list of on_lights and off_lights, so this method doesn't make sense. Query the lists independently.

Definition at line 274 of file lightAttrib.cxx.

References get_num_off_lights(), and get_num_on_lights().

int LightAttrib::get_num_off_lights ( ) const [inline]

Returns the number of lights that are turned off by the attribute.

Definition at line 83 of file lightAttrib.I.

References ordered_vector< Key, Compare >::size().

Referenced by get_light(), get_num_lights(), get_operation(), has_light(), and write_datagram().

int LightAttrib::get_num_on_lights ( ) const [inline]

Returns the number of lights that are turned on by the attribute.

Definition at line 49 of file lightAttrib.I.

References ordered_vector< Key, Compare >::size().

Referenced by ShaderGenerator::analyze_renderstate(), SpeedTreeNode::cull_callback(), get_num_lights(), and write_datagram().

NodePath LightAttrib::get_off_light ( int  n) const [inline]

Returns the nth light turned off by the attribute, sorted in arbitrary (pointer) order.

Definition at line 94 of file lightAttrib.I.

References NodePath::fail(), and ordered_vector< Key, Compare >::size().

Referenced by get_light().

NodePath LightAttrib::get_on_light ( int  n) const [inline]

Returns the nth light turned on by the attribute, sorted in render order.

Definition at line 60 of file lightAttrib.I.

References NodePath::fail(), and ordered_vector< Key, Compare >::size().

Referenced by ShaderGenerator::analyze_renderstate(), SpeedTreeNode::cull_callback(), and get_light().

LightAttrib::Operation LightAttrib::get_operation ( ) const

Returns the basic operation type of the LightAttrib.

If this is O_set, the lights listed here completely replace any lights that were already on. If this is O_add, the lights here are added to the set of of lights that were already on, and if O_remove, the lights here are removed from the set of lights that were on.

This method is now deprecated. LightAttribs nowadays have a separate list of on_lights and off_lights, so this method doesn't make sense. Query the lists independently.

Definition at line 248 of file lightAttrib.cxx.

References get_num_off_lights(), and has_all_off().

bool LightAttrib::has_all_off ( ) const [inline]

Returns true if this attrib turns off all lights (although it may also turn some on).

Definition at line 118 of file lightAttrib.I.

Referenced by get_operation(), and NodePath::has_light_off().

bool LightAttrib::has_light ( Light light) const

Returns true if the indicated light is listed in the attrib, false otherwise.

This method is now deprecated. LightAttribs nowadays have a separate list of on_lights and off_lights, so this method doesn't make sense. Query the lists independently.

Definition at line 319 of file lightAttrib.cxx.

References get_num_off_lights(), has_off_light(), and has_on_light().

bool LightAttrib::has_off_light ( const NodePath light) const [inline]

Returns true if the indicated light is turned off by the attrib, false otherwise.

Definition at line 106 of file lightAttrib.I.

References ordered_vector< Key, Compare >::end(), and has_on_light().

Referenced by has_light(), and NodePath::has_light_off().

bool LightAttrib::has_on_light ( const NodePath light) const [inline]

Returns true if the indicated light is turned on by the attrib, false otherwise.

Definition at line 72 of file lightAttrib.I.

References ordered_vector< Key, Compare >::end().

Referenced by has_light(), NodePath::has_light(), and has_off_light().

bool LightAttrib::is_identity ( ) const [inline]

Returns true if this is an identity attrib: it does not change the set of lights in use.

Definition at line 129 of file lightAttrib.I.

References ordered_vector< Key, Compare >::empty().

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

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

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

Definition at line 1103 of file lightAttrib.cxx.

References fillin(), LightAttrib(), and BamReader::register_finalize().

Referenced by register_with_read_factory().

Tells the BamReader how to create objects of type LightAttrib.

Definition at line 974 of file lightAttrib.cxx.

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

void LightAttrib::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 RenderAttrib.

Definition at line 985 of file lightAttrib.cxx.

References Datagram::add_bool(), Datagram::add_uint16(), ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), get_num_off_lights(), get_num_on_lights(), NodePath::node(), and BamWriter::write_pointer().


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