mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Added line scale factor to line renderer
This commit is contained in:
parent
ae9d2a3d02
commit
c3420d3985
@ -51,3 +51,22 @@ INLINE const Colorf& LineParticleRenderer::
|
|||||||
get_tail_color() const {
|
get_tail_color() const {
|
||||||
return _tail_color;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ LineParticleRenderer() :
|
|||||||
_head_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
|
_head_color(Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
|
||||||
_tail_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);
|
resize_pool(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,14 +245,19 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) {
|
|||||||
|
|
||||||
if (use_qpgeom) {
|
if (use_qpgeom) {
|
||||||
vertex.add_data3f(position);
|
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(head_color);
|
||||||
color.add_data4f(tail_color);
|
color.add_data4f(tail_color);
|
||||||
_lines->add_next_vertices(2);
|
_lines->add_next_vertices(2);
|
||||||
_lines->close_primitive();
|
_lines->close_primitive();
|
||||||
} else {
|
} else {
|
||||||
|
LPoint3f last_position = position +
|
||||||
|
(cur_particle->get_last_position() - position) * _line_scale_factor;
|
||||||
|
|
||||||
*cur_vert++ = position;
|
*cur_vert++ = position;
|
||||||
*cur_vert++ = cur_particle->get_last_position();
|
*cur_vert++ = last_position;
|
||||||
|
|
||||||
*cur_color++ = head_color;
|
*cur_color++ = head_color;
|
||||||
*cur_color++ = tail_color;
|
*cur_color++ = tail_color;
|
||||||
|
@ -52,6 +52,9 @@ PUBLISHED:
|
|||||||
INLINE const Colorf& get_head_color() const;
|
INLINE const Colorf& get_head_color() const;
|
||||||
INLINE const Colorf& get_tail_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 output(ostream &out) const;
|
||||||
virtual void write(ostream &out, int indent=0) const;
|
virtual void write(ostream &out, int indent=0) const;
|
||||||
|
|
||||||
@ -71,6 +74,8 @@ private:
|
|||||||
LPoint3f _aabb_min;
|
LPoint3f _aabb_min;
|
||||||
LPoint3f _aabb_max;
|
LPoint3f _aabb_max;
|
||||||
|
|
||||||
|
float _line_scale_factor;
|
||||||
|
|
||||||
virtual void birth_particle(int index);
|
virtual void birth_particle(int index);
|
||||||
virtual void kill_particle(int index);
|
virtual void kill_particle(int index);
|
||||||
virtual void init_geoms();
|
virtual void init_geoms();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user