Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions

Spotlight Class Reference

A light originating from a single point in space, and shining in a particular direction, with a cone-shaped falloff. More...

#include "spotlight.h"

Inheritance diagram for Spotlight:
LightLensNode Light Camera ReferenceCount LensNode MemoryBase PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Classes

class  CData

Public Member Functions

 Spotlight (const string &name)
virtual void bind (GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)
virtual TypeHandle force_init_type ()
const LVecBase3get_attenuation () const
 Returns the terms of the attenuation equation for the light.
virtual int get_class_priority () const
 Returns the relative priority associated with all lights of this class.
PN_stdfloat get_exponent () const
 Returns the exponent that controls the amount of light falloff from the center of the spotlight.
const LColorget_specular_color () const
 Returns the color of specular highlights generated by the 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.
virtual PandaNodemake_copy () const
 Returns a newly-allocated PandaNode that is a shallow copy of this one.
void set_attenuation (const LVecBase3 &attenuation)
 Sets the terms of the attenuation equation for the light.
void set_exponent (PN_stdfloat exponent)
 Sets the exponent that controls the amount of light falloff from the center of the spotlight.
void set_specular_color (const LColor &color)
 Sets the color of specular highlights generated by the light.
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.
virtual void xform (const LMatrix4 &mat)
 Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static PT (Texture) make_spot(int pixel_width
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type Spotlight.

Public Attributes

static PN_stdfloat LColor LColorbg
static PN_stdfloat LColorfg
static PN_stdfloat full_radius

Protected Member Functions

 Spotlight (const Spotlight &copy)
 Do not call the copy constructor directly; instead, use make_copy() or copy_subgraph() to make a copy of a node.
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 Spotlight.

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

Detailed Description

A light originating from a single point in space, and shining in a particular direction, with a cone-shaped falloff.

The Spotlight frustum is defined using a Lens, so it can have any of the properties that a camera lens can have.

Note that the class is named Spotlight instead of SpotLight, because "spotlight" is a single English word, instead of two words.

Definition at line 37 of file spotlight.h.


Constructor & Destructor Documentation

Spotlight::Spotlight ( const Spotlight copy) [protected]

Do not call the copy constructor directly; instead, use make_copy() or copy_subgraph() to make a copy of a node.

Definition at line 84 of file spotlight.cxx.


Member Function Documentation

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

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

Reimplemented from Light.

Definition at line 243 of file spotlight.cxx.

References GeomNode::add_geom(), and LensNode::get_lens().

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

Reimplemented from LightLensNode.

Definition at line 320 of file spotlight.cxx.

References BamReader::read_cdata().

Referenced by make_from_bam().

const LVecBase3 & Spotlight::get_attenuation ( ) const [inline]

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.

Definition at line 105 of file spotlight.I.

Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), and DXGraphicsStateGuardian8::bind_light().

int Spotlight::get_class_priority ( ) const [virtual]

Returns the relative priority associated with all lights of this class.

This priority is used to order lights whose instance priority (get_priority()) is the same--the idea is that other things being equal, AmbientLights (for instance) are less important than DirectionalLights.

Implements Light.

Definition at line 222 of file spotlight.cxx.

PN_stdfloat Spotlight::get_exponent ( ) const [inline]

Returns the exponent that controls the amount of light falloff from the center of the spotlight.

See set_exponent().

Definition at line 50 of file spotlight.I.

Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), and DXGraphicsStateGuardian8::bind_light().

const LColor & Spotlight::get_specular_color ( ) const [inline]

Returns the color of specular highlights generated by the light.

Definition at line 79 of file spotlight.I.

Referenced by TinyGraphicsStateGuardian::bind_light(), DXGraphicsStateGuardian9::bind_light(), and DXGraphicsStateGuardian8::bind_light().

bool Spotlight::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 from Light.

Definition at line 158 of file spotlight.cxx.

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

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

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

Reimplemented from Camera.

Definition at line 100 of file spotlight.cxx.

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

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

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

Reimplemented from Camera.

Definition at line 301 of file spotlight.cxx.

References fillin().

Referenced by register_with_read_factory().

void Spotlight::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type Spotlight.

Reimplemented from Camera.

Definition at line 276 of file spotlight.cxx.

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

void Spotlight::set_attenuation ( const LVecBase3 attenuation) [inline]

Sets 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.

Definition at line 119 of file spotlight.I.

void Spotlight::set_exponent ( PN_stdfloat  exponent) [inline]

Sets the exponent that controls the amount of light falloff from the center of the spotlight.

The light is attenuated by the cosine of the angle between the direction of the light and the direction of the point being lighted, raised to the power of this exponent. Thus, higher exponents result in a more focused light source, regardless of the field-of-view of the lens.

Definition at line 67 of file spotlight.I.

void Spotlight::set_specular_color ( const LColor color) [inline]

Sets the color of specular highlights generated by the light.

Definition at line 91 of file spotlight.I.

void Spotlight::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 LightLensNode.

Definition at line 287 of file spotlight.cxx.

References BamWriter::write_cdata().

void Spotlight::xform ( const LMatrix4 mat) [virtual]

Transforms the contents of this PandaNode by the indicated matrix, if it means anything to do so.

For most kinds of PandaNodes, this does nothing.

Reimplemented from LensNode.

Definition at line 112 of file spotlight.cxx.

References Light::mark_viz_stale().


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