Skip to content

Commit 8efb80f

Browse files
committed
give up on wrapping AffineTransform and other matrices
1 parent d7f3f4f commit 8efb80f

File tree

9 files changed

+605
-113
lines changed

9 files changed

+605
-113
lines changed

core/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry excluding="processing/core/PMatrix.java" kind="src" path="src"/>
3+
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
55
<classpathentry kind="output" path="bin"/>
66
</classpath>

core/api.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ style(PStyle s)
200200
int xx, int yy,
201201
int w0, int h0)
202202

203+
public void pushMatrix()
204+
public void popMatrix()
205+
206+
public void resetMatrix()
203207
public void translate(float tx, float ty)
204208
public void translate(float tx, float ty, float tz)
205209
public void rotate(float angle)
@@ -210,27 +214,20 @@ style(PStyle s)
210214
public void scale(float s)
211215
public void scale(float sx, float sy)
212216
public void scale(float x, float y, float z)
213-
214-
public void resetMatrix()
215-
216-
public PMatrix getMatrix()
217-
public getMatrix(PMatrix2D target)
218-
public getMatrix(PMatrix3D target)
219-
public void setMatrix(PMatrix source)
220-
221-
public void applyMatrix(PMatrix source)
217+
public void applyMatrix(PMatrix2D source)
218+
public void applyMatrix(PMatrix3D source)
222219
public void applyMatrix(float n00, float n01, float n02,
223220
float n10, float n11, float n12)
224221
public void applyMatrix(float n00, float n01, float n02, float n03,
225222
float n10, float n11, float n12, float n13,
226223
float n20, float n21, float n22, float n23,
227224
float n30, float n31, float n32, float n33)
228225

229-
public void pushMatrix()
230-
public void popMatrix()
231-
232-
public void loadMatrix()
233226
public void printMatrix()
227+
public getMatrix(PMatrix2D target)
228+
public getMatrix(PMatrix3D target)
229+
public void setMatrix(PMatrix2D source)
230+
public void setMatrix(PMatrix3D source)
234231

235232
public void beginCamera()
236233
public void endCamera()

core/src/processing/core/PGraphics.java

Lines changed: 176 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,13 +3198,40 @@ protected void textCharScreenImpl(PImage glyph,
31983198
}
31993199
}
32003200

3201+
3202+
3203+
//////////////////////////////////////////////////////////////
3204+
3205+
// MATRIX STACK
3206+
3207+
3208+
/**
3209+
* Push a copy of the current transformation matrix onto the stack.
3210+
*/
3211+
public void pushMatrix() {
3212+
}
3213+
3214+
3215+
/**
3216+
* Replace the current transformation matrix with the top of the stack.
3217+
*/
3218+
public void popMatrix() {
3219+
}
3220+
32013221

32023222

32033223
//////////////////////////////////////////////////////////////
32043224

32053225
// MATRIX TRANSFORMATIONS
32063226

32073227

3228+
/**
3229+
* Set the current transformation matrix to identity.
3230+
*/
3231+
public void resetMatrix() {
3232+
}
3233+
3234+
32083235
/**
32093236
* Translate in X and Y.
32103237
*/
@@ -3289,59 +3316,6 @@ public void scale(float x, float y, float z) {
32893316
}
32903317

32913318

3292-
3293-
//////////////////////////////////////////////////////////////
3294-
3295-
// TRANSFORMATION MATRIX
3296-
3297-
3298-
/**
3299-
* Push a copy of the current transformation matrix onto the stack.
3300-
*/
3301-
public void pushMatrix() {
3302-
}
3303-
3304-
3305-
/**
3306-
* Replace the current transformation matrix with the top of the stack.
3307-
*/
3308-
public void popMatrix() {
3309-
}
3310-
3311-
3312-
/**
3313-
* Set the current transformation matrix to identity.
3314-
*/
3315-
public void resetMatrix() {
3316-
}
3317-
3318-
3319-
// public PMatrix getMatrix() {
3320-
// return null;
3321-
// }
3322-
3323-
3324-
// public PMatrix2D getMatrix2D() {
3325-
// return null;
3326-
// }
3327-
3328-
3329-
public void getMatrix(PMatrix2D target) {
3330-
}
3331-
3332-
3333-
public void getMatrix(PMatrix3D target) {
3334-
}
3335-
3336-
3337-
public void setMatrix(PMatrix2D source) {
3338-
}
3339-
3340-
3341-
public void setMatrix(PMatrix3D source) {
3342-
}
3343-
3344-
33453319
public void applyMatrix(PMatrix2D source) {
33463320
applyMatrix(source.m00, source.m01, source.m02,
33473321
source.m10, source.m11, source.m12);
@@ -3373,26 +3347,49 @@ public void applyMatrix(float n00, float n01, float n02, float n03,
33733347
float n30, float n31, float n32, float n33) {
33743348
}
33753349

3350+
3351+
3352+
//////////////////////////////////////////////////////////////
33763353

3377-
/**
3378-
* Loads the current matrix into the local 'matrix' object so that the values
3379-
* can be used for other purposes.
3380-
* <P/>
3381-
* Note that there is no "updateMatrix" because that gets too
3382-
* complicated (unnecessary) when considering the 3D matrices.
3383-
*/
3384-
// public void loadMatrix() {
3385-
// }
3386-
3354+
// MATRIX GET/SET/PRINT
33873355

3356+
33883357
/**
33893358
* Print the current model (or "transformation") matrix.
33903359
*/
33913360
public void printMatrix() {
33923361
}
33933362

3363+
3364+
/**
3365+
* Copy the current transformation matrix into the specified target.
3366+
*/
3367+
public void getMatrix(PMatrix2D target) {
3368+
}
3369+
3370+
3371+
/**
3372+
* Copy the current transformation matrix into the specified target.
3373+
*/
3374+
public void getMatrix(PMatrix3D target) {
3375+
}
3376+
3377+
3378+
/**
3379+
* Set the current transformation to the contents of the specified source.
3380+
*/
3381+
public void setMatrix(PMatrix2D source) {
3382+
}
3383+
3384+
3385+
/**
3386+
* Set the current transformation to the contents of the specified source.
3387+
*/
3388+
public void setMatrix(PMatrix3D source) {
3389+
}
33943390

33953391

3392+
33963393
//////////////////////////////////////////////////////////////
33973394

33983395
// CAMERA (none are supported in 2D)
@@ -4150,10 +4147,124 @@ protected void fillFromCalc() {
41504147
fillAlpha = calcAlpha;
41514148
}
41524149

4150+
41534151

41544152
//////////////////////////////////////////////////////////////
41554153

4154+
// MATERIAL PROPERTIES
41564155

4156+
4157+
public void ambient(int rgb) {
4158+
if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above
4159+
ambient((float) rgb);
4160+
4161+
} else {
4162+
colorCalcARGB(rgb, colorModeA);
4163+
ambientFromCalc();
4164+
}
4165+
}
4166+
4167+
4168+
public void ambient(float gray) {
4169+
colorCalc(gray);
4170+
ambientFromCalc();
4171+
}
4172+
4173+
4174+
public void ambient(float x, float y, float z) {
4175+
colorCalc(x, y, z);
4176+
ambientFromCalc();
4177+
}
4178+
4179+
4180+
protected void ambientFromCalc() {
4181+
ambientR = calcR;
4182+
ambientG = calcG;
4183+
ambientB = calcB;
4184+
// material.ambient(calcR, calcG, calcB);
4185+
}
4186+
4187+
4188+
//////////////////////////////////////////////////////////////
4189+
4190+
4191+
public void specular(int rgb) {
4192+
if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above
4193+
specular((float) rgb);
4194+
4195+
} else {
4196+
colorCalcARGB(rgb, colorModeA);
4197+
specularFromCalc();
4198+
}
4199+
}
4200+
4201+
4202+
public void specular(float gray) {
4203+
colorCalc(gray);
4204+
specularFromCalc();
4205+
}
4206+
4207+
4208+
public void specular(float x, float y, float z) {
4209+
colorCalc(x, y, z);
4210+
specularFromCalc();
4211+
}
4212+
4213+
4214+
protected void specularFromCalc() {
4215+
specularR = calcR;
4216+
specularG = calcG;
4217+
specularB = calcB;
4218+
//specularA = calcA;
4219+
//specularRi = calcRi;
4220+
//specularGi = calcGi;
4221+
//specularBi = calcBi;
4222+
//specularAi = calcAi;
4223+
}
4224+
4225+
4226+
public void shininess(float shine) {
4227+
shininess = shine;
4228+
}
4229+
4230+
4231+
//////////////////////////////////////////////////////////////
4232+
4233+
4234+
public void emissive(int rgb) {
4235+
if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above
4236+
emissive((float) rgb);
4237+
4238+
} else {
4239+
colorCalcARGB(rgb, colorModeA);
4240+
emissiveFromCalc();
4241+
}
4242+
}
4243+
4244+
4245+
public void emissive(float gray) {
4246+
colorCalc(gray);
4247+
emissiveFromCalc();
4248+
}
4249+
4250+
4251+
public void emissive(float x, float y, float z) {
4252+
colorCalc(x, y, z);
4253+
emissiveFromCalc();
4254+
}
4255+
4256+
4257+
protected void emissiveFromCalc() {
4258+
emissiveR = calcR;
4259+
emissiveG = calcG;
4260+
emissiveB = calcB;
4261+
//emissiveRi = calcRi;
4262+
//emissiveGi = calcGi;
4263+
//emissiveBi = calcBi;
4264+
}
4265+
4266+
4267+
/*
41574268
public void ambient(int rgb) {
41584269
showDepthError("ambient");
41594270
}
@@ -4199,8 +4310,10 @@ public void emissive(float gray) {
41994310
public void emissive(float x, float y, float z ) {
42004311
showDepthError("emissive");
42014312
}
4313+
*/
42024314

42034315

4316+
42044317
//////////////////////////////////////////////////////////////
42054318

42064319
// LIGHTS
@@ -4468,7 +4581,6 @@ static protected void throwTextFontError(String method) {
44684581

44694582

44704583

4471-
44724584
//////////////////////////////////////////////////////////////
44734585

44744586
// COLOR MANIPULATION
@@ -4704,17 +4816,6 @@ static public int lerpColor(int c1, int c2, float amt, int mode) {
47044816
}
47054817

47064818

4707-
//////////////////////////////////////////////////////////////
4708-
4709-
// MATH
4710-
4711-
4712-
static final float sqrt(float a) {
4713-
return (float)Math.sqrt(a);
4714-
}
4715-
4716-
4717-
47184819
//////////////////////////////////////////////////////////////
47194820

47204821

core/src/processing/core/PGraphics2D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ private void thick_flat_line(float ox1, float oy1,
13561356

13571357
float dX = ox2-ox1 + EPSILON;
13581358
float dY = oy2-oy1 + EPSILON;
1359-
float len = sqrt(dX*dX + dY*dY);
1359+
float len = (float) Math.sqrt(dX*dX + dY*dY);
13601360

13611361
// TODO strokeWidth should be transformed!
13621362
float rh = strokeWeight / len;

core/src/processing/core/PGraphics3D.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,6 +3698,11 @@ public void noSmooth() {
36983698
// MATH (internal use only)
36993699

37003700

3701+
private final float sqrt(float a) {
3702+
return (float) Math.sqrt(a);
3703+
}
3704+
3705+
37013706
private final float mag(float a, float b, float c) {
37023707
return (float) Math.sqrt(a*a + b*b + c*c);
37033708
}

0 commit comments

Comments
 (0)