diff --git a/panda/src/particlesystem/lineParticleRenderer.I b/panda/src/particlesystem/lineParticleRenderer.I index 3c2d6438db..965d024406 100644 --- a/panda/src/particlesystem/lineParticleRenderer.I +++ b/panda/src/particlesystem/lineParticleRenderer.I @@ -51,3 +51,22 @@ INLINE const Colorf& LineParticleRenderer:: get_tail_color() const { return _tail_color; } + +//////////////////////////////////////////////////////////////////// +// Function : set_line_scale_factor +// Description : accessor +//////////////////////////////////////////////////////////////////// +INLINE void LineParticleRenderer:: +set_line_scale_factor(float sf) { + _line_scale_factor = sf; +} + +//////////////////////////////////////////////////////////////////// +// Function : get_line_scale_factor +// Description : accessor +//////////////////////////////////////////////////////////////////// +INLINE float LineParticleRenderer:: +get_line_scale_factor() const { + return _line_scale_factor; +} + diff --git a/panda/src/particlesystem/lineParticleRenderer.cxx b/panda/src/particlesystem/lineParticleRenderer.cxx index 58f27f7832..6bd09f97c1 100644 --- a/panda/src/particlesystem/lineParticleRenderer.cxx +++ b/panda/src/particlesystem/lineParticleRenderer.cxx @@ -34,6 +34,8 @@ LineParticleRenderer() : _head_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)), _tail_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)) { + _line_scale_factor = 1.0f; + resize_pool(0); } @@ -243,14 +245,19 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { if (use_qpgeom) { vertex.add_data3f(position); - vertex.add_data3f(cur_particle->get_last_position()); + LPoint3f last_position = position + + (cur_particle->get_last_position() - position) * _line_scale_factor; + vertex.add_data3f(last_position); color.add_data4f(head_color); color.add_data4f(tail_color); _lines->add_next_vertices(2); _lines->close_primitive(); } else { + LPoint3f last_position = position + + (cur_particle->get_last_position() - position) * _line_scale_factor; + *cur_vert++ = position; - *cur_vert++ = cur_particle->get_last_position(); + *cur_vert++ = last_position; *cur_color++ = head_color; *cur_color++ = tail_color; diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index 3bdb093b13..3600ae71d2 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -52,6 +52,9 @@ PUBLISHED: INLINE const Colorf& get_head_color() const; INLINE const Colorf& get_tail_color() const; + INLINE void set_line_scale_factor(float sf); + INLINE float get_line_scale_factor() const; + virtual void output(ostream &out) const; virtual void write(ostream &out, int indent=0) const; @@ -71,6 +74,8 @@ private: LPoint3f _aabb_min; LPoint3f _aabb_max; + float _line_scale_factor; + virtual void birth_particle(int index); virtual void kill_particle(int index); virtual void init_geoms();