From 649eac26832deb4f159e6de30e6e9e6bec8f703b Mon Sep 17 00:00:00 2001 From: benfry Date: Thu, 15 Oct 2009 19:28:04 +0000 Subject: [PATCH] change how camera/perspective is set for immediate updates, addl PVector dot() method --- core/src/processing/core/PGraphics3D.java | 26 +++++++++++++++++--- core/src/processing/core/PVector.java | 5 ++++ core/todo.txt | 30 ++++++++++++++++++----- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/core/src/processing/core/PGraphics3D.java b/core/src/processing/core/PGraphics3D.java index ba5af3c15..57dde4343 100644 --- a/core/src/processing/core/PGraphics3D.java +++ b/core/src/processing/core/PGraphics3D.java @@ -358,12 +358,12 @@ public class PGraphics3D extends PGraphics { cameraInv = new PMatrix3D(); // set up the default camera - camera(); +// camera(); // defaults to perspective, if the user has setup up their // own projection, they'll need to fix it after resize anyway. // this helps the people who haven't set up their own projection. - perspective(); +// perspective(); } @@ -478,6 +478,12 @@ public class PGraphics3D extends PGraphics { forwardTransform = modelview; reverseTransform = modelviewInv; + // set up the default camera + camera(); + + // defaults to perspective, if the user has setup up their + // own projection, they'll need to fix it after resize anyway. + // this helps the people who haven't set up their own projection. perspective(); // easiest for beginners @@ -1344,7 +1350,7 @@ public class PGraphics3D extends PGraphics { boolean bClipped = false; int clippedCount = 0; - cameraNear = -8; +// cameraNear = -8; if (vertices[a][VZ] > cameraNear) { aClipped = true; clippedCount++; @@ -1358,8 +1364,15 @@ public class PGraphics3D extends PGraphics { clippedCount++; } if (clippedCount == 0) { +// if (vertices[a][VZ] < cameraFar && +// vertices[b][VZ] < cameraFar && +// vertices[c][VZ] < cameraFar) { addTriangleWithoutClip(a, b, c); +// } +// } else if (true) { +// return; + } else if (clippedCount == 3) { // In this case there is only one visible point. |/| // So we'll have to make two new points on the clip line <| | @@ -3502,6 +3515,7 @@ public class PGraphics3D extends PGraphics { 0, y, 0, ty, 0, 0, z, tz, 0, 0, 0, 1); + updateProjection(); frustumMode = false; } @@ -3569,6 +3583,12 @@ public class PGraphics3D extends PGraphics { 0, (2*znear)/(top-bottom), (top+bottom)/(top-bottom), 0, 0, 0, -(zfar+znear)/(zfar-znear),-(2*zfar*znear)/(zfar-znear), 0, 0, -1, 0); + updateProjection(); + } + + + /** Called after the 'projection' PMatrix3D has changed. */ + protected void updateProjection() { } diff --git a/core/src/processing/core/PVector.java b/core/src/processing/core/PVector.java index 78209bb60..1fb4f1f76 100644 --- a/core/src/processing/core/PVector.java +++ b/core/src/processing/core/PVector.java @@ -428,6 +428,11 @@ public class PVector { public float dot(float x, float y, float z) { return this.x*x + this.y*y + this.z*z; } + + + static public float dot(PVector v1, PVector v2) { + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; + } /** diff --git a/core/todo.txt b/core/todo.txt index f8f57275f..dbe664c81 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -3,6 +3,30 @@ X added some min/max functions that work with doubles X not sure if those are staying in or not X filter(RGB) supposed to be filter(OPAQUE) X http://dev.processing.org/bugs/show_bug.cgi?id=1346 +X implement non-power-of-2 textures +X fix get() when used with save() in OpenGL mode +X immediately update projection with OpenGL +X in the past, projection updates required a new frame +X also prevents camera/project from being reset with setSize() (regression?) +X which was a problem anyway because it made GL calls outside draw() + +_ should vertexTexture() divide by width/height or width-1/height-1? + +_ open up the pdf library more (philho) +_ http://dev.processing.org/bugs/show_bug.cgi?id=1343 +_ changing vertex alpha in P3D in a QUAD_STRIP is ignored +_ with smoothing, it works fine, but with PTriangle, it's not +_ smooth() not working with applets an createGraphics(JAVA2D) +_ but works fine with applications + +_ get() with OPENGL is grabbing the wrong coords + +_ No textures render with hint(ENABLE_ACCURATE_TEXTURES) +_ http://dev.processing.org/bugs/show_bug.cgi?id=985 +_ need to remove the hint from the reference +_ need to throw an error when it's used +_ deal with issue of single pixel seam at the edge of textures +_ http://dev.processing.org/bugs/show_bug.cgi?id=602 _ opengl camera does not update on current frame (has to do a second frame) @@ -180,12 +204,6 @@ _ smooth in P3D has zbuffer glitches _ http://dev.processing.org/bugs/show_bug.cgi?id=1000 _ smoothing is slow _ http://dev.processing.org/bugs/show_bug.cgi?id=1001 -_ No textures render with hint(ENABLE_ACCURATE_TEXTURES) -_ http://dev.processing.org/bugs/show_bug.cgi?id=985 -_ need to remove the hint from the reference -_ need to throw an error when it's used -_ deal with issue of single pixel seam at the edge of textures -_ ??? what is the bug # for this one? _ textured sphere example needs to set normals _ also needs fix for last edge and the seam