We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Help with Physics
Page Index Toggle Pages: 1
Help with Physics (Read 895 times)
Help with Physics
Nov 11th, 2006, 1:23am
 
I am trying to make a whole bunch of particles and then add springs as well as repulsion based on the Arboretum example. My problem comes with adding the repulsion to each of the particles. I keep getting NullPointerException errors accuring at random. What could be going wrong with this bit of code:

void addSpacersToNode( Particle p, Particle r )
{
 for ( int i = 0; i < physics.numberOfParticles(); ++i )
 {
   Particle q = physics.getParticle( i );
   if ( p != q && p != r )
     physics.makeAttraction( p, q, -SPACER_STRENGTH, 20 );
 }
}


Error messages:

java.lang.NullPointerException

at traer.physics.ParticleSystem.cleanUp(ParticleSystem.java:158)

at traer.physics.ParticleSystem.tick(ParticleSystem.java:47)

at Temporary_8936_1760.draw(Temporary_8936_1760.java:87)

at processing.core.PApplet.handleDisplay(PApplet.java:1314)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1409)

at java.lang.Thread.run(Thread.java:613)


Please help me out. Thanks
Page Index Toggle Pages: 1