Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- size(1024, 512, P3D);
- }
- void draw() {
- background(200);
- //cam variables
- float fov = PI / 3;
- float cameraEyeZ = (height / 2) / (tan(fov / 2));
- float angle = (mouseY * 1.0 / height) * 2 * PI; //cam rotation angle around the origin [0, 2*PI]
- camera(
- cameraEyeZ * sin(angle), 0.0, cameraEyeZ * cos(angle), //position
- 0.0, 0.0, 0.0, //centre
- 0.0, 1.0, 0.0); //up
- { //perspective
- float m = 0.10;
- frustum(-width/2*m, width/2*m, -height/2*m, height/2*m, cameraEyeZ * m, cameraEyeZ * 100.0);
- }
- { //ortho
- //float m = 1.0;
- //ortho(-width/2 * m, width/2 * m, -height/2 * m, height/2 * m, cameraEyeZ * 0.10, cameraEyeZ * 100.0);
- }
- stroke(0);
- fill(255);
- box(30, 30, 30);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement