Putting drawing methods from PShape3D in PShape, updated examples

This commit is contained in:
codeanticode
2011-12-12 05:44:39 +00:00
parent e051c1325c
commit 1ee3dab312
5 changed files with 186 additions and 35 deletions
@@ -1,6 +1,6 @@
size(100, 100, P3D);
PShape3D obj = (PShape3D)createShape(POLYGON);
PShape obj = createShape(POLYGON);
obj.fill(0, 255, 0, 255);
obj.stroke(0, 0, 255, 255);
obj.strokeWeight(5);
@@ -1,4 +1,4 @@
PShape3D circle;
PShape circle;
public void setup() {
size(400, 400, P3D);
@@ -7,7 +7,7 @@ public void setup() {
fill(255, 0, 0);
stroke(0, 0, 255);
strokeWeight(3);
circle = (PShape3D) createShape(ELLIPSE, 0, 0, 100, 100);
circle = createShape(ELLIPSE, 0, 0, 100, 100);
}
public void draw () {
@@ -18,7 +18,6 @@ public void draw () {
circle.stroke(0, 0, map(mouseY, 0, height, 255, 0));
}
translate(mouseX, mouseY);
shape(circle);
}
@@ -1,7 +1,7 @@
size(100, 100, P3D);
smooth();
PShape3D obj = (PShape3D)createShape();
PShape obj = createShape();
obj.noFill();
obj.stroke(0);
obj.strokeWeight(1);
@@ -294,6 +294,27 @@ public class PShape3D extends PShape {
}
}
public void addShape(PShape child) {
if (family == GROUP) {
super.addChild(child);
child.updateRoot(root);
root.modified = true;
modified = true;
child.modified = true;
} else {
PGraphics.showWarning("Cannot add child shape to non-group shape.");
}
}
public void updateRoot(PShape root) {
this.root = (PShape3D) root;
if (family == GROUP) {
for (int i = 0; i < childCount; i++) {
PShape3D child = (PShape3D)children[i];
child.updateRoot(root);
}
}
}
protected void finalize() throws Throwable {
try {
@@ -1651,28 +1672,6 @@ public class PShape3D extends PShape {
getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
}
public void addShape(PShape3D child) {
if (family == GROUP) {
super.addChild(child);
child.updateRoot(root);
root.modified = true;
modified = true;
child.modified = true;
} else {
PGraphics.showWarning("Cannot add child shape to non-group shape.");
}
}
private void updateRoot(PShape3D root) {
this.root = root;
if (family == GROUP) {
for (int i = 0; i < childCount; i++) {
PShape3D child = (PShape3D)children[i];
child.updateRoot(root);
}
}
}
///////////////////////////////////////////////////////////