finish scrubbing P3D

This commit is contained in:
benfry
2008-10-05 22:10:04 +00:00
parent fbb299abe7
commit e42c4169c6
4 changed files with 239 additions and 54 deletions
+14
View File
@@ -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)
+6 -2
View File
@@ -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;
}
+214 -52
View File
@@ -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
//////////////////////////////////////////////////////////////
+5
View File
@@ -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