save the sphere detail from the renderer when creating a PShape (or pass

it as a parameter to createShape)
This commit is contained in:
codeanticode
2013-08-25 13:54:12 -04:00
parent 764be11cc9
commit 6bd22196b7
3 changed files with 15 additions and 5 deletions
+2
View File
@@ -166,6 +166,8 @@ public class PShape implements PConstants {
protected int emissiveColor;
protected float shininess;
protected int sphereDetailU, sphereDetailV;
/** Temporary toggle for whether styles should be honored. */
protected boolean style = true;
+1 -1
View File
@@ -277,7 +277,7 @@ public class PGraphics3D extends PGraphicsOpenGL {
shape = new PShapeOpenGL(parent, PShape.PRIMITIVE);
shape.setKind(BOX);
} else if (kind == SPHERE) {
if (len != 1) {
if (len < 1 || 3 < len) {
showWarning("Wrong number of parameters");
return null;
}
+12 -4
View File
@@ -330,6 +330,9 @@ public class PShapeOpenGL extends PShape {
emissiveColor = pg.emissiveColor;
shininess = pg.shininess;
sphereDetailU = pg.sphereDetailU;
sphereDetailV = pg.sphereDetailV;
normalX = normalY = 0;
normalZ = 1;
@@ -2787,12 +2790,17 @@ public class PShapeOpenGL extends PShape {
protected void tessellateSphere() {
// Getting sphere detail from renderer. Is this correct?
int nu = pg.sphereDetailU;
int nv = pg.sphereDetailV;
float r = 0;
if (params.length == 1) {
int nu = sphereDetailU;
int nv = sphereDetailV;
if (1 <= params.length) {
r = params[0];
if (params.length == 2) {
nu = nv = (int)params[1];
} else if (params.length == 3) {
nu = (int)params[1];
nv = (int)params[2];
}
}
inGeo.setMaterial(fillColor, strokeColor, strokeWeight,