Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. void setup() {
  2. size(1024, 512, P3D);
  3. }
  4.  
  5. void draw() {
  6. background(200);
  7.  
  8. //cam variables
  9. float fov = PI / 3;
  10. float cameraEyeZ = (height / 2) / (tan(fov / 2));
  11. float angle = (mouseY * 1.0 / height) * 2 * PI; //cam rotation angle around the origin [0, 2*PI]
  12.  
  13. camera(
  14. cameraEyeZ * sin(angle), 0.0, cameraEyeZ * cos(angle), //position
  15. 0.0, 0.0, 0.0, //centre
  16. 0.0, 1.0, 0.0); //up
  17.  
  18. { //perspective
  19. float m = 0.10;
  20. frustum(-width/2*m, width/2*m, -height/2*m, height/2*m, cameraEyeZ * m, cameraEyeZ * 100.0);
  21. }
  22. { //ortho
  23. //float m = 1.0;
  24. //ortho(-width/2 * m, width/2 * m, -height/2 * m, height/2 * m, cameraEyeZ * 0.10, cameraEyeZ * 100.0);
  25. }
  26. stroke(0);
  27. fill(255);
  28. box(30, 30, 30);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement