From 97dce3394d3e66180850dbfa7229b5a4bd2ee4f3 Mon Sep 17 00:00:00 2001 From: juniperoserra Date: Mon, 2 May 2005 04:26:45 +0000 Subject: [PATCH] Fixed camera and removed lookat --- core/PApplet.java | 8 ------- core/PGraphics.java | 6 ----- core/PGraphics3.java | 57 +++++++++++++++----------------------------- 3 files changed, 19 insertions(+), 52 deletions(-) diff --git a/core/PApplet.java b/core/PApplet.java index 7df4379df..8cb7dd36c 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -6176,14 +6176,6 @@ v PApplet.this.stop(); } - public void lookat(float eyeX, float eyeY, float eyeZ, - float centerX, float centerY, float centerZ, - float upX, float upY, float upZ) { - if (recorder != null) recorder.lookat(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ); - g.lookat(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ); - } - - public void printCamera() { if (recorder != null) recorder.printCamera(); g.printCamera(); diff --git a/core/PGraphics.java b/core/PGraphics.java index 5e65cfc01..a7037acbc 100644 --- a/core/PGraphics.java +++ b/core/PGraphics.java @@ -2111,12 +2111,6 @@ public class PGraphics extends PImage implements PConstants { depthError("frustum"); } - public void lookat(float eyeX, float eyeY, float eyeZ, - float centerX, float centerY, float centerZ, - float upX, float upY, float upZ) { - depthError("lookat"); - } - public void printCamera() { depthError("printCamera"); } diff --git a/core/PGraphics3.java b/core/PGraphics3.java index 8acea656e..8ee49f48b 100644 --- a/core/PGraphics3.java +++ b/core/PGraphics3.java @@ -353,6 +353,8 @@ public class PGraphics3 extends PGraphics { modelview = new PMatrix(MATRIX_STACK_DEPTH); modelviewInv = new PMatrix(MATRIX_STACK_DEPTH); + forwardTransform = modelview; + reverseTransform = modelviewInv; camera = new PMatrix(); cameraInv = new PMatrix(); @@ -2824,8 +2826,8 @@ public class PGraphics3 extends PGraphics { "in camera manipulation mode"); } // reset the modelview to use this new camera matrix - modelview.set(forwardTransform); // cameraInv - modelviewInv.set(reverseTransform); // camera + modelview.set(camera); + modelviewInv.set(cameraInv); // set matrix mode back to modelview forwardTransform = modelview; @@ -2871,26 +2873,9 @@ public class PGraphics3 extends PGraphics { * Calls camera() with Processing's standard camera setup. */ public void camera() { - beginCamera(); - resetMatrix(); - lookat(cameraX, cameraY, cameraZ, + camera(cameraX, cameraY, cameraZ, cameraX, cameraY, 0, 0, 1, 0); - endCamera(); - } - - - /** - * Similar to gluLookAt(), however it first clears the current - * camera settings. - */ - public void camera(float eyeX, float eyeY, float eyeZ, - float centerX, float centerY, float centerZ, - float upX, float upY, float upZ) { - beginCamera(); - resetMatrix(); - lookat(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ); - endCamera(); } @@ -2942,7 +2927,7 @@ public class PGraphics3 extends PGraphics { */ // TODO: deal with this. Lookat must ALWAYS apply to the modelview // regardless of the camera manipulation mode. - public void lookat(float eyeX, float eyeY, float eyeZ, + public void camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { float z0 = eyeX - centerX; @@ -2984,25 +2969,21 @@ public class PGraphics3 extends PGraphics { // just does an apply to the main matrix, // since that'll be copied out on endCamera - applyMatrix(x0, x1, x2, 0, - y0, y1, y2, 0, - z0, z1, z2, 0, - 0, 0, 0, 1); - translate(eyeX, eyeY, eyeZ); + camera.set(x0, x1, x2, 0, + y0, y1, y2, 0, + z0, z1, z2, 0, + 0, 0, 0, 1); + camera.translate(-eyeX, -eyeY, -eyeZ); - /* - modelview.invApplyMatrix(x0, x1, x2, 0, - y0, y1, y2, 0, - z0, z1, z2, 0, - 0, 0, 0, 1); - modelview.invTranslate(eyeX, eyeY, eyeZ); + cameraInv.reset(); + cameraInv.invApply(x0, x1, x2, 0, + y0, y1, y2, 0, + z0, z1, z2, 0, + 0, 0, 0, 1); + cameraInv.invTranslate(-eyeX, -eyeY, -eyeZ); - modelviewInv.applyMatrix(x0, x1, x2, 0, - y0, y1, y2, 0, - z0, z1, z2, 0, - 0, 0, 0, 1); - modelviewInv.translate(eyeX, eyeY, eyeZ); - */ + modelview.set(camera); + modelviewInv.set(cameraInv); }