from panda3d.direct import CMotionTrail
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
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.
addVertex(vertex: panda3d.core.LVector4, start_color: panda3d.core.LVector4, end_color: panda3d.core.LVector4, v: float)¶
Add a vertex.
Reset the frame sample history.
Reset the vertex list.
setParameters(sampling_time: float, time_window: float, use_texture: bool, calculate_relative_matrix: bool, use_nurbs: bool, resolution_distance: float)¶
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.