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 & HelpSyntax Questions › my fireballs aint working...
Page Index Toggle Pages: 1
my fireballs aint working... (Read 401 times)
my fireballs aint working...
Mar 13th, 2008, 6:00am
 
like many beginners learning processing, i m starting to play with perlin noise to simulate flocking...

but the end result looks like the balls r just bouncing...

heres the vid cap of the code:
http://www.youtube.com/watch?v=jy0hr5ftRoA

heres the main code that does the bounce:

**************************************
//flip the direction if ball position hits bound box
if(abs(pos.x)>840) flipX = flipX*-1;
if(abs(pos.y)>840) flipY = flipY*-1;
if(abs(pos.z)>840) flipZ = flipZ*-1;

//get noise val at current position
float origin = noise(pos.x,pos.y,pos.z);

//calulate delta in x,y,z direction using noise value around
//the current position, then cos interpolate
float deltaX = interpolate(noise(pos.x+.1,pos.y,pos.z),origin, .5);
float deltaY = interpolate(noise(pos.x,pos.y+.1,pos.z),origin, .5);
float deltaZ = interpolate(noise(pos.x,pos.y,pos.z+.1),origin, .5);

//create the delta vector
Vec3D change = new Vec3D(deltaX*flipX*10, deltaY*flipY*10, deltaZ*flipZ*10);

//add it to the current position
pos.addSelf(change);

***********************************

any ideas on how to get the natural flocking effect in many posted vids such as this one?
http://vimeo.com/653177

thanks in advance

Re: my fireballs aint working...
Reply #1 - Mar 13th, 2008, 2:31pm
 
i've wrote an example using your code for a fake simulation of firefly flock. main difference is that i used your change vector as acceleration. its simple physics.
looks quite cool.
have fun

www.nothing.scene.org/p5/p5data/fireballs/fireballs_src.zip
Re: my fireballs aint working...
Reply #2 - Mar 13th, 2008, 5:10pm
 
Hi,

I'm the author of the Firefly video you linked. If you like, I can email you some source on how I created it, specifically the Perlin noise code I wrote.
Drop me an email on:

secretdark (at) g mail (dot) com

and I'll reply with some code.

Ryan
Page Index Toggle Pages: 1