Last active
October 5, 2015 01:52
-
-
Save FreedomGrenade/817d31b55c438ae7b565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mouse left to toggle cam change on/off | |
// Other to toggle transformations | |
public void setup() { | |
size(500, 500, P3D); | |
textSize(50); | |
} | |
boolean cam = true; | |
boolean tran = true; | |
public void draw() { | |
background(255); | |
float x = cos(frameCount/100.0)*20; | |
float y = sin(frameCount/100.0)*20; | |
textSize(50); | |
pushMatrix(); | |
if (cam) camera(width/2.0, height/2.0, (height/2.0)/tan(PI*30.0/180.0), width/2.0+x, height/2.0+y, 0, 0, 1, 0); | |
if (tran) { | |
translate(width/2, height/2, -100); | |
rotateY(frameCount/50.0); | |
} | |
fill(64); | |
stroke(0); | |
drawAxis(); | |
box(20); | |
noStroke(); | |
fill(0,0,255); | |
text("In scene", mouseX, mouseY); | |
popMatrix(); | |
fill(255,0,0); | |
text("Out of scene", mouseX, mouseY); | |
textSize(20); | |
if (cam) { | |
text("Cam looking at " + nf(width/2.0+x,3,2) + ":" + nf(height/2.0 + y,3,2),0,30); | |
} else { | |
text("Cam looking at " + width/2.0 + ":" + height/2.0 ,0,30); | |
} | |
if (tran) { | |
text("Box translated to " + width/2.0 + ":" + height/2.0,0,60); | |
} else { | |
text("Box translated to 0,0",0,60); | |
} | |
} | |
public void mouseReleased() { | |
println(mouseButton); | |
if (mouseButton == LEFT) { | |
cam= !cam; | |
} else { | |
tran = !tran; | |
} | |
} | |
public void drawAxis() { | |
line( -100, 0, 0, 100, 0, 0); | |
line( 0, -100, 0, 0, 100, 0); | |
line( 0, 0, -100, 0, 0, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment