Panda3D
|
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"
Public Types | |
typedef plist< CMotionTrailFrame > | FrameList |
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 () |
void | begin_geometry (int num_quads) |
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 (GeomTriangles) _triangles | |
PT (GeomVertexData) _vertex_data | |
void | reset () |
Reset the frame sample history. | |
void | reset_vertex_list () |
Reset the vertex list. | |
void | set_geom_node (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. | |
![]() | |
TypedReferenceCount (const TypedReferenceCount ©) | |
void | operator= (const TypedReferenceCount ©) |
![]() | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. | |
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. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
TypedObject & | operator= (const TypedObject ©)=default |
![]() | |
void | operator delete (void *, void *) |
void | operator delete (void *ptr) |
void | operator delete[] (void *, void *) |
void | operator delete[] (void *ptr) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *ptr) |
void * | operator new[] (size_t size) |
void * | operator new[] (size_t size, void *ptr) |
![]() | |
int | get_ref_count () const |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
void | ref () const |
Explicitly increments the reference count. | |
bool | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
virtual bool | unref () const |
Explicitly decrements the reference count. | |
bool | unref_if_one () const |
Atomically decreases the reference count of this object if it is one. | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
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. | |
![]() | |
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 |
![]() | |
get_type | |
![]() | |
get_ref_count | |
Returns the current reference count. | |
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.
Definition at line 114 of file cMotionTrail.h.
typedef epvector<CMotionTrailVertex> CMotionTrail::VertexList |
Definition at line 112 of file cMotionTrail.h.
CMotionTrail::CMotionTrail | ( | ) |
Constructor.
Definition at line 34 of file cMotionTrail.cxx.
CMotionTrail::~CMotionTrail | ( | ) |
Destructor.
Definition at line 80 of file cMotionTrail.cxx.
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 271 of file cMotionTrail.cxx.
References GeomVertexWriter::set_data2(), GeomVertexWriter::set_data3(), and GeomVertexWriter::set_data4().
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 294 of file cMotionTrail.cxx.
References GeomVertexWriter::set_data2(), GeomVertexWriter::set_data3(), and GeomVertexWriter::set_data4().
void CMotionTrail::add_vertex | ( | LVector4 * | vertex, |
LVector4 * | start_color, | ||
LVector4 * | end_color, | ||
PN_stdfloat | v ) |
Add a vertex.
Definition at line 120 of file cMotionTrail.cxx.
void CMotionTrail::begin_geometry | ( | ) |
Definition at line 188 of file cMotionTrail.cxx.
void CMotionTrail::begin_geometry | ( | int | num_quads | ) |
Definition at line 196 of file cMotionTrail.cxx.
int CMotionTrail::check_for_update | ( | PN_stdfloat | current_time | ) |
Check if a sample can be submitted.
Definition at line 168 of file cMotionTrail.cxx.
void CMotionTrail::enable | ( | bool | enable | ) |
Enable/disable the motion trail.
Definition at line 104 of file cMotionTrail.cxx.
References enable().
Referenced by enable().
void CMotionTrail::end_geometry | ( | ) |
Definition at line 317 of file cMotionTrail.cxx.
|
inlinevirtual |
Reimplemented from TypedReferenceCount.
Definition at line 154 of file cMotionTrail.h.
|
inlinestatic |
Definition at line 143 of file cMotionTrail.h.
|
inlinevirtual |
Reimplemented from TypedReferenceCount.
Definition at line 151 of file cMotionTrail.h.
|
inlinestatic |
Definition at line 146 of file cMotionTrail.h.
void CMotionTrail::reset | ( | ) |
Reset the frame sample history.
Definition at line 88 of file cMotionTrail.cxx.
void CMotionTrail::reset_vertex_list | ( | ) |
Reset the vertex list.
Definition at line 96 of file cMotionTrail.cxx.
void CMotionTrail::set_geom_node | ( | GeomNode * | geom_node | ) |
Set the GeomNode.
Definition at line 112 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 154 of file cMotionTrail.cxx.
void CMotionTrail::update_motion_trail | ( | PN_stdfloat | current_time, |
LMatrix4 * | transform ) |
See class header comments.
Definition at line 340 of file cMotionTrail.cxx.
References add_geometry_quad().
int CMotionTrail::_active |
Definition at line 98 of file cMotionTrail.h.
int CMotionTrail::_calculate_relative_matrix |
Definition at line 123 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_color_scale |
Definition at line 118 of file cMotionTrail.h.
GeomVertexWriter CMotionTrail::_color_writer |
Definition at line 136 of file cMotionTrail.h.
int CMotionTrail::_enable |
Definition at line 99 of file cMotionTrail.h.
int CMotionTrail::_fade |
Definition at line 104 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_fade_color_scale |
Definition at line 108 of file cMotionTrail.h.
int CMotionTrail::_fade_end |
Definition at line 105 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_fade_start_time |
Definition at line 107 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_fade_time |
Definition at line 106 of file cMotionTrail.h.
FrameList CMotionTrail::_frame_list |
Definition at line 115 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_last_update_time |
Definition at line 110 of file cMotionTrail.h.
int CMotionTrail::_pause |
Definition at line 101 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_pause_time |
Definition at line 102 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_resolution_distance |
Definition at line 127 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_sampling_time |
Definition at line 119 of file cMotionTrail.h.
bool CMotionTrail::_square_t |
Definition at line 121 of file cMotionTrail.h.
GeomVertexWriter CMotionTrail::_texture_writer |
Definition at line 137 of file cMotionTrail.h.
PN_stdfloat CMotionTrail::_time_window |
Definition at line 120 of file cMotionTrail.h.
bool CMotionTrail::_use_nurbs |
Definition at line 126 of file cMotionTrail.h.
bool CMotionTrail::_use_texture |
Definition at line 122 of file cMotionTrail.h.
CMotionTrailVertex* CMotionTrail::_vertex_array |
Definition at line 140 of file cMotionTrail.h.
int CMotionTrail::_vertex_index |
Definition at line 133 of file cMotionTrail.h.
VertexList CMotionTrail::_vertex_list |
Definition at line 113 of file cMotionTrail.h.
GeomVertexWriter CMotionTrail::_vertex_writer |
Definition at line 135 of file cMotionTrail.h.