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

#include "cMotionTrail.h"

Inheritance diagram for CMotionTrail:
TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

Public Types

typedef plist< CMotionTrailFrameFrameList
 
typedef epvector< CMotionTrailVertexVertexList
 

Public Member Functions

 CMotionTrail ()
 Constructor. More...
 
 ~CMotionTrail ()
 Destructor. More...
 
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. More...
 
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. More...
 
void add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v)
 Add a vertex. More...
 
void begin_geometry ()
 
int check_for_update (PN_stdfloat current_time)
 Check if a sample can be submitted. More...
 
void enable (bool enable)
 Enable/disable the motion trail. More...
 
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. More...
 
void reset_vertex_list ()
 Reset the vertex list. More...
 
void set_geom_node (GeomNode *geom_node)
 Set the GeomNode. More...
 
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. More...
 
void update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform)
 See class header comments. More...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
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. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

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
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns 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.

Definition at line 72 of file cMotionTrail.h.

Constructor & Destructor Documentation

◆ CMotionTrail()

CMotionTrail::CMotionTrail ( )

Constructor.

Definition at line 26 of file cMotionTrail.cxx.

◆ ~CMotionTrail()

CMotionTrail::~CMotionTrail ( )

Destructor.

Definition at line 72 of file cMotionTrail.cxx.

Member Function Documentation

◆ add_geometry_quad() [1/2]

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 222 of file cMotionTrail.cxx.

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

◆ add_geometry_quad() [2/2]

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 261 of file cMotionTrail.cxx.

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

◆ add_vertex()

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

Add a vertex.

Definition at line 112 of file cMotionTrail.cxx.

Referenced by add_geometry_quad().

◆ check_for_update()

int CMotionTrail::check_for_update ( PN_stdfloat  current_time)

Check if a sample can be submitted.

Definition at line 160 of file cMotionTrail.cxx.

◆ enable()

void CMotionTrail::enable ( bool  enable)

Enable/disable the motion trail.

Definition at line 96 of file cMotionTrail.cxx.

◆ reset()

void CMotionTrail::reset ( )

Reset the frame sample history.

Definition at line 80 of file cMotionTrail.cxx.

◆ reset_vertex_list()

void CMotionTrail::reset_vertex_list ( )

Reset the vertex list.

Definition at line 88 of file cMotionTrail.cxx.

◆ set_geom_node()

void CMotionTrail::set_geom_node ( GeomNode geom_node)

Set the GeomNode.

Definition at line 104 of file cMotionTrail.cxx.

◆ set_parameters()

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 146 of file cMotionTrail.cxx.

◆ update_motion_trail()

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

See class header comments.

Definition at line 320 of file cMotionTrail.cxx.


The documentation for this class was generated from the following files: