From e42c4169c66796fa3cf6d546cd06bb4dd5e17981 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 5 Oct 2008 22:10:04 +0000 Subject: [PATCH] finish scrubbing P3D --- core/api.txt | 14 ++ core/src/processing/core/PGraphics.java | 8 +- core/src/processing/core/PGraphics3D.java | 266 +++++++++++++++++----- core/todo.txt | 5 + 4 files changed, 239 insertions(+), 54 deletions(-) diff --git a/core/api.txt b/core/api.txt index b9f102744..879274e7b 100644 --- a/core/api.txt +++ b/core/api.txt @@ -325,8 +325,22 @@ public void background(float x, float y, float z, float a) public void background(PImage image) protected void backgroundFromCalc() + protected void backgroundImpl(PImage image) protected void backgroundImpl() + public void colorMode(int mode) + public void colorMode(int mode, float max) + public void colorMode(int mode, float maxX, float maxY, float maxZ) + public void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA) + + protected void colorCalc(int rgb) + protected void colorCalc(int rgb, float alpha) + protected void colorCalc(float gray) + protected void colorCalc(float gray, float alpha) + protected void colorCalc(float x, float y, float z) + protected void colorCalc(float x, float y, float z, float a) + protected void colorCalcARGB(int argb, float alpha) + public final int color(int gray) public final int color(int gray, int alpha) public final int color(int rgb, float alpha) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 3613d58f1..e13853be5 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -3424,17 +3424,21 @@ public class PGraphics extends PImage implements PConstants { /** * Copy the current transformation matrix into the specified target. + * Pass in null to create a new matrix. */ - public void getMatrix(PMatrix2D target) { + public PMatrix2D getMatrix(PMatrix2D target) { showMissingWarning("getMatrix"); + return null; } /** * Copy the current transformation matrix into the specified target. + * Pass in null to create a new matrix. */ - public void getMatrix(PMatrix3D target) { + public PMatrix3D getMatrix(PMatrix3D target) { showMissingWarning("getMatrix"); + return null; } diff --git a/core/src/processing/core/PGraphics3D.java b/core/src/processing/core/PGraphics3D.java index a0baa42f2..fd19c52f6 100644 --- a/core/src/processing/core/PGraphics3D.java +++ b/core/src/processing/core/PGraphics3D.java @@ -2773,14 +2773,15 @@ public class PGraphics3D extends PGraphics { // MATRIX GET/SET/PRINT - //public void getMatrix(PMatrix2D target) + //public PMatrix2D getMatrix(PMatrix2D target) - /** - * Copy the current transformation matrix into the specified target. - */ - public void getMatrix(PMatrix3D target) { + public PMatrix3D getMatrix(PMatrix3D target) { + if (target == null) { + target = new PMatrix3D(); + } target.set(modelview); + return target; } @@ -2809,10 +2810,47 @@ public class PGraphics3D extends PGraphics { } + /* + * This function checks if the modelview matrix is set up to likely be + * drawing in 2D. It merely checks if the non-translational piece of the + * matrix is unity. If this is to be used, it should be coupled with a + * check that the raw vertex coordinates lie in the z=0 plane. + * Mainly useful for applying sub-pixel shifts to avoid 2d artifacts + * in the screen plane. + * Added by ewjordan 6/13/07 + * + * TODO need to invert the logic here so that we can simply return + * the value, rather than calculating true/false and returning it. + */ + /* + private boolean drawing2D() { + if (modelview.m00 != 1.0f || + modelview.m11 != 1.0f || + modelview.m22 != 1.0f || // check scale + modelview.m01 != 0.0f || + modelview.m02 != 0.0f || // check rotational pieces + modelview.m10 != 0.0f || + modelview.m12 != 0.0f || + modelview.m20 != 0.0f || + modelview.m21 != 0.0f || + !((camera.m23-modelview.m23) <= EPSILON && + (camera.m23-modelview.m23) >= -EPSILON)) { // check for z-translation + // Something about the modelview matrix indicates 3d drawing + // (or rotated 2d, in which case 2d subpixel fixes probably aren't needed) + return false; + } else { + //The matrix is mapping z=0 vertices to the screen plane, + // which means it's likely that 2D drawing is happening. + return true; + } + } + */ + + ////////////////////////////////////////////////////////////// - // CAMERA and PERSPECTIVE + // CAMERA /** @@ -3073,6 +3111,11 @@ public class PGraphics3D extends PGraphics { } + ////////////////////////////////////////////////////////////// + + // PROJECTION + + /** * Calls ortho() with the proper parameters for Processing's * standard orthographic projection. @@ -3183,47 +3226,10 @@ public class PGraphics3D extends PGraphics { } - /* - * This function checks if the modelview matrix is set up to likely be - * drawing in 2D. It merely checks if the non-translational piece of the - * matrix is unity. If this is to be used, it should be coupled with a - * check that the raw vertex coordinates lie in the z=0 plane. - * Mainly useful for applying sub-pixel shifts to avoid 2d artifacts - * in the screen plane. - * Added by ewjordan 6/13/07 - * - * TODO need to invert the logic here so that we can simply return - * the value, rather than calculating true/false and returning it. - */ - /* - private boolean drawing2D() { - if (modelview.m00 != 1.0f || - modelview.m11 != 1.0f || - modelview.m22 != 1.0f || // check scale - modelview.m01 != 0.0f || - modelview.m02 != 0.0f || // check rotational pieces - modelview.m10 != 0.0f || - modelview.m12 != 0.0f || - modelview.m20 != 0.0f || - modelview.m21 != 0.0f || - !((camera.m23-modelview.m23) <= EPSILON && - (camera.m23-modelview.m23) >= -EPSILON)) { // check for z-translation - // Something about the modelview matrix indicates 3d drawing - // (or rotated 2d, in which case 2d subpixel fixes probably aren't needed) - return false; - } else { - //The matrix is mapping z=0 vertices to the screen plane, - // which means it's likely that 2D drawing is happening. - return true; - } - } - */ - - ////////////////////////////////////////////////////////////// - // SCREEN AND OBJECT COORDINATES + // SCREEN AND MODEL COORDS public float screenX(float x, float y) { @@ -3364,27 +3370,79 @@ public class PGraphics3D extends PGraphics { return (ow != 0) ? oz / ow : oz; } + ////////////////////////////////////////////////////////////// + + // STYLE + + // All methods are inherited from PGraphics. - // strokeWeight() doesn't really work properly either, - // but that will be dealt with in some other way. + + ////////////////////////////////////////////////////////////// + + // COLOR MODE + + // All methods are inherited from PGraphics. + + + + ////////////////////////////////////////////////////////////// + + // COLOR CALC + + // All methods are inherited from PGraphics. + + + + ////////////////////////////////////////////////////////////// + + // STROKE CAP/JOIN/WEIGHT + + + public void strokeWeight(float weight) { + if (weight != DEFAULT_STROKE_WEIGHT) { + showMethodWarning("strokeWeight"); + } + } public void strokeJoin(int join) { - showMethodWarning("strokeJoin"); + if (join != DEFAULT_STROKE_JOIN) { + showMethodWarning("strokeJoin"); + } } public void strokeCap(int cap) { - showMethodWarning("strokeCap"); + if (cap != DEFAULT_STROKE_CAP) { + showMethodWarning("strokeCap"); + } } ////////////////////////////////////////////////////////////// + // STROKE COLOR + + // All methods inherited from PGraphics. + + + + ////////////////////////////////////////////////////////////// + + // TINT COLOR + + // All methods inherited from PGraphics. + + + + ////////////////////////////////////////////////////////////// + + // FILL COLOR + protected void fillFromCalc() { super.fillFromCalc(); @@ -3392,9 +3450,22 @@ public class PGraphics3D extends PGraphics { } - + ////////////////////////////////////////////////////////////// + // MATERIAL PROPERTIES + + // ambient, specular, shininess, and emissive all inherited. + + + + ////////////////////////////////////////////////////////////// + + // LIGHTS + + + PVector lightPositionVec = new PVector(); + PVector lightDirectionVec = new PVector(); /** * Sets up an ambient and directional light. @@ -3707,9 +3778,6 @@ public class PGraphics3D extends PGraphics { } - PVector lightPositionVec = new PVector(); - PVector lightDirectionVec = new PVector(); - /** * internal function to set the light direction * based on the current modelview matrix. @@ -3762,6 +3830,100 @@ public class PGraphics3D extends PGraphics { } + + ////////////////////////////////////////////////////////////// + + // COLOR MODE + + // all colorMode() variations inherited from PGraphics. + + + + ////////////////////////////////////////////////////////////// + + // COLOR CALCULATIONS + + // protected colorCalc and colorCalcARGB inherited. + + + + ////////////////////////////////////////////////////////////// + + // COLOR DATATYPE STUFFING + + // final color() variations inherited. + + + + ////////////////////////////////////////////////////////////// + + // COLOR DATATYPE EXTRACTION + + // final methods alpha, red, green, blue, + // hue, saturation, and brightness all inherited. + + + + ////////////////////////////////////////////////////////////// + + // COLOR DATATYPE INTERPOLATION + + // both lerpColor variants inherited. + + + + ////////////////////////////////////////////////////////////// + + // BEGINRAW/ENDRAW + + // beginRaw, endRaw() both inherited. + + + + ////////////////////////////////////////////////////////////// + + // WARNINGS and EXCEPTIONS + + // showWarning and showException inherited. + + + + ////////////////////////////////////////////////////////////// + + // RENDERER SUPPORT QUERIES + + + //public boolean displayable() + + + /** + * Returns true because this renderer supports 3D drawing. + */ + public boolean dimensional() { + return true; + } + + + + ////////////////////////////////////////////////////////////// + + // PIMAGE METHODS + + // All these methods are inherited, because this render has a + // pixels[] array that can be accessed directly. + + // getImage + // setCache, getCache, removeCache + // isModified, setModified + // loadPixels, updatePixels + // resize + // get, getImpl, set, setImpl + // mask + // filter + // copy + // blendColor, blend + + ////////////////////////////////////////////////////////////// diff --git a/core/todo.txt b/core/todo.txt index 5c9704028..33cb54eaa 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -71,6 +71,11 @@ smooth is now part of PGraphics, moved out of PImage imageMode has been removed from PImage, too awkward raw must handle points, lines, triangles, and textures +_ add to hint(DISABLE_DEPTH_TEST) +_ gl.glClear(GL.GL_DEPTH_BUFFER_BIT); +_ or clearing the zbuffer for P3D +_ also add a note to the hint() reference + _ accessors inside PFont need a lot of work _ may need to add to PApplet.main() for OS X 10.5