Panda3D
|
This effect automatically applies a computed texture matrix to the specified texture stage, according to the relative position of two specified nodes. More...
#include "texProjectorEffect.h"
Classes | |
class | StageDef |
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 (RenderEffect) add_stage(TextureStage *stage | |
CPT (RenderEffect) remove_stage(TextureStage *stage) const | |
virtual void | cull_callback (CullTraverser *trav, CullTraverserData &data, CPT(TransformState)&node_transform, CPT(RenderState)&node_state) const |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
NodePath | get_from (TextureStage *stage) const |
Returns the "from" node associated with the TexProjectorEffect on the indicated stage. | |
NodePath | get_to (TextureStage *stage) const |
Returns the "to" node associated with the TexProjectorEffect on the indicated stage. | |
virtual TypeHandle | get_type () const |
virtual bool | has_cull_callback () const |
Should be overridden by derived classes to return true if cull_callback() has been defined. | |
bool | has_stage (TextureStage *stage) const |
Returns true if there is a transform associated with the indicated stage, or false otherwise (in which case get_transform(stage) will return the identity transform). | |
bool | is_empty () const |
Returns true if no stages are defined in the TexProjectorEffect, false if at least one is. | |
virtual void | output (ostream &out) 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 (RenderEffect) make() |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type TexProjectorEffect. | |
Public Attributes | |
const NodePath const NodePath &to | const |
const NodePath & | from |
Protected Member Functions | |
TexProjectorEffect () | |
Use TexProjectorEffect::make() to construct a new TexProjectorEffect object. | |
TexProjectorEffect (const TexProjectorEffect ©) | |
Use TexProjectorEffect::make() to construct a new TexProjectorEffect object. | |
virtual int | compare_to_impl (const RenderEffect *other) const |
Intended to be overridden by derived TexProjectorEffect types to return a unique number indicating whether this TexProjectorEffect is equivalent to the other one. | |
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 TexProjectorEffect. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type TexProjectorEffect is encountered in the Bam file. |
This effect automatically applies a computed texture matrix to the specified texture stage, according to the relative position of two specified nodes.
The relative transform from the "from" node to the "to" node is applied directly to the texture matrix each frame. If the "to" node happens to be a LensNode, its lens projection matrix is applied as well.
This can be used to apply a number of special effects. Fundamentally, it may simply be used to provide a separate PandaNode that may be adjusted (e.g. via a LerpInterval) in order to easily apply a linear transformation to an object's texture coordinates (rather than having to explicitly call NodePath.set_tex_transform() each frame).
In a more sophisticated case, the TexProjectorEffect is particularly useful in conjunction with a TexGenAttrib that specifies a mode of M_world_position (which copies the world position of each vertex to the texture coordinates). Then the TexProjector can be used to convert these world coordinates to the relative coordinates of a particular node, causing (for instance) a texture to appear to follow a node around as it moves through the world. With a LensNode, you can project a texture onto the walls, for instance to apply a flashlight effect or an image-based shadow.
Definition at line 59 of file texProjectorEffect.h.
TexProjectorEffect::TexProjectorEffect | ( | ) | [inline, protected] |
Use TexProjectorEffect::make() to construct a new TexProjectorEffect object.
Definition at line 23 of file texProjectorEffect.I.
Referenced by make_from_bam().
TexProjectorEffect::TexProjectorEffect | ( | const TexProjectorEffect & | copy | ) | [inline, protected] |
Use TexProjectorEffect::make() to construct a new TexProjectorEffect object.
Definition at line 33 of file texProjectorEffect.I.
int TexProjectorEffect::compare_to_impl | ( | const RenderEffect * | other | ) | const [protected, virtual] |
Intended to be overridden by derived TexProjectorEffect types to return a unique number indicating whether this TexProjectorEffect is equivalent to the other one.
This should return 0 if the two TexProjectorEffect 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 TexProjectorEffect objects whose get_type() functions return the same.
Reimplemented from RenderEffect.
Definition at line 264 of file texProjectorEffect.cxx.
int TexProjectorEffect::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 345 of file texProjectorEffect.cxx.
void TexProjectorEffect::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data, | ||
CPT(TransformState)& | node_transform, | ||
CPT(RenderState)& | node_state | ||
) | const [virtual] |
If has_cull_callback() returns true, this function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
At the time this function is called, the current node's transform and state have not yet been applied to the net_transform and net_state. This callback may modify the node_transform and node_state to apply an effective change to the render state at this level.
Reimplemented from RenderEffect.
Definition at line 204 of file texProjectorEffect.cxx.
void TexProjectorEffect::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 TexProjectorEffect.
Reimplemented from RenderEffect.
Definition at line 379 of file texProjectorEffect.cxx.
References DatagramIterator::get_uint16().
Referenced by make_from_bam().
NodePath TexProjectorEffect::get_from | ( | TextureStage * | stage | ) | const |
Returns the "from" node associated with the TexProjectorEffect on the indicated stage.
The relative transform between the "from" and the "to" nodes is automatically applied to the texture transform each frame.
Definition at line 128 of file texProjectorEffect.cxx.
References NodePath::fail().
Referenced by NodePath::get_tex_projector_from().
NodePath TexProjectorEffect::get_to | ( | TextureStage * | stage | ) | const |
Returns the "to" node associated with the TexProjectorEffect on the indicated stage.
The relative transform between the "from" and the "to" nodes is automatically applied to the texture transform each frame.
Furthermore, if the "to" node is a LensNode, its projection matrix is also applied to the texture transform.
Definition at line 148 of file texProjectorEffect.cxx.
References NodePath::fail().
Referenced by NodePath::get_tex_projector_to().
bool TexProjectorEffect::has_cull_callback | ( | ) | const [virtual] |
Should be overridden by derived classes to return true if cull_callback() has been defined.
Otherwise, returns false to indicate cull_callback() does not need to be called for this effect during the cull traversal.
Reimplemented from RenderEffect.
Definition at line 182 of file texProjectorEffect.cxx.
bool TexProjectorEffect::has_stage | ( | TextureStage * | stage | ) | const |
Returns true if there is a transform associated with the indicated stage, or false otherwise (in which case get_transform(stage) will return the identity transform).
Definition at line 113 of file texProjectorEffect.cxx.
Referenced by NodePath::has_tex_projector().
bool TexProjectorEffect::is_empty | ( | ) | const |
Returns true if no stages are defined in the TexProjectorEffect, false if at least one is.
Definition at line 100 of file texProjectorEffect.cxx.
TypedWritable * TexProjectorEffect::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type TexProjectorEffect is encountered in the Bam file.
It should create the TexProjectorEffect and extract its information from the file.
Definition at line 360 of file texProjectorEffect.cxx.
References fillin(), and TexProjectorEffect().
Referenced by register_with_read_factory().
void TexProjectorEffect::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type TexProjectorEffect.
Definition at line 311 of file texProjectorEffect.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from RenderEffect.
Definition at line 322 of file texProjectorEffect.cxx.
References Datagram::add_uint16().