Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions
Light Class Reference

The abstract interface to all kinds of lights. More...

#include "light.h"

Inheritance diagram for Light:
ReferenceCount MemoryBase LightLensNode LightNode DirectionalLight PointLight Spotlight AmbientLight

List of all members.

Classes

class  CData

Public Member Functions

 Light (const Light &copy)
virtual PandaNodeas_node ()=0
virtual void bind (GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)=0
virtual int get_class_priority () const =0
const LColorget_color () const
 Returns the basic color of the light.
int get_priority () const
 Returns the priority associated with this light.
virtual TypeHandle get_type () const
virtual bool get_vector_to_light (LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space)
 Computes the vector from a particular vertex to this light.
GeomNodeget_viz ()
 Returns a GeomNode that may be rendered to visualize the Light.
virtual bool is_ambient_light () const
 Returns true if this is an AmbientLight, false if it is some other kind of light.
virtual void output (ostream &out) const =0
void set_color (const LColor &color)
 Sets the basic color of the light.
void set_priority (int priority)
 Changes the relative importance of this light relative to the other lights that are applied simultaneously.
virtual void write (ostream &out, int indent_level) const =0

Static Public Member Functions

static TypeHandle get_class_type ()
static UpdateSeq get_sort_seq ()
 Returns a global sequence number that is incremented any time any Light in the world changes sort or priority.
static void init_type ()

Protected Types

enum  ClassPriority { CP_ambient_priority, CP_point_priority, CP_directional_priority, CP_spot_priority }

Protected Member Functions

virtual void fill_viz_geom (GeomNode *viz_geom)
 Fills the indicated GeomNode up with Geoms suitable for rendering this light.
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 Light.
void mark_viz_stale ()
 Indicates that the internal visualization object will need to be updated.
void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

Detailed Description

The abstract interface to all kinds of lights.

The actual light objects also inherit from PandaNode, and can therefore be added to the scene graph at some arbitrary point to define the coordinate system of effect.

Definition at line 42 of file light.h.


Member Function Documentation

void Light::fill_viz_geom ( GeomNode viz_geom) [protected, virtual]

Fills the indicated GeomNode up with Geoms suitable for rendering this light.

Reimplemented in Spotlight.

Definition at line 128 of file light.cxx.

Referenced by get_viz().

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

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

Reimplemented in Spotlight, DirectionalLight, PointLight, LightLensNode, AmbientLight, and LightNode.

Definition at line 151 of file light.cxx.

References DatagramIterator::get_int32(), and BamReader::read_cdata().

const LColor & Light::get_color ( ) const [inline]

Returns the basic color of the light.

Definition at line 70 of file light.I.

Referenced by SpeedTreeNode::cull_callback(), DXGraphicsStateGuardian8::get_light_color(), and DXGraphicsStateGuardian9::get_light_color().

int Light::get_priority ( ) const [inline]

Returns the priority associated with this light.

See set_priority().

Definition at line 118 of file light.I.

Referenced by SpeedTreeNode::cull_callback().

UpdateSeq Light::get_sort_seq ( ) [inline, static]

Returns a global sequence number that is incremented any time any Light in the world changes sort or priority.

This is used by LightAttrib to determine when it is necessary to re-sort its internal array of stages.

Definition at line 132 of file light.I.

bool Light::get_vector_to_light ( LVector3 result,
const LPoint3 from_object_point,
const LMatrix4 to_object_space 
) [virtual]

Computes the vector from a particular vertex to this light.

The exact vector depends on the type of light (e.g. point lights return a different result than directional lights).

The input parameters are the vertex position in question, expressed in object space, and the matrix which converts from light space to object space. The result is expressed in object space.

The return value is true if the result is successful, or false if it cannot be computed (e.g. for an ambient light).

Reimplemented in Spotlight, DirectionalLight, and PointLight.

Definition at line 97 of file light.cxx.

Returns a GeomNode that may be rendered to visualize the Light.

This is used during the cull traversal to render the Lights that have been made visible.

Definition at line 109 of file light.cxx.

References fill_viz_geom().

bool Light::is_ambient_light ( ) const [virtual]

Returns true if this is an AmbientLight, false if it is some other kind of light.

Reimplemented in AmbientLight.

Definition at line 75 of file light.cxx.

void Light::mark_viz_stale ( ) [inline, protected]

Indicates that the internal visualization object will need to be updated.

Definition at line 143 of file light.I.

Referenced by set_color(), DirectionalLight::set_direction(), DirectionalLight::set_point(), PointLight::set_point(), DirectionalLight::xform(), and Spotlight::xform().

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

Sets the basic color of the light.

Definition at line 81 of file light.I.

References mark_viz_stale().

void Light::set_priority ( int  priority) [inline]

Changes the relative importance of this light relative to the other lights that are applied simultaneously.

The priority number is used to decide which of the requested lights are to be selected for rendering when more lights are requested than the hardware will support. The highest-priority n lights are selected for rendering.

This is similar to TextureStage::set_priority().

Definition at line 103 of file light.I.

void Light::write_datagram ( BamWriter manager,
Datagram dg 
) [protected]

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

Reimplemented in Spotlight, DirectionalLight, PointLight, LightLensNode, AmbientLight, and LightNode.

Definition at line 138 of file light.cxx.

References Datagram::add_int32(), and BamWriter::write_cdata().


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