# TexProjectorEffect¶

class TexProjectorEffect

Bases: RenderEffect

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

Inheritance diagram

ConstPointerTo<RenderEffect> add_stage(TextureStage *stage, NodePath const &from, NodePath const &to, int lens_index = 0) const

Returns a new TexProjectorEffect just like this one, with the indicated projection for the given stage. If this stage already exists, its projection definition is replaced.

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. In this case, the lens_index may be used to select the particular lens that should be used.

static TypeHandle get_class_type(void)
NodePath 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.

int get_lens_index(TextureStage *stage) const

Returns the lens_index associated with the TexProjectorEffect on the indicated stage. This is only used if the “to” node is a LensNode, in which case it specifies the particular lens that should be used.

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

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(void) const

Returns true if no stages are defined in the TexProjectorEffect, false if at least one is.

static ConstPointerTo<RenderEffect> make(void)

Constructs a TexProjectorEffect that modifies no stages at all.

ConstPointerTo<RenderEffect> remove_stage(TextureStage *stage) const

Returns a new TexProjectorEffect just like this one, with the indicated stage removed.