Get particle positions

#1 · closed · 3 comments

View on GitHub ↗

joquist

Is it possible to iterate through a particle system to get particle information like position and velocity? I'd like to implement boundary detection, as well a try out different rendering techniques (replacing particles with other shapes/colors/sizes/etc). Thanks-

Comments

diwi

yes you can access all particle-data and add your own callbacks/listeners etc... via the world instance, like the following code-snippet: (copied from: https://github.com/diwi/LiquidFunProcessing/blob/master/src/com/thomasdiewald/liquidfun/java/render/DwParticleRender.java#L87) ``` // particle data particle_num = world.getParticleCount(); particle_rad_world = world.getParticleRadius(); Vec2[] particle_pos = world.getParticlePositionBuffer(); Vec2[] particle_vel = world.getParticleVelocityBuffer(); ParticleColor[] particle_col = world.getParticleColorBuffer(); ParticleContact[] particle_con = world.getParticleContacts(); int particle_con_count = world.getParticleContactCount(); ```

diwi

here is the full reference for jbox2d: http://thomasdiewald.com/processing/libraries/jbox2d-2.3.0/doc/index.html

joquist

Thanks for the quick reply! This is really useful-