22 PStatCollector PointParticleRenderer::_render_collector(
"App:Particles:Point:Render");
29 PN_stdfloat point_size,
30 PointParticleBlendType bt,
31 ParticleRendererBlendMethod bm,
32 const LColor& sc,
const LColor& ec) :
34 _start_color(sc), _end_color(ec),
35 _blend_type(bt), _blend_method(bm)
37 set_point_size(point_size);
48 _blend_type = copy._blend_type;
49 _blend_method = copy._blend_method;
50 _start_color = copy._start_color;
51 _end_color = copy._end_color;
52 _point_size = copy._point_size;
75 void PointParticleRenderer::
76 resize_pool(
int new_size) {
77 if (new_size == _max_pool_size)
80 _max_pool_size = new_size;
88 void PointParticleRenderer::
94 _point_primitive = geom;
96 geom->add_primitive(_points);
100 render_node->
add_geom(_point_primitive, _render_state->add_attrib(_thick));
106 void PointParticleRenderer::
107 birth_particle(
int) {
113 void PointParticleRenderer::
120 LColor PointParticleRenderer::
123 PN_stdfloat life_t, vel_t;
124 PN_stdfloat parameterized_age = 1.0f;
125 bool have_alpha_t =
false;
127 switch (_blend_type) {
130 color = _start_color;
135 parameterized_age = p->get_parameterized_age();
136 life_t = parameterized_age;
139 if (_blend_method == PP_BLEND_CUBIC) {
140 life_t = CUBIC_T(life_t);
143 color = LERP(life_t, _start_color, _end_color);
148 vel_t = p->get_parameterized_vel();
150 if (_blend_method == PP_BLEND_CUBIC) {
151 vel_t = CUBIC_T(vel_t);
154 color = LERP(vel_t, _start_color, _end_color);
159 if (_alpha_mode != PR_ALPHA_NONE) {
160 if (_alpha_mode == PR_ALPHA_USER) {
161 parameterized_age = 1.0;
164 parameterized_age = p->get_parameterized_age();
167 if (_alpha_mode == PR_ALPHA_OUT) {
168 parameterized_age = 1.0f - parameterized_age;
169 }
else if (_alpha_mode == PR_ALPHA_IN_OUT) {
170 parameterized_age = 2.0f * std::min(parameterized_age,
171 1.0f - parameterized_age);
183 void PointParticleRenderer::
189 int remaining_particles = ttl_particles;
197 _aabb_min.set(99999.0f, 99999.0f, 99999.0f);
198 _aabb_max.set(-99999.0f, -99999.0f, -99999.0f);
202 for (i = 0; i < (int)po_vector.size(); i++) {
205 if (!cur_particle->get_alive())
212 if (position[0] > _aabb_max[0])
213 _aabb_max[0] = position[0];
214 else if (position[0] < _aabb_min[0])
215 _aabb_min[0] = position[0];
219 if (position[1] > _aabb_max[1])
220 _aabb_max[1] = position[1];
221 else if (position[1] < _aabb_min[1])
222 _aabb_min[1] = position[1];
226 if (position[2] > _aabb_max[2])
227 _aabb_max[2] = position[2];
228 else if (position[2] < _aabb_min[2])
229 _aabb_min[2] = position[2];
233 vertex.add_data3(position);
234 color.add_data4(create_color(cur_particle));
238 remaining_particles--;
239 if (remaining_particles == 0)
243 _points->clear_vertices();
244 _points->add_next_vertices(ttl_particles);
248 LPoint3 aabb_center = _aabb_min + ((_aabb_max - _aabb_min) * 0.5f);
249 PN_stdfloat radius = (aabb_center - _aabb_min).length();
252 _point_primitive->set_bounds(&sphere);
260 output(std::ostream &out)
const {
262 out<<
"PointParticleRenderer";
270 write(std::ostream &out,
int indent_level)
const {
271 indent(out, indent_level) <<
"PointParticleRenderer:\n";
272 indent(out, indent_level + 2) <<
"_start_color "<<_start_color<<
"\n";
273 indent(out, indent_level + 2) <<
"_end_color "<<_end_color<<
"\n";
274 indent(out, indent_level + 2) <<
"_point_size "<<_point_size<<
"\n";
275 indent(out, indent_level + 2) <<
"_point_primitive "<<_point_primitive<<
"\n";
276 indent(out, indent_level + 2) <<
"_max_pool_size "<<_max_pool_size<<
"\n";
277 indent(out, indent_level + 2) <<
"_blend_type "<<_blend_type<<
"\n";
278 indent(out, indent_level + 2) <<
"_blend_method "<<_blend_method<<
"\n";
279 indent(out, indent_level + 2) <<
"_aabb_min "<<_aabb_min<<
"\n";
280 indent(out, indent_level + 2) <<
"_aabb_max "<<_aabb_max<<
"\n";
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Pure virtual particle renderer base class.
GeomNode * get_render_node() const
Query the geomnode pointer.
PN_stdfloat get_user_alpha() const
gets alpha for "user" alpha mode
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
An individual, physically-modelable particle abstract base class.
This defines a bounding sphere, consisting of a center and a radius.
A node that holds Geom objects, renderable pieces of geometry.
void add_geom(Geom *geom, const RenderState *state=RenderState::make_empty())
Adds a new Geom to the node.
void remove_all_geoms()
Removes all the geoms from the node at once.
Defines a series of disconnected points.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
A container for geometry primitives.
A lightweight class that represents a single element that may be timed and/or counted via stats.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
A body on which physics will be applied.
get_position
Position Query.
Simple point/point particle renderer.
virtual void write(std::ostream &out, int indent_level=0) const
Write a string representation of this instance to <out>.
virtual ~PointParticleRenderer()
Simple destructor.
PointParticleRenderer(const PointParticleRenderer ©)
Copy constructor.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual BaseParticleRenderer * make_copy()
for spawning systems from dead particles
This is our own Panda specialization on the default STL vector.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.