disablek
YaBB Newbies
Offline
Posts: 48
Re: camera() upX upY upZ
Reply #1 - Jan 21st , 2008, 7:54pm
void setup(){ size(1000,1000,P3D); x=1000;y=1000; } int z=1000; int x=width/2; int y=height/2; int tx=x,ty=y,tz=0; int bx=0,by=0,bz=0; boolean follow=true; void draw(){ background(255); if(follow){ tx=x; ty=y; tz=0; } camera(x,y,z,tx,ty,tz,0,-1,0 ); pushMatrix(); translate(bx,by,bz); fill(0); rect(0,0,width,height); translate(width,0,0); fill(126); rotateY(PI/2); rect(0,0,width,height); translate(0,height,0); fill(240,220,130); rotateX(-PI/2); rect(0,0,width,height); popMatrix(); println(x+" "+y+" "+z); println("tx ty tz "+tx+" "+ty+" "+tz); println("bx by bz "+bx+" "+by+" "+bz); } void mouseDragged() { if (mouseX - pmouseX > 0) x -=10; else x +=10; if(mouseY-pmouseY>0) y-=10; else y+=10; } void keyPressed(){ if(noCaseKey('w')){ y+=10; }else if(noCaseKey('a')){ x-=10; }else if(noCaseKey('s')){ y-=10; }else if(noCaseKey('d')){ x+=10; }else if(noCaseKey('x')){ z+=10; }else if(noCaseKey('z')){ z-=10; } else if(noCaseKey('i')){ ty+=10; }else if(noCaseKey('j')){ tx-=10; }else if(noCaseKey('k')){ ty-=10; }else if(noCaseKey('l')){ tx+=10; }else if(noCaseKey('q')){ follow=!follow; } else if(keyCode==UP){ by+=10; }else if(keyCode==LEFT){ bx-=10; }else if(keyCode==RIGHT){ bx+=10; }else if(keyCode==DOWN){ by-=10; } } boolean noCaseKey(char a){ char k=Character.toUpperCase(a); if(key==a)return true; return false; } ----------------------------- right hopefully this will help someone out there. basically WASD ZX moves the camera. Q toggles whether where the camera is looking at moves together with the camera movement. IJKL moves where the camera is looking at. Arrow keys move the box. The x,y,z and other coords are displayed in the console.