V 
		
		Senior Member
		 
		Offline 
		
		
		Posts: 430
		portugal
		
		
		
 
	 
	
		
			
				Re: interact recursive funct. with a not recursive  
				Reply #3 -  Jun 13th , 2007, 6:17pm 
			 
			
				
	  
			 
		
		
			this is one easy way to do that.. get matrix and take translation vector.. other way would be for you to use parent children relationship to do transformation yourself.. so far it prints the position.. you should create an array and save them for later use.. i think this is what u were looking for. import processing.opengl.*; import javax.media.opengl.*; import javax.media.opengl.glu.*; // my programm  float a  = 0.0;  float inc = TWO_PI/30;  float dreher;        PGraphicsOpenGL pgl; GL opengl; GLU glu; float[] m = new float[16]; //fluegelkreise akrivieren  Fluegelkreis[] kreiseF = new Fluegelkreis[10];    int zufall =0;  int kugelZaehler=0;  float posx =0; float posy =0; void setup()  {    size(400,400, OPENGL);       pgl = ((PGraphicsOpenGL)g);   opengl = pgl.gl;   glu = ((PGraphicsOpenGL)g).glu;   smooth();    frameRate(25);   //10 Fluegelkreise machen    for (int i=0;i<10;i++)      {      kreiseF[i] = new Fluegelkreis();    }  }    void draw()  {    background(254);    // gleichmässige Bewegung    dreher = sin(a)/10;    a+= inc;      // Kugelfigur zeichnen      initKugelfig(200);     // Fluegelkugeln produzieren?    zufall = int (random(20));    if (zufall==2) {   kreiseF[kugelZaehler].aktiv = 1;   kreiseF[kugelZaehler].y = height - int(random(150)) -40;   if (kugelZaehler == 9)   {     kugelZaehler=0;   } else   {   kugelZaehler+=1;   }    }     //Fluegelkugeln bewegen   for (int i=0;i<10;i++)    {      if (kreiseF[i].aktiv == 1)      {   kreiseF[i].walk();   kreiseF[i].render();      }    }  }    class Fluegelkreis  {    int y,x;    int aktiv = 0;      Fluegelkreis ()    {      y = 0;      x = 0;      aktiv = 0;    }      void render()    {      fill(0,0,200,150);      noStroke();      ellipseMode(CENTER);      ellipse(x,y,30,30);            if (x>width)      {   aktiv =0;   x=0;      }    }      void walk()    {      x+= 5;    }  }          void initKugelfig (int x)  {    pushMatrix();    translate(x, height);    posy = 0;     drawKugelfig(0);      popMatrix();    }    void drawKugelfig(int grad)  {    pushMatrix();    int kreisrad = 40-grad*4;    ellipseMode(CENTER);    noStroke();    fill(250,0,0,180);        ellipse(0,0,kreisrad,kreisrad);      rotate(dreher);    translate(0,-kreisrad);       //-------------------------------   //  Get the modelview matrix and extract the position vector   //-------------------------------   opengl = pgl.beginGL();   // get the current modelview matrix   opengl.glGetFloatv( GL.GL_MODELVIEW_MATRIX , m, 0 );     pgl.endGL();   float x = m[12];   float y = m[13];   float z = m[14];   println( "X="+x );   println( "Y="+y );   println( "Z="+z );      if(grad<7){drawKugelfig(grad+1);}    popMatrix();  }