Skip to content

Commit ebf861a

Browse files
committed
OBJ-loading code moved into PShapeOBJ, removed PShape2D and PShap3D
1 parent 85a44aa commit ebf861a

7 files changed

Lines changed: 662 additions & 723 deletions

File tree

core/src/processing/core/PShape.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ public class PShape implements PConstants {
205205
/** True if colorMode(RGB, 255) */
206206
boolean colorModeDefault; // = true;
207207

208+
/** True if contains 3D data */
209+
protected boolean is3D = false;
208210

209211
// should this be called vertices (consistent with PGraphics internals)
210212
// or does that hurt flexibility?
@@ -430,15 +432,20 @@ protected PVector getBottom(PVector bottom) {
430432
* Return true if this shape is 2D. Defaults to true.
431433
*/
432434
public boolean is2D() {
433-
return true;
435+
return !is3D;
434436
}
435437

436438

437439
/**
438440
* Return true if this shape is 3D. Defaults to false.
439441
*/
440442
public boolean is3D() {
441-
return false;
443+
return is3D;
444+
}
445+
446+
447+
public void is3D(boolean val) {
448+
is3D = val;
442449
}
443450

444451

@@ -840,9 +847,13 @@ static protected void copyGeometry(PShape src, PShape dest) {
840847
// s.emissive(vert[ER] * 255, vert[EG] * 255, vert[EB] * 255);
841848
// s.shininess(vert[SHINE]);
842849

843-
dest.normal(vert[PGraphics.NX],
844-
vert[PGraphics.NY],
845-
vert[PGraphics.NZ]);
850+
if (0 < PApplet.dist(vert[PGraphics.NX],
851+
vert[PGraphics.NY],
852+
vert[PGraphics.NZ], 0, 0, 0)) {
853+
dest.normal(vert[PGraphics.NX],
854+
vert[PGraphics.NY],
855+
vert[PGraphics.NZ]);
856+
}
846857
dest.vertex(vert[X], vert[Y], vert[Z],
847858
vert[PGraphics.U],
848859
vert[PGraphics.V]);

0 commit comments

Comments
 (0)