Panda3D
Public Member Functions | Static Public Member Functions | List of all members
CMotionTrail Class Reference

The method used in creating the motion trail is based on taking samples of time and transformations (the position and orientation matrix) in real- time. More...

Inheritance diagram for CMotionTrail:
TypedReferenceCount TypedObject ReferenceCount

Public Member Functions

 __init__ ()
 Constructor. More...
 
 __init__ (const CMotionTrail)
 
 addVertex (LVector4 vertex, LVector4 start_color, LVector4 end_color, float v)
 Add a vertex. More...
 
int checkForUpdate (float current_time)
 Check if a sample can be submitted. More...
 
 enable (bool enable)
 Enable/disable the motion trail. More...
 
 reset ()
 Reset the frame sample history. More...
 
 resetVertexList ()
 Reset the vertex list. More...
 
 setGeomNode (GeomNode geom_node)
 Set the GeomNode. More...
 
 setParameters (float sampling_time, float time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, float resolution_distance)
 Set motion trail parameters. More...
 
 updateMotionTrail (float current_time, LMatrix4 transform)
 See class header comments. More...
 
- Public Member Functions inherited from TypedObject
TypeHandle getType ()
 
int getTypeIndex ()
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool isExactType (TypeHandle handle)
 Returns true if the current object is the indicated type exactly. More...
 
bool isOfType (TypeHandle handle)
 Returns true if the current object is or derives from the indicated type. More...
 
- Public Member Functions inherited from ReferenceCount
int getRefCount ()
 Returns the current reference count. More...
 
 ref ()
 Explicitly increments the reference count. More...
 
bool testRefCountIntegrity ()
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool testRefCountNonzero ()
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
bool unref ()
 Explicitly decrements the reference count. More...
 

Static Public Member Functions

static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle getClassType ()
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle getClassType ()
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
TypeHandle type
 Returns the TypeHandle representing this object's type. More...
 
- Public Attributes inherited from ReferenceCount
int ref_count
 The current reference count. More...
 

Detailed Description

The method used in creating the motion trail is based on taking samples of time and transformations (the position and orientation matrix) in real- time.

The method also requires a number of vertices (positions) that determines "shape" of the motion trail (i.e. the edge of a blade). A start color and end color is also required for each vertex. The color is interpolated as function of time. The colors are typically used to fade the motion trail so the end color is typically black.

The vertices are submitted via the "add_vertex" function. For each frame, a sample is submited via the "update_motion_trail" function. During the "update_motion_trail" function, the motion trail geometry is created dynamically from the sample history and the vertices.

The user must specifiy a GeomNode via "set_geom_node".

The duration of the sample history is specified by a time window. A larger time window creates longer motion trails (given constant speed). Samples that are no longer within the time window are automatically discarded.

The nurbs option can be used to create smooth interpolated curves from the samples. The nurbs option is useful for animations that lack sampling to begin with, animations that move very quickly, or low frame rates.

The texture option be used to create variation to the motion trail. The u coordinate of the texture corresponds to time and the v coordinate corresponds to the "shape" of the motion trail.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( )

Constructor.

◆ __init__() [2/2]

__init__ ( const  CMotionTrail)

◆ addVertex()

addVertex ( LVector4  vertex,
LVector4  start_color,
LVector4  end_color,
float  v 
)

Add a vertex.

◆ checkForUpdate()

int checkForUpdate ( float  current_time)

Check if a sample can be submitted.

◆ enable()

enable ( bool  enable)

Enable/disable the motion trail.

◆ getClassType()

static TypeHandle getClassType ( )
static

◆ reset()

reset ( )

Reset the frame sample history.

◆ resetVertexList()

resetVertexList ( )

Reset the vertex list.

◆ setGeomNode()

setGeomNode ( GeomNode  geom_node)

Set the GeomNode.

◆ setParameters()

setParameters ( float  sampling_time,
float  time_window,
bool  use_texture,
bool  calculate_relative_matrix,
bool  use_nurbs,
float  resolution_distance 
)

Set motion trail parameters.

sampling_time = Can be used to specify a lower sampling rate than the frame rate. Use 0.0 with nurbs.

time_window = a component for the "length" of the motion trail. The motion trail length = time_window * velocity of the object.

use_texture = texture option on/off.

calculate_relative_matrix = calculate relative matrix on/off.

use_nurbs = nurbs option on/off

resolution_distance = the distance used to determine the number of geometry samples. samples = motion trail length / resolution_distance. Applicable only if nurbs is on.

◆ updateMotionTrail()

updateMotionTrail ( float  current_time,
LMatrix4  transform 
)

See class header comments.