class Pellet { float x,y,z,px,py,pz,step; int sx,sy; //------------------ Pellet(){ step = random(0.005,0.015); } //------------------ void cubeFormation(float side){ x = random(0,side)-side/2; y = random(0,side)-side/2; z = random(0,side); //drawInitalPos(); } //------------------ void drawInitalPos(){ px = x; py = y; pz = z-30; float tx; tx = cos(rotY)*px + sin(rotY)*pz; pz = -sin(rotY)*px + cos(rotY)*pz; py = cos(rotX)*py + sin(rotX)*pz; sx = constrain( (int)( 9*tx+width/2 ), 0,width-1); sy = constrain( (int)( 9*py+width/2 ), 0,width-1); screenImage[sx][sy] += 1024; } //------------------ void update(){ x += step*( sigma*(y-x) ); y += step*( x*(roe-z) - y ); z += step*( x*y - beta*z ); drawToScreenBuffer(); } //------------------ void drawToScreenBuffer(){ px = x; py = y; pz = z-30; //perform some rotation float tx, ty, tz; tx = cos(rotY)*px + sin(rotY)*pz; ty = py; tz = -sin(rotY)*px + cos(rotY)*pz; px = tx; py = ty; pz = tz; tx = px; ty = cos(rotX)*py + sin(rotX)*pz; tz = -sin(rotX)*py + cos(rotX)*pz; px = tx; py = ty; pz = tz; if(antialias){ //perform some scaling sx = constrain( (int)( 7*px+width/2 ), 1,width-2); sy = constrain( (int)( 7*py+width/2 ), 1,width-2); // this code do some basic antialiasing // I pretty much assume this is a waste of CPU cycles float xP = px-(int)px; float yP = py-(int)py; float xN = 1-xP; float yN = 1-xP; screenImage[sx ][sy ] += (int)(64*xP*yP); screenImage[sx+1][sy ] += (int)(64*xN*yP); screenImage[sx ][sy+1] += (int)(64*xP*yN); screenImage[sx+1][sy+1] += (int)(64*xN*yN); } else { //perform some scaling sx = constrain( (int)( 9*px+width/2 ), 0,width-1); sy = constrain( (int)( 9*py+width/2 ), 0,width-1); screenImage[sx][sy] += 64; } } } //---------------------------------------------