Panda3D
Classes | Public Member Functions | Static Public Member Functions | List of all members
Light Class Referenceabstract

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

#include "light.h"

Inheritance diagram for Light:
LightLensNode LightNode DirectionalLight PointLight Spotlight AmbientLight

Public Member Functions

 Light (const Light &copy)
 
virtual PandaNodeas_node ()=0
 
virtual void bind (GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)=0
 
virtual const LVecBase3get_attenuation () const
 Returns the terms of the attenuation equation for the light. More...
 
virtual int get_class_priority () const =0
 
const LColorget_color () const
 Returns the basic color of the light. More...
 
virtual PN_stdfloat get_exponent () const
 For spotlights, returns the exponent that controls the amount of light falloff from the center of the spotlight. More...
 
int get_priority () const
 Returns the priority associated with this light. More...
 
virtual const LColorget_specular_color () const
 Returns the color of specular highlights generated by the light. More...
 
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. More...
 
GeomNodeget_viz ()
 Returns a GeomNode that may be rendered to visualize the Light. More...
 
virtual bool is_ambient_light () const
 Returns true if this is an AmbientLight, false if it is some other kind of light. More...
 
virtual void output (ostream &out) const =0
 
void set_color (const LColor &color)
 Sets the basic color of the light. More...
 
void set_priority (int priority)
 Changes the relative importance of this light relative to the other lights that are applied simultaneously. More...
 
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. More...
 
static void init_type ()
 

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

◆ get_attenuation()

const LVecBase3 & Light::get_attenuation ( ) const
virtual

Returns the terms of the attenuation equation for the light.

These are, in order, the constant, linear, and quadratic terms based on the distance from the point to the vertex.

Reimplemented in Spotlight, and PointLight.

Definition at line 113 of file light.cxx.

References get_vector_to_light().

Referenced by GraphicsStateGuardian::fetch_specified_part(), and get_specular_color().

◆ get_color()

const LColor & Light::get_color ( ) const
inline

Returns the basic color of the light.

Definition at line 70 of file light.I.

References set_color().

Referenced by SpeedTreeNode::cull_callback(), GraphicsStateGuardian::fetch_specified_part(), and DXGraphicsStateGuardian9::get_index_type().

◆ get_exponent()

PN_stdfloat Light::get_exponent ( ) const
virtual

For spotlights, returns the exponent that controls the amount of light falloff from the center of the spotlight.

For other kinds of lights, returns 0.

Reimplemented in Spotlight.

Definition at line 87 of file light.cxx.

References get_specular_color().

Referenced by GraphicsStateGuardian::fetch_specified_part(), and is_ambient_light().

◆ get_priority()

int Light::get_priority ( ) const
inline

Returns the priority associated with this light.

See set_priority().

Definition at line 118 of file light.I.

References get_sort_seq().

Referenced by SpeedTreeNode::cull_callback(), and set_priority().

◆ get_sort_seq()

UpdateSeq Light::get_sort_seq ( )
inlinestatic

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.

Referenced by get_priority(), LightAttrib::has_light(), and LightAttrib::is_identity().

◆ get_specular_color()

const LColor & Light::get_specular_color ( ) const
virtual

Returns the color of specular highlights generated by the light.

This value is meaningless for ambient lights.

Reimplemented in Spotlight, DirectionalLight, and PointLight.

Definition at line 99 of file light.cxx.

References get_attenuation().

Referenced by GraphicsStateGuardian::fetch_specified_part(), and get_exponent().

◆ get_vector_to_light()

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 136 of file light.cxx.

References get_viz().

Referenced by get_attenuation().

◆ get_viz()

GeomNode * Light::get_viz ( )

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 148 of file light.cxx.

References Datagram::add_int32(), DatagramIterator::get_int32(), BamReader::read_cdata(), and BamWriter::write_cdata().

Referenced by get_vector_to_light().

◆ is_ambient_light()

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.

References get_exponent().

◆ set_color()

void Light::set_color ( const LColor color)
inline

Sets the basic color of the light.

Definition at line 81 of file light.I.

References set_priority().

Referenced by get_color(), and WindowFramework::make_camera().

◆ set_priority()

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.

References get_priority().

Referenced by set_color().


The documentation for this class was generated from the following files: