Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes
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...

#include "cMotionTrail.h"

Inheritance diagram for CMotionTrail:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Types

typedef plist< CMotionTrailFrameFrameList
typedef epvector
< CMotionTrailVertex
VertexList

Public Member Functions

 CMotionTrail ()
 Constructor.
 ~CMotionTrail ()
 Destructor.
void add_geometry_quad (LVector3 &v0, LVector3 &v1, LVector3 &v2, LVector3 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3)
 LVector3 vertex version.
void add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3)
 LVector4 vertex version.
void add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v)
 Add a vertex.
void begin_geometry ()
int check_for_update (PN_stdfloat current_time)
 Check if a sample can be submitted.
void enable (bool enable)
 Enable/disable the motion trail.
void end_geometry ()
virtual TypeHandle force_init_type ()
virtual TypeHandle get_type () const
 PT (GeomNode) _geom_node
 PT (GeomVertexData) _vertex_data
 PT (GeomTriangles) _triangles
void reset ()
 Reset the frame sample history.
void reset_vertex_list ()
 Reset the vertex list.
void set_geom_node (PT(GeomNode) geom_node)
 Set the GeomNode.
void set_parameters (PN_stdfloat sampling_time, PN_stdfloat time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, PN_stdfloat resolution_distance)
 Set motion trail parameters.
void update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform)
 See class header comments.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.

Public Attributes

int _active
int _calculate_relative_matrix
PN_stdfloat _color_scale
GeomVertexWriter _color_writer
int _enable
int _fade
PN_stdfloat _fade_color_scale
int _fade_end
PN_stdfloat _fade_start_time
PN_stdfloat _fade_time
FrameList _frame_list
PN_stdfloat _last_update_time
int _pause
PN_stdfloat _pause_time
PN_stdfloat _resolution_distance
PN_stdfloat _sampling_time
bool _square_t
GeomVertexWriter _texture_writer
PN_stdfloat _time_window
bool _use_nurbs
bool _use_texture
CMotionTrailVertex_vertex_array
int _vertex_index
VertexList _vertex_list
GeomVertexWriter _vertex_writer

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.

Definition at line 86 of file cMotionTrail.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 29 of file cMotionTrail.cxx.

Destructor.

Definition at line 77 of file cMotionTrail.cxx.


Member Function Documentation

void CMotionTrail::add_geometry_quad ( LVector3 v0,
LVector3 v1,
LVector3 v2,
LVector3 v3,
LVector4 c0,
LVector4 c1,
LVector4 c2,
LVector4 c3,
LVector2 t0,
LVector2 t1,
LVector2 t2,
LVector2 t3 
)

LVector3 vertex version.

Definition at line 249 of file cMotionTrail.cxx.

References GeomVertexWriter::add_data2(), GeomVertexWriter::add_data3(), GeomVertexWriter::add_data4(), and add_vertex().

Referenced by update_motion_trail().

void CMotionTrail::add_geometry_quad ( LVector4 v0,
LVector4 v1,
LVector4 v2,
LVector4 v3,
LVector4 c0,
LVector4 c1,
LVector4 c2,
LVector4 c3,
LVector2 t0,
LVector2 t1,
LVector2 t2,
LVector2 t3 
)

LVector4 vertex version.

Definition at line 290 of file cMotionTrail.cxx.

References GeomVertexWriter::add_data2(), GeomVertexWriter::add_data3(), GeomVertexWriter::add_data4(), and add_vertex().

void CMotionTrail::add_vertex ( LVector4 vertex,
LVector4 start_color,
LVector4 end_color,
PN_stdfloat  v 
)

Add a vertex.

Definition at line 127 of file cMotionTrail.cxx.

Referenced by add_geometry_quad().

int CMotionTrail::check_for_update ( PN_stdfloat  current_time)

Check if a sample can be submitted.

Definition at line 183 of file cMotionTrail.cxx.

void CMotionTrail::enable ( bool  enable)

Enable/disable the motion trail.

Definition at line 107 of file cMotionTrail.cxx.

static void CMotionTrail::init_type ( ) [inline, static]

This function is declared non-inline to work around a compiler bug in g++ 2.96.

Making it inline seems to cause problems in the optimizer.

Reimplemented from TypedReferenceCount.

Definition at line 161 of file cMotionTrail.h.

References TypedReferenceCount::init_type().

Reset the frame sample history.

Definition at line 87 of file cMotionTrail.cxx.

Referenced by update_motion_trail().

Reset the vertex list.

Definition at line 97 of file cMotionTrail.cxx.

void CMotionTrail::set_geom_node ( PT(GeomNode geom_node)

Set the GeomNode.

Definition at line 117 of file cMotionTrail.cxx.

void CMotionTrail::set_parameters ( PN_stdfloat  sampling_time,
PN_stdfloat  time_window,
bool  use_texture,
bool  calculate_relative_matrix,
bool  use_nurbs,
PN_stdfloat  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.

Definition at line 167 of file cMotionTrail.cxx.

void CMotionTrail::update_motion_trail ( PN_stdfloat  current_time,
LMatrix4 transform 
)

See class header comments.

Definition at line 353 of file cMotionTrail.cxx.

References add_geometry_quad(), LMatrix4f::invert_in_place(), LVecBase3f::length(), reset(), and LMatrix4f::xform().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations