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 & HelpOpenGL and 3D Libraries › independent instances
Page Index Toggle Pages: 1
independent instances (Read 475 times)
independent instances
Mar 28th, 2008, 3:32am
 
Hey!
I have an animation done and i want to duplicate it all around the grid but each instance of the animation needs to be at a random frame.

So, im testing with simple lines on the grid with some noise on one axe of each line, but i would like to make each noise of each line independent, or at least a random group, Any tips?

Sorry, if it's a stupid question..
Thanks


this is what i did as a sketch for the animation idea

import processing.opengl.*;
 float n1 = 0.00;float n2 = 0.00;float n3 = 1.00;float n4 = 0.00;
 float rndXpos= random(-100,100);
 float rndZpos= random(-100,100);
 int res = 20;
 float rotacion=0;
 
void setup()
{
 size(640, 480, OPENGL);
 noiseDetail(12);
 smooth();
}


void draw()
{
 
 
   rotacion-=0.005;
// translate(width/2,height/2);
   background(0);
   float angle= (noise(n1) - 0.5)*20;
   float angle1= (noise(n1) - 0.5)*20;
   for(int i=0; i<height; i+=res) {
   for(int j=0; j<width; j+=res) {
     stroke(255);
     float rrr= noise(j)*20;
     float eee= noise(j)*20;float tt= noise(j)*80;
     line(i, j, tt/10-20, i+angle, j+angle, tt/10 );
     
   
   }
 }
   n1 += 0.005;
   n2 += 0.005;

}


void tt(float xpos, float zpos){
   float angle= (noise(n1) - 0.5);
   beginShape(LINES);
     //tail
     stroke(24);
     vertex(angle*100, 0, 0);
     //root
     stroke(255);
     vertex(xpos, 100, zpos);
   endShape();
   n1 += 0.005;
}

Re: independent instances
Reply #1 - Mar 28th, 2008, 5:51am
 
First of all, there are no stupid questions. Smiley

Second, care to explain a little bit more what you are trying to achieve?

What I can think of right now is, create an object for each line or whatever object you are working with, you put the animation code inside the class, with customizable initialization parameters, such that you can create the same object several times, each with different settings.

So, you might receive, say, position and color for each object. And since you can specify the parameters whenever you create an object, you can tell each of them to behave differently, even though it's the same "base" object.

Is this what you are trying to do or I'm way off?
Re: independent instances
Reply #2 - Mar 28th, 2008, 7:06pm
 
I'm trying that. I think that will help.
Then I could have a function with a Counter that calls two rnd numbers(one for each axe) and change the properties of that obj in that position of the array, having like this some noise in my destribution.

Thanks for your comment acapulco
Page Index Toggle Pages: 1