00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CMOTIONTRAIL_H
00016 #define CMOTIONTRAIL_H
00017
00018 #include "directbase.h"
00019
00020 #include "geomNode.h"
00021 #include "geomVertexData.h"
00022 #include "geomVertexWriter.h"
00023 #include "geomTriangles.h"
00024 #include "luse.h"
00025 #include "nurbsCurveEvaluator.h"
00026 #include "plist.h"
00027 #include "pvector.h"
00028
00029 class CMotionTrailVertex {
00030 public:
00031 LPoint4 _vertex;
00032 LVecBase4 _start_color;
00033 LVecBase4 _end_color;
00034 PN_stdfloat _v;
00035
00036 PT(NurbsCurveEvaluator) _nurbs_curve_evaluator;
00037 };
00038
00039 class CMotionTrailFrame {
00040 public:
00041 UnalignedLMatrix4 _transform;
00042 PN_stdfloat _time;
00043 };
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 class EXPCL_DIRECT CMotionTrail : public TypedReferenceCount {
00087
00088 PUBLISHED:
00089
00090 CMotionTrail ( );
00091 ~CMotionTrail ( );
00092
00093 void reset ( );
00094 void reset_vertex_list ( );
00095
00096 void enable (bool enable);
00097
00098 void set_geom_node (PT(GeomNode) geom_node);
00099 void add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v);
00100
00101 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);
00102
00103 int check_for_update (PN_stdfloat current_time);
00104 void update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform);
00105
00106 public:
00107
00108 void begin_geometry ( );
00109 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);
00110 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);
00111 void end_geometry ( );
00112
00113 int _active;
00114 int _enable;
00115
00116 int _pause;
00117 PN_stdfloat _pause_time;
00118
00119 int _fade;
00120 int _fade_end;
00121 PN_stdfloat _fade_time;
00122 PN_stdfloat _fade_start_time;
00123 PN_stdfloat _fade_color_scale;
00124
00125 PN_stdfloat _last_update_time;
00126
00127 typedef epvector<CMotionTrailVertex> VertexList;
00128 VertexList _vertex_list;
00129 typedef plist<CMotionTrailFrame> FrameList;
00130 FrameList _frame_list;
00131
00132
00133 PN_stdfloat _color_scale;
00134 PN_stdfloat _sampling_time;
00135 PN_stdfloat _time_window;
00136 bool _square_t;
00137 bool _use_texture;
00138 int _calculate_relative_matrix;
00139
00140
00141 bool _use_nurbs;
00142 PN_stdfloat _resolution_distance;
00143
00144
00145 PT(GeomNode) _geom_node;
00146
00147
00148 int _vertex_index;
00149 PT(GeomVertexData) _vertex_data;
00150 GeomVertexWriter _vertex_writer;
00151 GeomVertexWriter _color_writer;
00152 GeomVertexWriter _texture_writer;
00153 PT(GeomTriangles) _triangles;
00154
00155 CMotionTrailVertex *_vertex_array;
00156
00157 public:
00158 static TypeHandle get_class_type() {
00159 return _type_handle;
00160 }
00161 static void init_type() {
00162 TypedReferenceCount::init_type();
00163 register_type(_type_handle, "CMotionTrail",
00164 TypedReferenceCount::get_class_type());
00165 }
00166 virtual TypeHandle get_type() const {
00167 return get_class_type();
00168 }
00169 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00170
00171 private:
00172 static TypeHandle _type_handle;
00173
00174 };
00175
00176 #endif