a few more example updates

This commit is contained in:
codeanticode
2013-02-13 11:14:25 -05:00
parent f39e24e4f8
commit 6675f2b1f5
7 changed files with 40 additions and 28 deletions
@@ -11,7 +11,8 @@ class Particle {
Particle() {
partSize = random(10,60);
part = createShape(QUAD);
part = createShape();
part.beginShape(QUAD);
part.noStroke();
part.texture(sprite);
part.normal(0, 0, 1);
@@ -19,7 +20,7 @@ class Particle {
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
part.end();
part.endShape();
rebirth(width/2,height/2);
lifespan = random(255);
@@ -52,7 +53,7 @@ class Particle {
lifespan = lifespan - 1;
velocity.add(gravity);
part.tint(255,lifespan);
part.setTint(color(255,lifespan));
part.translate(velocity.x, velocity.y);
}
}
@@ -50,6 +50,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
if (renderMode == 0) {
model = createShape();
model.beginShape();
model.stroke(ribbonColor);
model.noFill();
model.beginContour();
@@ -70,12 +71,13 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
model.vertex(posVec.x, posVec.y, posVec.z);
}
model.endContour();
model.end(OPEN);
model.endShape(OPEN);
} else {
// The ribbon construction is fairly inneficient here, since
// it could use triangle strips instead to avoid duplicating
// shared vertices...
model = createShape(TRIANGLES);
model = createShape();
model.beginShape(TRIANGLES);
model.noStroke();
model.fill(ribbonColor);
for (int i = 0; i < vertices.size(); i++) {
@@ -84,7 +86,7 @@ void createRibbonModel(ArrayList residues, PShape model, ArrayList trj) {
model.normal(-normVec.x, -normVec.y, -normVec.z);
model.vertex(posVec.x, posVec.y, posVec.z);
}
model.end();
model.endShape();
}
trj.add(model);
@@ -10,7 +10,8 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
PVector n0, n1, n2;
float u0, u1, v0, v1;
PShape obj = createShape(TRIANGLES);
PShape obj = createShape();
obj.beginShape(TRIANGLES);
obj.texture(tex);
for (int j = 0; j < nx; j++) {
@@ -49,7 +50,7 @@ PShape createTrefoil(float s, int ny, int nx, PImage tex) {
obj.vertex(s * p1.x, s * p1.y, s * p1.z, u1, v0);
}
}
obj.end();
obj.endShape();
return obj;
}
@@ -61,7 +61,8 @@ void createCube() {
PShape face;
// Front face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -79,11 +80,12 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
// Back face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -101,11 +103,12 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
// Right face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -123,11 +126,12 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
// Left face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -145,11 +149,12 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
// Top face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -167,11 +172,12 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
// Bottom face
face = createShape(POLYGON);
face = createShape();
face.beginShape(POLYGON);
face.stroke(255, 0, 0);
face.fill(255);
face.beginContour();
@@ -189,7 +195,7 @@ void createCube() {
face.vertex(x, y, z);
}
face.endContour();
face.end(CLOSE);
face.endShape(CLOSE);
cube.addChild(face);
}
@@ -16,7 +16,7 @@ void setup() {
noSmooth();
noStroke();
grid = createShape(PShape.GROUP);
grid = createShape(GROUP);
// Build grid using multiple translations
for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){
@@ -26,7 +26,7 @@ void setup() {
// ensures values stay within legal range
boxFill = color(abs(i), abs(j), abs(k), 50);
PShape cube = createShape(BOX, boxSize, boxSize, boxSize);
cube.fill(boxFill);
cube.setFill(boxFill);
cube.translate(k, j, i);
grid.addChild(cube);
}
@@ -24,7 +24,8 @@ void setup() {
sprite = loadImage("sprite.png");
for (int n = 0; n < npartTotal; n++) {
PShape part = createShape(QUAD);
PShape part = createShape();
part.beginShape(QUAD);
part.noStroke();
part.texture(sprite);
part.normal(0, 0, 1);
@@ -32,7 +33,7 @@ void setup() {
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
part.end();
part.endShape();
particles.addChild(part);
}
@@ -59,7 +60,7 @@ void draw () {
if (0 <= lifetimes[n]) {
float opacity = 1.0 - float(lifetimes[n]) / partLifetime;
part.tint(255, opacity * 255);
part.setTint(color(255, opacity * 255));
if (lifetimes[n] == 0) {
// Re-spawn dead particle
@@ -74,7 +75,7 @@ void draw () {
velocities[n].y += gravity;
}
} else {
part.tint(0, 0);
part.setTint(color(0));
}
}
@@ -21,7 +21,8 @@ void setup() {
float cy = random(-500, +500);
float cz = random(-500, +500);
PShape part = createShape(QUAD);
PShape part = createShape();
part.beginShape(QUAD);
part.noStroke();
part.tint(255);
part.texture(sprite);
@@ -30,7 +31,7 @@ void setup() {
part.vertex(cx + partSize/2, cy - partSize/2, cz, sprite.width, 0);
part.vertex(cx + partSize/2, cy + partSize/2, cz, sprite.width, sprite.height);
part.vertex(cx - partSize/2, cy + partSize/2, cz, 0, sprite.height);
part.end();
part.endShape();
particles.addChild(part);
}