Added line scale factor to line renderer

This commit is contained in:
Mark Mine 2005-04-09 01:38:33 +00:00
parent ae9d2a3d02
commit c3420d3985
3 changed files with 33 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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();