Sorry for the lame subject, i'm trying to rotate vertex rectangles (in an array)that are located under the mouse cursor.
Quote:import processing.opengl.*;
fan[] fsurface;
void setup()
{
size(1024,768, OPENGL);
frameRate(60);
fsurface=new fan[100];
for(int x=0;x<10;x++)
{
for(int y=0;y<10;y++)
{
fsurface[x+y*10]=new fan((x)*101,(y)*75,101,75);
}
}
}
int lc=-120;
void draw()
{
background(0,0,0);
if(random(100)>80)
{
int num= (mouseY*mouseX)%100;
if(fsurface[num].f==0)
{
fsurface[num].flip();
}
}
for(int i=0;i<fsurface.length;i++)
{
if(fsurface[i].x+fsurface[i].y==lc)
{
fsurface[i].flip();
}
}
lc+=2;
if(lc>120)
{
lc=-120;
}
translate(0,0,-100);
for(int i=0;i<fsurface.length;i++)
{
fsurface[i].Draw();
}
}
class fan
{
int x,y,z,lx,ly;
int sgx,slx,sgy,sly;
int angle;
int f;
color c;
fan(int _x, int _y, int _lx,int _ly)
{
x=_x;
y=_y;
lx=_lx;
ly=_ly;
z=0;
angle=0;
c=color(0,120+y,120-y);
}
void flip()
{
f=1;
}
void Draw()
{
pushMatrix();
stroke(0);
translate(x+60,y+47,120);
if((angle!=0 && angle !=180) || f==1)
{
angle = mouseY-(mouseY-mouseX)%10;
rotateX(radians(angle));
}
beginShape(POLYGON);
{
vertex(-lx/2,-ly/2,0);
vertex(lx/2,-ly/2,0);
vertex(lx/2,ly/2,0);
vertex(-lx/2,ly/2,0);
}
endShape();
popMatrix();
}
}
Thank you for any suggestion.