Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rhema/art
Browse files Browse the repository at this point in the history
  • Loading branch information
rhema committed Mar 4, 2013
2 parents 6e8a9a0 + 697fd7e commit 35a9f72
Show file tree
Hide file tree
Showing 19 changed files with 15,748 additions and 53 deletions.
204 changes: 151 additions & 53 deletions processing/sandbox/sketch 2 falling scene/sketch_camera.pde
@@ -1,11 +1,13 @@
PImage []imgs;
object []boxes;
Eyes []catEye;
int boxNum;
int eyeNum;
int boxSize;
int imageNum;
float []zVal;

int eyeID;//0:open, 1:closed
float previousSpeed;

int eyeBlinkSpeed=100;

PImage []eyes;
Expand All @@ -15,7 +17,7 @@ float currentSpeed;

void prepareTextures()
{
imageNum=2;
imageNum=3;
imgs=new PImage[10];
imgs[0]=loadImage("clock.png");
imgs[1]=loadImage("bluedoor.png");
Expand All @@ -31,53 +33,18 @@ float currentSpeed;
eyes[1]=loadImage("eyeClosed.png");
}

void drawEyes(float x,float y,float z,float thetax,float thetay,float thetaz)
{
pushMatrix();
translate(x, y, z);
rotateX(thetax);
rotateY(thetay);
rotateZ(thetaz);
//scale(size);
noStroke();

int w,h;
w=0;
h=0;
beginShape();
if(eyeID<eyeBlinkSpeed*0.9)
{
texture(eyes[0]);
w=eyes[0].width;
h=eyes[0].height;

}
else
{
texture(eyes[1]);
w=eyes[1].width;
h=eyes[0].height;
}
eyeID=(eyeID+1)%eyeBlinkSpeed;

int sizeH=(int)((float)boxSize*(float)h/((float)w));
vertex(-boxSize, -sizeH, 0, 0, 0);
vertex(boxSize, -sizeH, 0, w, 0);
vertex(boxSize, sizeH, 0, w, h);
vertex(-boxSize, sizeH, 0, 0, h);
endShape();
popMatrix();
}


void setup() {
int w=640;
int h=480;
boxSize=50;
boxNum=60;
eyeNum=10;
cameraY=0;
prepareTextures();
size(w, h, P3D);
eyeID=0;


zVal=new float[boxNum];
for(int i=0;i<boxNum;i++)
Expand All @@ -91,25 +58,74 @@ float currentSpeed;
{
boxes[i]=new object(w,h,i);
}
catEye=new Eyes[eyeNum];
for(int i=0;i<eyeNum;i++)
{
catEye[i]=new Eyes(w,h);
}

currentSpeed=2;
noStroke();
}

void keyPressed() {
if (key == 's' || key == 'S') {
if(currentSpeed>0)
{
previousSpeed=currentSpeed;
currentSpeed=0;
}
else
currentSpeed=previousSpeed;
}
else if (key == 'q' || key == 'Q')
currentSpeed+=1;
else if (key == 'e' || key == 'E')
{
currentSpeed-=1;
if(currentSpeed<1)
currentSpeed=1;
}
}

void draw() {

background(0);
drawEyes(300,100,30,0,0,0);
// if (keyPressed) {
// if (key == 's' || key == 'S') {
// if(currentSpeed>0)
// {
// previousSpeed=currentSpeed;
// currentSpeed=0;
// }
// else
// currentSpeed=previousSpeed;
// }
// else if (key == 'q' || key == 'Q')
// currentSpeed+=0.2;
// else if (key == 'e' || key == 'E')
// {
// currentSpeed-=0.2;
// if(currentSpeed<1)
// currentSpeed=1;
// }
// }

background(0);

camera(width/2, height/2+cameraY, (height/2) / tan(PI/6), width/2, height/2+cameraY, 0, 0, 1, 0);

// pushMatrix();


for(int i=0;i<eyeNum;i++)
{
catEye[i].display();
}
for(int i=0;i<boxNum;i++)
{
boxes[i].display();
}
// popMatrix();
// cameraY+=currentSpeed;
cameraY+=currentSpeed;
// beginShape();
// texture(img);
// vertex(-100, -100, 0, 0, 0);
Expand All @@ -119,6 +135,84 @@ float currentSpeed;
// endShape();
}

class Eyes
{
float x,y,z,thetax,thetay,thetaz,size;
int w, h;
int eyeID;//0:open, 1:closed
Eyes(int _w,int _h) {
w=_w;
h=_h;
eyeID=(int)random(eyeBlinkSpeed);

generate();

}

void generate()
{

x=random(-w/3,w/3)+w/2;
//y=random(-h/3,h/3)+h/2;
y=random(0,10*h);
z=0;

thetax=thetay=thetaz=0;

thetaz=random(-PI/4,PI/4);
size=random(0.5,3);
}
void display()
{
if(y<(cameraY-10))
{
y+=h*10+random(h*0.2,h*0.5);

}

if(y<(cameraY-10)||y>(cameraY+h+10))
return;
drawEyes(x,y,z,thetax,thetay,thetaz);
}
void drawEyes(float x,float y,float z,float thetax,float thetay,float thetaz)
{
pushMatrix();
translate(x, y, z);
rotateX(thetax);
rotateY(thetay);
rotateZ(thetaz);
//scale(size);
noStroke();

int w,h;
w=0;
h=0;
beginShape();
if(eyeID<eyeBlinkSpeed*0.9)
{
texture(eyes[0]);
w=eyes[0].width;
h=eyes[0].height;

}
else
{
texture(eyes[1]);
w=eyes[1].width;
h=eyes[1].height;
}
eyeID=(eyeID+1)%eyeBlinkSpeed;

int sizeH=(int)((float)boxSize*(float)h/((float)w));
vertex(-boxSize, -sizeH, 0, 0, 0);
vertex(boxSize, -sizeH, 0, w, 0);
vertex(boxSize, sizeH, 0, w, h);
vertex(-boxSize, sizeH, 0, 0, h);
endShape();
popMatrix();
}
}

class object
{
PImage image;
Expand Down Expand Up @@ -155,12 +249,14 @@ float currentSpeed;
size=random(0.5,3);
//fallSpeed=random(3,6);

float tmp=random(-1,1);
if(tmp>0)
float tmp=random(3);
if(tmp>2)
rotateDirection=1;
else if(tmp>1)
rotateDirection=0;
else
rotateDirection=-1;
rotationSpeed=random(PI/200,PI/80);
rotationSpeed=random(PI/800,PI/600);
life=random(10,30);
}

Expand All @@ -186,14 +282,16 @@ float currentSpeed;

void display() {

if(y<(cameraY-10))
y+=h*10+random(h*0.2,h*0.5);
if(y<(cameraY-10)||y>(cameraY+h+10))
return;
drawBox(x,y,z,thetax,thetay,thetaz,size,pointer.width,pointer.height);
if(imageID==0)
{
drawPointer(x,y,z,thetax,thetay,thetaz,size,imgs[imageID].width,imgs[imageID].height);
}
// thetaz=thetaz+rotationSpeed*rotateDirection;
// if(imageID==0)
// {
// drawPointer(x,y,z,thetax,thetay,thetaz,size,imgs[imageID].width,imgs[imageID].height);
// }
thetaz=thetaz+rotationSpeed*rotateDirection;
}

void drawPointer(float x,float y,float z,float thetax,float thetay,float thetaz,float size,int w,int h)
Expand Down
Empty file modified processing/sketch2/data/images/blankclock.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added processing/sketch2/data/images/clockarms.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added processing/sketch2/data/images/clocknumbers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added processing/sketch2/data/images/crookedhand.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 35a9f72

Please sign in to comment.