TexProjectorEffect

from panda3d.core import TexProjectorEffect
class TexProjectorEffect

Bases:

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 NodePath.setTexTransform() 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

Inheritance diagram of TexProjectorEffect

addStage(stage: TextureStage, from: NodePath, to: NodePath, lens_index: int) RenderEffect

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 getClassType() TypeHandle
getFrom(stage: TextureStage) NodePath

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.

getLensIndex(stage: TextureStage) int

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.

getTo(stage: TextureStage) NodePath

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.

hasStage(stage: TextureStage) bool

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

isEmpty() bool

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

static make() RenderEffect

Constructs a TexProjectorEffect that modifies no stages at all.

removeStage(stage: TextureStage) RenderEffect

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