00001 /* -*- C++ -*- */ 00002 00003 /* COPYRIGHT 00004 * 00005 * This file is part of the Visual Effects Engine - VEE 00006 * 00007 * Read the "VEE-LICENSE" file for the license. 00008 * 00009 * Authors & Copyright: 00010 * 00011 * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 00012 * Janne Kontkanen 2001-2004 00013 * 00014 * Additional copyrights: Tekes 2003-2004 00015 * 00016 * firstname.lastname@hut.fi 00017 * 00018 */ 00019 00020 #ifndef VEE_TAIL_PARTICLE_H 00021 #define VEE_TAIL_PARTICLE_H 00022 00023 #include <vee_particle.h> 00024 #include <vee_math.h> 00025 00026 #include <mj_ringbuffer.h> 00027 00029 class VEE_TailParticle : public VEE_Particle 00030 { 00031 public: 00032 VEE_TailParticle(); 00033 virtual ~VEE_TailParticle(); 00034 00035 virtual bool setValue(const char *, VEE_Value *); 00036 virtual VEE_Variable getVariable(const char *) const; 00037 00038 virtual void update(float); 00039 00040 virtual VEE_Object *clone() const; 00041 static VEE_Object * factory(); 00042 00043 virtual void resizeTail(uint); 00044 00045 uint pointsToRender() const 00046 { return VEE_min((uint) m_points.getSampleCount(), (uint) (m_nofPoints)); } 00047 00048 class Point { 00049 public: 00050 00051 VEE_Rgba & color() { return m_color; } 00052 const VEE_Rgba & color() const { return m_color; } 00053 00054 VEE_Vector3 & location() { return m_location; } 00055 const VEE_Vector3 & location() const { return m_location; } 00056 00057 VEE_Vector3 & velocity() { return m_velocity; } 00058 const VEE_Vector3 & velocity() const { return m_velocity; } 00059 00060 VEE_Vector3 m_location; 00061 VEE_Vector3 m_velocity; 00062 VEE_Rgba m_color; 00063 }; 00064 00065 Point & getDelayedPoint(uint delay) 00066 { return m_points.getNewest(delay); } 00067 00068 const Point & getDelayedPoint(uint delay) const 00069 { return m_points.getNewest(delay); } 00070 00071 // typedef std::vector<Point>::iterator iterator; 00072 00073 00074 protected: 00075 00076 MJ_RingBufferDelay<Point> m_points; 00077 00078 uint m_nofPoints; 00079 float m_dtSum; 00080 // float m_threshold; 00081 00082 VEE_Vector3 m_prevLocation; 00083 }; 00084 00087 00090 class VEE_TailParticle2 : public VEE_TailParticle 00091 { 00092 public: 00093 VEE_TailParticle2(); 00094 virtual ~VEE_TailParticle2(); 00095 00096 virtual bool setValue(const char *, VEE_Value *); 00097 virtual VEE_Variable getVariable(const char *) const; 00098 00099 virtual void update(float); 00100 00101 virtual VEE_Object *clone() const; 00102 static VEE_Object * factory(); 00103 00104 virtual void resizeTail(uint); 00105 00106 class Link { 00107 public: 00108 float m_distance; 00109 }; 00110 00111 protected: 00112 00113 MJ_RingBufferDelay<Link> m_links; 00114 00115 float m_springConstant; 00116 float m_tailForceAttenuation; 00117 00118 }; 00119 00122 00125 class VEE_TailParticle3 : public VEE_TailParticle 00126 { 00127 public: 00128 VEE_TailParticle3(); 00129 virtual ~VEE_TailParticle3(); 00130 00131 virtual bool setValue(const char *, VEE_Value *); 00132 virtual VEE_Variable getVariable(const char *) const; 00133 00134 virtual void update(float); 00135 00136 virtual VEE_Object *clone() const; 00137 static VEE_Object * factory(); 00138 00139 protected: 00140 00141 float m_velocityScale; 00142 }; 00143 00144 #endif