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.
IndexDiscussionExhibition › makingThingsMove (animation via code)
Page Index Toggle Pages: 1
makingThingsMove (animation via code) (Read 2066 times)
makingThingsMove (animation via code)
Oct 15th, 2005, 1:52am
 
hi all,

as part of a workshop I did in madrid (at the medialab madrid), in june, I created a series of processing sketches to explain the basic principles of programmatic animation.

I've posted the processing sketches here:

http://thesystemis.com/makingThingsMove/

You can download code examples from day 1, 2 and 3.

I'm hoping to find some more time soon to write about how these examples work and how they fit together.

In the meantime, I hope you enjoy this collection of processing sketches from that workshop.

- zach
Re: makingThingsMove (animation via code)
Reply #1 - Oct 19th, 2005, 12:01am
 
Very nice work. I like the way you have grouped almost all of the animation techniques into similar sketches. I'm sure it will be useful for a lot of people.

One thing I would suggest is adding a framerate cap to the sketches.

Ali
Re: makingThingsMove (animation via code)
Reply #2 - Oct 21st, 2005, 9:38pm
 
interesting, would that be using the framerate(fps) function or rolling something myself using a timer (ie sleep or don't sleep)...  

Another option, which I didn't get to in the code examples, is using framerate independent motion, ie timesteps "idle(dt)" are based on the actual time not the frame.  good game programmers know this well, and it might be the best approach - ie, render as fast or as slow is you want, but move the objects based on actual time, not frame rate.
Re: makingThingsMove (animation via code)
Reply #3 - Oct 22nd, 2005, 11:25pm
 
Yeah, I know what you mean about time vs framerate. What I had in mind was a simple framerate(30); statement in setup().
Re: makingThingsMove (animation via code)
Reply #4 - Nov 18th, 2005, 7:53pm
 
cool.
simple and nice.
Re: makingThingsMove (animation via code)
Reply #5 - Dec 17th, 2005, 7:36am
 
Zach,

Very nice code examples. I played with the vector fields for hours! They appear to be a very powerful data structure.

I've been looking at example_06_02. I've seen this variable "float pct" in a few other examples. What does this name stand for? What is it doing?

Hoora for polymorphism!

Casey

Quote:
void calculateForces(){
 
  vec2d dist = new vec2d(0,0);
  float radius = 30.0f;
 
  for (int i = 0; i < numParticles; i ++){
  if (PRTS[i].bAlive == false) continue;
    for (int j = 0; j < i; j ++){
    if (PRTS[j].bAlive == false) continue;
     
      dist.set(PRTS[i].pos);
      dist.sub(PRTS[j].pos);
      float len = dist.length();
      if (len < radius){
        float pct = 1.0f - (len/radius);
        dist.normalise();
        dist.mult(pct * 0.05f);  // scale the force!
       
        PRTS[j].vel.add(dist);
        PRTS[i].vel.sub(dist);
      }
    }
  }
}
Re: makingThingsMove (animation via code)
Reply #6 - Dec 25th, 2005, 5:06am
 
watsoncj wrote on Dec 17th, 2005, 7:36am:
I've been looking at example_06_02. I've seen this variable "float pct" in a few other examples. What does this name stand for What is it doing


thanks!

sorry for the delay, I don't get an email when there is a response...

pct is a number which goes from 0 to 1, this could be anything, but as a rule for myself, it represent a value of 0 to 1.  for example, you could convert mouse position in x to a pct,

float pct = mousex / width;

in this case pct is a number which represent how close the objects are.  this is based on their actual distance (dist) devided by the whole (in this case 30.0f).  As the distance gets closer (the object get closer to touching each other) this number gets closer to 0.  I inverted it, by subtracting it from 1...

float pct = 1 - (dist/radius);

when dist is close to radius, ie 28, the number is small

1 - ( 28 / 30 )

when dist is close to zero, the number is larger

1 - ( 3 / 30 )

I use this number (pct) to scale the forces on these two objects, when they are closer, apply more force, when they are further away, apply less force.

hope that helps - feel free to ask some more if it's not clear....

- zach
Page Index Toggle Pages: 1