Skip to content

Commit db99d4c

Browse files
committed
finish scrubbing P3D
1 parent 0562411 commit db99d4c

4 files changed

Lines changed: 238 additions & 53 deletions

File tree

core/api.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,22 @@
325325
public void background(float x, float y, float z, float a)
326326
public void background(PImage image)
327327
protected void backgroundFromCalc()
328+
protected void backgroundImpl(PImage image)
328329
protected void backgroundImpl()
329330

331+
public void colorMode(int mode)
332+
public void colorMode(int mode, float max)
333+
public void colorMode(int mode, float maxX, float maxY, float maxZ)
334+
public void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA)
335+
336+
protected void colorCalc(int rgb)
337+
protected void colorCalc(int rgb, float alpha)
338+
protected void colorCalc(float gray)
339+
protected void colorCalc(float gray, float alpha)
340+
protected void colorCalc(float x, float y, float z)
341+
protected void colorCalc(float x, float y, float z, float a)
342+
protected void colorCalcARGB(int argb, float alpha)
343+
330344
public final int color(int gray)
331345
public final int color(int gray, int alpha)
332346
public final int color(int rgb, float alpha)

core/src/processing/core/PGraphics.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,17 +3424,21 @@ public void applyMatrix(float n00, float n01, float n02, float n03,
34243424

34253425
/**
34263426
* Copy the current transformation matrix into the specified target.
3427+
* Pass in null to create a new matrix.
34273428
*/
3428-
public void getMatrix(PMatrix2D target) {
3429+
public PMatrix2D getMatrix(PMatrix2D target) {
34293430
showMissingWarning("getMatrix");
3431+
return null;
34303432
}
34313433

34323434

34333435
/**
34343436
* Copy the current transformation matrix into the specified target.
3437+
* Pass in null to create a new matrix.
34353438
*/
3436-
public void getMatrix(PMatrix3D target) {
3439+
public PMatrix3D getMatrix(PMatrix3D target) {
34373440
showMissingWarning("getMatrix");
3441+
return null;
34383442
}
34393443

34403444

core/src/processing/core/PGraphics3D.java

Lines changed: 213 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,14 +2773,15 @@ public void applyMatrix(float n00, float n01, float n02, float n03,
27732773
// MATRIX GET/SET/PRINT
27742774

27752775

2776-
//public void getMatrix(PMatrix2D target)
2776+
//public PMatrix2D getMatrix(PMatrix2D target)
27772777

27782778

2779-
/**
2780-
* Copy the current transformation matrix into the specified target.
2781-
*/
2782-
public void getMatrix(PMatrix3D target) {
2779+
public PMatrix3D getMatrix(PMatrix3D target) {
2780+
if (target == null) {
2781+
target = new PMatrix3D();
2782+
}
27832783
target.set(modelview);
2784+
return target;
27842785
}
27852786

27862787

@@ -2809,10 +2810,47 @@ public void printMatrix() {
28092810
}
28102811

28112812

2813+
/*
2814+
* This function checks if the modelview matrix is set up to likely be
2815+
* drawing in 2D. It merely checks if the non-translational piece of the
2816+
* matrix is unity. If this is to be used, it should be coupled with a
2817+
* check that the raw vertex coordinates lie in the z=0 plane.
2818+
* Mainly useful for applying sub-pixel shifts to avoid 2d artifacts
2819+
* in the screen plane.
2820+
* Added by ewjordan 6/13/07
2821+
*
2822+
* TODO need to invert the logic here so that we can simply return
2823+
* the value, rather than calculating true/false and returning it.
2824+
*/
2825+
/*
2826+
private boolean drawing2D() {
2827+
if (modelview.m00 != 1.0f ||
2828+
modelview.m11 != 1.0f ||
2829+
modelview.m22 != 1.0f || // check scale
2830+
modelview.m01 != 0.0f ||
2831+
modelview.m02 != 0.0f || // check rotational pieces
2832+
modelview.m10 != 0.0f ||
2833+
modelview.m12 != 0.0f ||
2834+
modelview.m20 != 0.0f ||
2835+
modelview.m21 != 0.0f ||
2836+
!((camera.m23-modelview.m23) <= EPSILON &&
2837+
(camera.m23-modelview.m23) >= -EPSILON)) { // check for z-translation
2838+
// Something about the modelview matrix indicates 3d drawing
2839+
// (or rotated 2d, in which case 2d subpixel fixes probably aren't needed)
2840+
return false;
2841+
} else {
2842+
//The matrix is mapping z=0 vertices to the screen plane,
2843+
// which means it's likely that 2D drawing is happening.
2844+
return true;
2845+
}
2846+
}
2847+
*/
28122848

2849+
2850+
28132851
//////////////////////////////////////////////////////////////
28142852

2815-
// CAMERA and PERSPECTIVE
2853+
// CAMERA
28162854

28172855

28182856
/**
@@ -3073,6 +3111,11 @@ public void printCamera() {
30733111
}
30743112

30753113

3114+
//////////////////////////////////////////////////////////////
3115+
3116+
// PROJECTION
3117+
3118+
30763119
/**
30773120
* Calls ortho() with the proper parameters for Processing's
30783121
* standard orthographic projection.
@@ -3183,47 +3226,10 @@ public void printProjection() {
31833226
}
31843227

31853228

3186-
/*
3187-
* This function checks if the modelview matrix is set up to likely be
3188-
* drawing in 2D. It merely checks if the non-translational piece of the
3189-
* matrix is unity. If this is to be used, it should be coupled with a
3190-
* check that the raw vertex coordinates lie in the z=0 plane.
3191-
* Mainly useful for applying sub-pixel shifts to avoid 2d artifacts
3192-
* in the screen plane.
3193-
* Added by ewjordan 6/13/07
3194-
*
3195-
* TODO need to invert the logic here so that we can simply return
3196-
* the value, rather than calculating true/false and returning it.
3197-
*/
3198-
/*
3199-
private boolean drawing2D() {
3200-
if (modelview.m00 != 1.0f ||
3201-
modelview.m11 != 1.0f ||
3202-
modelview.m22 != 1.0f || // check scale
3203-
modelview.m01 != 0.0f ||
3204-
modelview.m02 != 0.0f || // check rotational pieces
3205-
modelview.m10 != 0.0f ||
3206-
modelview.m12 != 0.0f ||
3207-
modelview.m20 != 0.0f ||
3208-
modelview.m21 != 0.0f ||
3209-
!((camera.m23-modelview.m23) <= EPSILON &&
3210-
(camera.m23-modelview.m23) >= -EPSILON)) { // check for z-translation
3211-
// Something about the modelview matrix indicates 3d drawing
3212-
// (or rotated 2d, in which case 2d subpixel fixes probably aren't needed)
3213-
return false;
3214-
} else {
3215-
//The matrix is mapping z=0 vertices to the screen plane,
3216-
// which means it's likely that 2D drawing is happening.
3217-
return true;
3218-
}
3219-
}
3220-
*/
3221-
3222-
32233229

32243230
//////////////////////////////////////////////////////////////
32253231

3226-
// SCREEN AND OBJECT COORDINATES
3232+
// SCREEN AND MODEL COORDS
32273233

32283234

32293235
public float screenX(float x, float y) {
@@ -3364,37 +3370,102 @@ public float modelZ(float x, float y, float z) {
33643370
return (ow != 0) ? oz / ow : oz;
33653371
}
33663372

3373+
33673374

33683375
//////////////////////////////////////////////////////////////
3376+
3377+
// STYLE
3378+
3379+
// All methods are inherited from PGraphics.
3380+
3381+
3382+
3383+
//////////////////////////////////////////////////////////////
3384+
3385+
// COLOR MODE
3386+
3387+
// All methods are inherited from PGraphics.
3388+
3389+
3390+
3391+
//////////////////////////////////////////////////////////////
3392+
3393+
// COLOR CALC
3394+
3395+
// All methods are inherited from PGraphics.
3396+
33693397

3398+
3399+
//////////////////////////////////////////////////////////////
33703400

3371-
// strokeWeight() doesn't really work properly either,
3372-
// but that will be dealt with in some other way.
3401+
// STROKE CAP/JOIN/WEIGHT
3402+
3403+
3404+
public void strokeWeight(float weight) {
3405+
if (weight != DEFAULT_STROKE_WEIGHT) {
3406+
showMethodWarning("strokeWeight");
3407+
}
3408+
}
33733409

33743410

33753411
public void strokeJoin(int join) {
3376-
showMethodWarning("strokeJoin");
3412+
if (join != DEFAULT_STROKE_JOIN) {
3413+
showMethodWarning("strokeJoin");
3414+
}
33773415
}
33783416

33793417

33803418
public void strokeCap(int cap) {
3381-
showMethodWarning("strokeCap");
3419+
if (cap != DEFAULT_STROKE_CAP) {
3420+
showMethodWarning("strokeCap");
3421+
}
33823422
}
33833423

33843424

33853425

33863426
//////////////////////////////////////////////////////////////
33873427

3428+
// STROKE COLOR
3429+
3430+
// All methods inherited from PGraphics.
3431+
3432+
3433+
3434+
//////////////////////////////////////////////////////////////
3435+
3436+
// TINT COLOR
3437+
3438+
// All methods inherited from PGraphics.
3439+
3440+
3441+
3442+
//////////////////////////////////////////////////////////////
3443+
3444+
// FILL COLOR
3445+
33883446

33893447
protected void fillFromCalc() {
33903448
super.fillFromCalc();
33913449
ambientFromCalc();
33923450
}
33933451

33943452

3453+
3454+
//////////////////////////////////////////////////////////////
3455+
3456+
// MATERIAL PROPERTIES
3457+
3458+
// ambient, specular, shininess, and emissive all inherited.
3459+
33953460

3461+
33963462
//////////////////////////////////////////////////////////////
33973463

3464+
// LIGHTS
3465+
3466+
3467+
PVector lightPositionVec = new PVector();
3468+
PVector lightDirectionVec = new PVector();
33983469

33993470
/**
34003471
* Sets up an ambient and directional light.
@@ -3707,9 +3778,6 @@ protected void lightPosition(int num, float x, float y, float z) {
37073778
}
37083779

37093780

3710-
PVector lightPositionVec = new PVector();
3711-
PVector lightDirectionVec = new PVector();
3712-
37133781
/**
37143782
* internal function to set the light direction
37153783
* based on the current modelview matrix.
@@ -3762,6 +3830,100 @@ protected void backgroundImpl() {
37623830
}
37633831

37643832

3833+
3834+
//////////////////////////////////////////////////////////////
3835+
3836+
// COLOR MODE
3837+
3838+
// all colorMode() variations inherited from PGraphics.
3839+
3840+
3841+
3842+
//////////////////////////////////////////////////////////////
3843+
3844+
// COLOR CALCULATIONS
3845+
3846+
// protected colorCalc and colorCalcARGB inherited.
3847+
3848+
3849+
3850+
//////////////////////////////////////////////////////////////
3851+
3852+
// COLOR DATATYPE STUFFING
3853+
3854+
// final color() variations inherited.
3855+
3856+
3857+
3858+
//////////////////////////////////////////////////////////////
3859+
3860+
// COLOR DATATYPE EXTRACTION
3861+
3862+
// final methods alpha, red, green, blue,
3863+
// hue, saturation, and brightness all inherited.
3864+
3865+
3866+
3867+
//////////////////////////////////////////////////////////////
3868+
3869+
// COLOR DATATYPE INTERPOLATION
3870+
3871+
// both lerpColor variants inherited.
3872+
3873+
3874+
3875+
//////////////////////////////////////////////////////////////
3876+
3877+
// BEGINRAW/ENDRAW
3878+
3879+
// beginRaw, endRaw() both inherited.
3880+
3881+
3882+
3883+
//////////////////////////////////////////////////////////////
3884+
3885+
// WARNINGS and EXCEPTIONS
3886+
3887+
// showWarning and showException inherited.
3888+
3889+
3890+
3891+
//////////////////////////////////////////////////////////////
3892+
3893+
// RENDERER SUPPORT QUERIES
3894+
3895+
3896+
//public boolean displayable()
3897+
3898+
3899+
/**
3900+
* Returns true because this renderer supports 3D drawing.
3901+
*/
3902+
public boolean dimensional() {
3903+
return true;
3904+
}
3905+
3906+
3907+
3908+
//////////////////////////////////////////////////////////////
3909+
3910+
// PIMAGE METHODS
3911+
3912+
// All these methods are inherited, because this render has a
3913+
// pixels[] array that can be accessed directly.
3914+
3915+
// getImage
3916+
// setCache, getCache, removeCache
3917+
// isModified, setModified
3918+
// loadPixels, updatePixels
3919+
// resize
3920+
// get, getImpl, set, setImpl
3921+
// mask
3922+
// filter
3923+
// copy
3924+
// blendColor, blend
3925+
3926+
37653927

37663928
//////////////////////////////////////////////////////////////
37673929

0 commit comments

Comments
 (0)