|
![](/i/fill.gif) |
Hmmm... It looks like the last two bytes were stripped from the MPEG
file. That's what I get for trying to hack a newsreader that does not
support posting of binary attachments. ;-) But I hope that most of
you will be able to play the animation without problems.
Although this will not be very useful until I release the source code
of my particle system, here is an excerpt from the scene file that I
used to generate the animation. I am posting the following lines of
code in order to explain what I mean by a procedural API (see my
message in p.a-v): the main scene file calls several macros that
perform some actions on the particles. Some of these macros can call
other user-defined macros, for example the macro pps_draw_particles()
calls the user-defined macro pps_user_draw_particle() several times.
Although this is not shown here, the macro pps_bounce() calls the
user-defined macro pps_user_hit_trigger() when a particle hits
something. This is what allows me to trigger a splash or some sparks
using a second and third particle system.
/* ... */
#declare pps_target_time = 8 * clock;
#declare pps_time_step = 0.01;
#if (clock = 0)
#declare pps_current_time = 0.0;
// [...] some stuff to create the boxes (particles + springs)
#else
pps_load_from_file ("springbox_state.txt")
#end
// this defines the environment: this is a CSG union on which the particles
// will bounce (one checkered plane and several spheres and cylinders)
#declare bounce_obj = union {
plane { y, 0
pigment { checker color rgb 0.2 color rgb 1 }
}
union {
// [...] several spheres and cylinders
}
}
// run the particle system simulation
#while (pps_iterate ())
pps_gravity (PPS_DEFAULT_GRAVITY)
pps_activate_springs ()
pps_bounce (bounce_obj, 0.95, 0.07, 0)
pps_move (0)
#end
pps_save_to_file ("springbox_state.txt")
#macro pps_user_draw_particle (index, p_pos, p_size, p_velocity, p_orient, p_color,
age)
sphere { p_pos, p_size }
#end
union {
pps_draw_particles ()
texture { T_Chrome_5D }
}
#macro pps_user_draw_spring (index, s_particle1, s_particle2, s_pos1, s_pos2,
s_size, s_color)
// [...] a bit too long to post here
#end
union {
pps_draw_springs ()
}
/* ... */
The other two particle systems (splash and sparks) use the same
structure as above, with slightly different actions in the main loop
of the simulation. For example, here is what I used for the sparks
(of course, I redefine pps_user_draw_particle() for the sparks):
#while (pps_iterate ())
pps_kill_old (sparks_max_age)
pps_gravity (PPS_DEFAULT_GRAVITY)
pps_viscous_drag (0.9, 0, 1e9)
pps_bounce (bounce_obj, 0.7, 0.05, 0)
pps_move (0)
#end
pps_save_to_file ("sparks_state.txt")
By the way, all macros are prefixed with "pps_", for "POV Particle
System" because when I started this project a long time ago I was not
aware of other efforts to create particle systems for POV-Ray. I am
wondering if I should rename this now that several of them are in
development... Comments are welcome (but maybe you should post your
comments in povray.advanced-users, which is more appropriate for
discussing this kind of comments).
--
http://www.gamers.org/~quinet/
Post a reply to this message
|
![](/i/fill.gif) |