diff --git a/java/examples/3D/Camera/MoveEye/MoveEye.pde b/java/examples/3D/Camera/MoveEye/MoveEye.pde deleted file mode 100644 index 6a6384640..000000000 --- a/java/examples/3D/Camera/MoveEye/MoveEye.pde +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Move Eye. - * by Simon Greenwold. - * - * The camera lifts up (controlled by mouseY) while looking at the same point. - */ - -void setup() { - size(640, 360, P3D); - fill(204); -} - -void draw() { - lights(); - background(0); - - // Change height of the camera with mouseY - camera(30.0, mouseY, 220.0, // eyeX, eyeY, eyeZ - 0.0, 0.0, 0.0, // centerX, centerY, centerZ - 0.0, 1.0, 0.0); // upX, upY, upZ - - noStroke(); - box(90); - stroke(255); - line(-100, 0, 0, 100, 0, 0); - line(0, -100, 0, 0, 100, 0); - line(0, 0, -100, 0, 0, 100); -} diff --git a/java/examples/3D/Camera/OrthoVSPerspective/OrthoVSPerspective.pde b/java/examples/3D/Camera/OrthoVSPerspective/OrthoVSPerspective.pde deleted file mode 100644 index 9c9a0ff1d..000000000 --- a/java/examples/3D/Camera/OrthoVSPerspective/OrthoVSPerspective.pde +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Ortho vs Perspective. - * - * Click to see the difference between orthographic projection - * and perspective projection as applied to a simple box. - * The ortho() function sets an orthographic projection and - * defines a parallel clipping volume. All objects with the - * same dimension appear the same size, regardless of whether - * they are near or far from the camera. The parameters to this - * function specify the clipping volume where left and right - * are the minimum and maximum x values, top and bottom are the - * minimum and maximum y values, and near and far are the minimum - * and maximum z values. - */ - -void setup() -{ - size(640, 360, P3D); - noStroke(); - fill(204); -} - -void draw() -{ - background(0); - lights(); - - if(mousePressed) { - float fov = PI/3.0; - float cameraZ = (height/2.0) / tan(fov/2.0); - perspective(fov, float(width)/float(height), - cameraZ/2.0, cameraZ*2.0); - } else { - ortho(0, width, 0, height); - } - - translate(width/2, height/2, 0); - rotateX(-PI/6); - rotateY(PI/3); - box(160); -} - diff --git a/java/examples/3D/Camera/Perspective/Perspective.pde b/java/examples/3D/Camera/Perspective/Perspective.pde deleted file mode 100644 index 46695397d..000000000 --- a/java/examples/3D/Camera/Perspective/Perspective.pde +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Perspective. - * - * Move the mouse left and right to change the field of view (fov). - * Click to modify the aspect ratio. The perspective() function - * sets a perspective projection applying foreshortening, making - * distant objects appear smaller than closer ones. The parameters - * define a viewing volume with the shape of truncated pyramid. - * Objects near to the front of the volume appear their actual size, - * while farther objects appear smaller. This projection simulates - * the perspective of the world more accurately than orthographic projection. - * The version of perspective without parameters sets the default - * perspective and the version with four parameters allows the programmer - * to set the area precisely. - */ - -void setup() { - size(640, 360, P3D); - noStroke(); -} - -void draw() { - lights(); - background(204); - float cameraY = height/2.0; - float fov = mouseX/float(width) * PI/2; - float cameraZ = cameraY / tan(fov / 2.0); - float aspect = float(width)/float(height); - if (mousePressed) { - aspect = aspect / 2.0; - } - perspective(fov, aspect, cameraZ/10.0, cameraZ*10.0); - - translate(width/2+30, height/2, 0); - rotateX(-PI/6); - rotateY(PI/3 + mouseY/float(height) * PI); - box(45); - translate(0, 0, -50); - box(30); -} - diff --git a/java/examples/3D/Form/CubicGrid/CubicGrid.pde b/java/examples/3D/Form/CubicGrid/CubicGrid.pde deleted file mode 100644 index 111cd3f3f..000000000 --- a/java/examples/3D/Form/CubicGrid/CubicGrid.pde +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Cubic Grid - * by Ira Greenberg. - * - * 3D translucent colored grid uses nested pushMatrix() - * and popMatrix() functions. - */ - -float boxSize = 40; -float margin = boxSize*2; -float depth = 400; -color boxFill; - -void setup() { - size(640, 360, P3D); - noStroke(); -} - -void draw() { - background(255); - - // Center and spin grid - translate(width/2, height/2, -depth); - rotateY(frameCount * 0.01); - rotateX(frameCount * 0.01); - - // Build grid using multiple translations - for (float i =- depth/2+margin; i <= depth/2-margin; i += boxSize){ - pushMatrix(); - for (float j =- height+margin; j <= height-margin; j += boxSize){ - pushMatrix(); - for (float k =- width+margin; k <= width-margin; k += boxSize){ - // Base fill color on counter values, abs function - // ensures values stay within legal range - boxFill = color(abs(i), abs(j), abs(k), 50); - pushMatrix(); - translate(k, j, i); - fill(boxFill); - box(boxSize, boxSize, boxSize); - popMatrix(); - } - popMatrix(); - } - popMatrix(); - } -} - diff --git a/java/examples/3D/Form/RunAmuck/Legs.pde b/java/examples/3D/Form/RunAmuck/Legs.pde deleted file mode 100644 index eb74d7859..000000000 --- a/java/examples/3D/Form/RunAmuck/Legs.pde +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Legs class - * By Ira Greenberg
- * Processing for Flash Developers, - * Friends of ED, 2009 - */ - -class Legs { - // Instance properties with default values - float x = 0, y = 0, z = 0, w = 150, ht = 125; - color col = #77AA22; - // Advanced properties - float detailW = w/6.0; - float detailHt = ht/8.0; - float shoeBulge = detailHt*2.0; - float legGap = w/7.0; - - // Dynamics properties - float velocity = .02, stepL, stepR, stepRate = random(10, 50); - float speedX = 1.0, speedZ, spring, damping = .5, theta; - - // Default constructor - Legs() { - } - - // Standard constructor - Legs(float x, float z, float w, float ht, color col) { - this.x = x; - this.z = z; - this.w = w; - this.ht = ht; - this.col = col; - fill(col); - detailW = w/6.0; - detailHt = ht/8.0; - shoeBulge = detailHt*2.0; - legGap = w/7.0; - speedX = random(-speedX, speedX); - } - - // Advanced constructor - Legs(float x, float z, float w, float ht, color col, float detailW, - float detailHt, float shoeBulge, float legGap) { - this.x = x; - this.z = z; - this.w = w; - this.ht = ht; - this.col = col; - this.detailW = detailW; - this.detailHt = detailHt; - this.shoeBulge = shoeBulge; - this.legGap = legGap; - speedX = random(-speedX, speedX); - } - - // Draw legs - void create() { - fill(col); - float footWidth = (w - legGap)/2; - beginShape(); - vertex(x - w/2, y - ht, z); - vertex(x - w/2, y - ht + detailHt, z); - vertex(x - w/2 + detailW, y - ht + detailHt, z); - // left foot - vertex(x - w/2 + detailW, y + stepL, z); - curveVertex(x - w/2 + detailW, y + stepL, z); - curveVertex(x - w/2 + detailW, y + stepL, z); - curveVertex(x - w/2 + detailW - shoeBulge, y + detailHt/2 + stepL, z); - curveVertex(x - w/2, y + detailHt + stepL, z); - curveVertex(x - w/2, y + detailHt + stepL, z); - vertex(x - w/2 + footWidth, y + detailHt + stepL*.9, z); - // end left foot - vertex(x - w/2 + footWidth + legGap/2, y - ht + detailHt, z); - vertex(x - w/2 + footWidth + legGap/2, y - ht + detailHt, z); - // right foot - vertex(x - w/2 + footWidth + legGap, y + detailHt + stepR*.9, z); - vertex(x + w/2, y + detailHt + stepR, z); - curveVertex(x + w/2, y + detailHt + stepR, z); - curveVertex(x + w/2, y + detailHt + stepR, z); - curveVertex(x + w/2 - detailW + shoeBulge, y + detailHt/2 + stepR, z); - curveVertex(x + w/2 - detailW, y + stepR, z); - vertex(x + w/2 - detailW, y + stepR, z); - // end right foot - vertex(x + w/2 - detailW, y - ht + detailHt, z); - vertex(x + w/2, y - ht + detailHt, z); - vertex(x + w/2, y - ht, z); - endShape(CLOSE); - } - - // Set advanced property values - void setDetails(float detailW, float detailHt, float shoeBulge, float legGap) { - this.detailW = detailW; - this.detailHt = detailHt; - this.shoeBulge = shoeBulge; - this.legGap = legGap; - } - - // Make the legs step - void step(float stepRate) { - this.stepRate = stepRate; - spring = ht/2.0; - stepL = sin(theta)*spring; - stepR = cos(theta)*spring; - theta += radians(stepRate); - } - - // Alternative overloaded step method - void step() { - spring = ht/2.0; - stepL = sin(theta)*spring; - stepR = cos(theta)*spring; - theta += radians(stepRate); - } - - - // Moves legs along x, y, z axes - void move() { - // Move legs along y-axis - y = stepR*damping; - - // Move legs along x-axis and - // check for collision against frame edge - x += speedX; - if (screenX(x, y, z) > width) { - speedX *= -1; - } - if (screenX(x, y, z) < 0) { - speedX *= -1; - } - - // Move legs along z-axis based on speed of stepping - // and check for collision against extremes - speedZ = (stepRate*velocity); - z += speedZ; - if (z > 400) { - z = 400; - velocity *= -1; - } - if (z < -100) { - z = -100; - velocity *= -1; - } - } - - void setDynamics(float speedX, float spring, float damping) { - this.speedX = speedX; - this.spring = spring; - this.damping = damping; - } -} - - - - - - - - - - - - diff --git a/java/examples/3D/Form/RunAmuck/RunAmuck.pde b/java/examples/3D/Form/RunAmuck/RunAmuck.pde deleted file mode 100644 index 7a5b06fc2..000000000 --- a/java/examples/3D/Form/RunAmuck/RunAmuck.pde +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Run-Amuck - * By Ira Greenberg
- * Processing for Flash Developers, - * Friends of ED, 2009 - */ - -int count = 250; -Legs[] legs = new Legs[count]; - -void setup() { - size(640, 360, P3D); - noStroke(); - for (int i = 0; i < legs.length; i++) { - legs[i] = new Legs(random(-10, 10), random(-50, 150), random(.5, 5), - random(.5, 5), color(random(255), random(255), random(255))); - } -} - -void draw() { - background(0); - translate(width/2, height/2); - noStroke(); - fill(35); - - // Draw ground plane - beginShape(); - vertex(-width*2, 0, -1000); - vertex(width*2, 0, -1000); - vertex(width/2, height/2, 400); - vertex(-width/2, height/2, 400); - endShape(CLOSE); - - // Update and draw the legs - for (int i = 0; i < legs.length; i++) { - legs[i].create(); - // Set foot step rate - legs[i].step(random(10, 50)); - // Move legs along x, y, z axes - // z-movement dependent upon step rate - legs[i].move(); - } -} - - diff --git a/java/examples/3D/Lights/Directional/Directional.pde b/java/examples/3D/Lights/Directional/Directional.pde deleted file mode 100644 index 6a1af3008..000000000 --- a/java/examples/3D/Lights/Directional/Directional.pde +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Directional. - * - * Move the mouse the change the direction of the light. - * Directional light comes from one direction and is stronger - * when hitting a surface squarely and weaker if it hits at a - * a gentle angle. After hitting a surface, a directional lights - * scatters in all directions. - */ - -void setup() { - size(640, 360, P3D); - noStroke(); - fill(204); -} - -void draw() { - noStroke(); - background(0); - float dirY = (mouseY / float(height) - 0.5) * 2; - float dirX = (mouseX / float(width) - 0.5) * 2; - directionalLight(204, 204, 204, -dirX, -dirY, -1); - translate(width/2 - 100, height/2, 0); - sphere(80); - translate(200, 0, 0); - sphere(80); -} - diff --git a/java/examples/3D/Lights/Lights1/Lights1.pde b/java/examples/3D/Lights/Lights1/Lights1.pde deleted file mode 100644 index bf7a36edc..000000000 --- a/java/examples/3D/Lights/Lights1/Lights1.pde +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Lights 1. - * - * Uses the default lights to show a simple box. The lights() function - * is used to turn on the default lighting. - */ - -float spin = 0.0; - -void setup() -{ - size(640, 360, P3D); - noStroke(); -} - -void draw() -{ - background(51); - lights(); - - spin += 0.01; - - pushMatrix(); - translate(width/2, height/2, 0); - rotateX(PI/9); - rotateY(PI/5 + spin); - box(150); - popMatrix(); -} diff --git a/java/examples/3D/Lights/Lights2/Lights2.pde b/java/examples/3D/Lights/Lights2/Lights2.pde deleted file mode 100644 index e1693e590..000000000 --- a/java/examples/3D/Lights/Lights2/Lights2.pde +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Lights 2 - * by Simon Greenwold. - * - * Display a box with three different kinds of lights. - */ - -void setup() -{ - size(640, 360, P3D); - noStroke(); -} - -void draw() -{ - background(0); - translate(width / 2, height / 2); - - // Orange point light on the right - pointLight(150, 100, 0, // Color - 200, -150, 0); // Position - - // Blue directional light from the left - directionalLight(0, 102, 255, // Color - 1, 0, 0); // The x-, y-, z-axis direction - - // Yellow spotlight from the front - spotLight(255, 255, 109, // Color - 0, 40, 200, // Position - 0, -0.5, -0.5, // Direction - PI / 2, 2); // Angle, concentration - - rotateY(map(mouseX, 0, width, 0, PI)); - rotateX(map(mouseY, 0, height, 0, PI)); - box(150); -} diff --git a/java/examples/3D/Lights/Reflection/Reflection.pde b/java/examples/3D/Lights/Reflection/Reflection.pde deleted file mode 100644 index f6a3d7a94..000000000 --- a/java/examples/3D/Lights/Reflection/Reflection.pde +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Reflection - * by Simon Greenwold. - * - * Vary the specular reflection component of a material - * with the horizontal position of the mouse. - */ - -void setup() { - size(640, 360, P3D); - noStroke(); - colorMode(RGB, 1); - fill(0.4); -} - -void draw() { - background(0); - translate(width / 2, height / 2); - // Set the specular color of lights that follow - lightSpecular(1, 1, 1); - directionalLight(0.8, 0.8, 0.8, 0, 0, -1); - float s = mouseX / float(width); - specular(s, s, s); - sphere(120); -} diff --git a/java/examples/3D/Lights/Spot/Spot.pde b/java/examples/3D/Lights/Spot/Spot.pde deleted file mode 100644 index ce25c4bee..000000000 --- a/java/examples/3D/Lights/Spot/Spot.pde +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Spot. - * - * Move the mouse the change the position and concentation - * of a blue spot light. - */ - -int concentration = 600; // Try values 1 -> 10000 - -void setup() -{ - //size(200, 200, P3D); - size(640, 360, P3D); - noStroke(); - fill(204); - sphereDetail(60); -} - -void draw() -{ - background(0); - - // Light the bottom of the sphere - directionalLight(51, 102, 126, 0, -1, 0); - - // Orange light on the upper-right of the sphere - spotLight(204, 153, 0, 360, 160, 600, 0, 0, -1, PI/2, 600); - - // Moving spotlight that follows the mouse - spotLight(102, 153, 204, 360, mouseY, 600, 0, 0, -1, PI/2, 600); - - translate(width/2, height/2, 0); - sphere(120); -} - diff --git a/java/examples/3D/Textures/Texture1/Texture1.pde b/java/examples/3D/Textures/Texture1/Texture1.pde deleted file mode 100644 index 7eb36310a..000000000 --- a/java/examples/3D/Textures/Texture1/Texture1.pde +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Texture 1. - * - * Load an image and draw it onto a quad. The texture() function sets - * the texture image. The vertex() function maps the image to the geometry. - */ - -PImage img; - -void setup() { - size(640, 360, P3D); - img = loadImage("berlin-1.jpg"); - noStroke(); -} - -void draw() { - background(0); - translate(width / 2, height / 2); - rotateY(map(mouseX, 0, width, -PI, PI)); - rotateZ(PI/6); - beginShape(); - texture(img); - vertex(-100, -100, 0, 0, 0); - vertex(100, -100, 0, 400, 0); - vertex(100, 100, 0, 400, 400); - vertex(-100, 100, 0, 0, 400); - endShape(); -} diff --git a/java/examples/3D/Textures/Texture2/Texture2.pde b/java/examples/3D/Textures/Texture2/Texture2.pde deleted file mode 100644 index 1398fd3e5..000000000 --- a/java/examples/3D/Textures/Texture2/Texture2.pde +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Texture 2. - * - * Using a rectangular image to map a texture onto a triangle. - */ - -PImage img; - -void setup() { - size(640, 360, P3D); - img = loadImage("berlin-1.jpg"); - noStroke(); -} - -void draw() { - background(0); - translate(width / 2, height / 2); - rotateY(map(mouseX, 0, width, -PI, PI)); - beginShape(); - texture(img); - vertex(-100, -100, 0, 0, 0); - vertex(100, -40, 0, 400, 120); - vertex(0, 100, 0, 200, 400); - endShape(); -} diff --git a/java/examples/3D/Textures/Texture3/Texture3.pde b/java/examples/3D/Textures/Texture3/Texture3.pde deleted file mode 100644 index 66130f1e5..000000000 --- a/java/examples/3D/Textures/Texture3/Texture3.pde +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Texture 3. - * - * Load an image and draw it onto a cylinder and a quad. - */ - - -int tubeRes = 32; -float[] tubeX = new float[tubeRes]; -float[] tubeY = new float[tubeRes]; -PImage img; - -void setup() { - size(640, 360, P3D); - img = loadImage("berlin-1.jpg"); - float angle = 270.0 / tubeRes; - for (int i = 0; i < tubeRes; i++) { - tubeX[i] = cos(radians(i * angle)); - tubeY[i] = sin(radians(i * angle)); - } - noStroke(); -} - -void draw() { - background(0); - translate(width / 2, height / 2); - rotateX(map(mouseY, 0, height, -PI, PI)); - rotateY(map(mouseX, 0, width, -PI, PI)); - beginShape(QUAD_STRIP); - texture(img); - for (int i = 0; i < tubeRes; i++) { - float x = tubeX[i] * 100; - float z = tubeY[i] * 100; - float u = img.width / tubeRes * i; - vertex(x, -100, z, u, 0); - vertex(x, 100, z, u, img.height); - } - endShape(); - beginShape(QUADS); - texture(img); - vertex(0, -100, 0, 0, 0); - vertex(100, -100, 0, 100, 0); - vertex(100, 100, 0, 100, 100); - vertex(0, 100, 0, 0, 100); - endShape(); -} diff --git a/java/examples/3D/Textures/TextureCube/TextureCube.pde b/java/examples/3D/Textures/TextureCube/TextureCube.pde deleted file mode 100644 index 38df04997..000000000 --- a/java/examples/3D/Textures/TextureCube/TextureCube.pde +++ /dev/null @@ -1,91 +0,0 @@ -/** - * TexturedCube - * by Dave Bollinger. - * - * Drag mouse to rotate cube. Demonstrates use of u/v coords in - * vertex() and effect on texture(). The textures get distorted using - * the P3D renderer as you can see, but they look great using OPENGL. -*/ - - -PImage tex; -float rotx = PI/4; -float roty = PI/4; - -void setup() -{ - size(640, 360, P3D); - tex = loadImage("berlin-1.jpg"); - textureMode(NORMALIZED); - fill(255); - stroke(color(44,48,32)); -} - -void draw() -{ - background(0); - noStroke(); - translate(width/2.0, height/2.0, -100); - rotateX(rotx); - rotateY(roty); - scale(90); - TexturedCube(tex); -} - -void TexturedCube(PImage tex) { - beginShape(QUADS); - texture(tex); - - // Given one texture and six faces, we can easily set up the uv coordinates - // such that four of the faces tile "perfectly" along either u or v, but the other - // two faces cannot be so aligned. This code tiles "along" u, "around" the X/Z faces - // and fudges the Y faces - the Y faces are arbitrarily aligned such that a - // rotation along the X axis will put the "top" of either texture at the "top" - // of the screen, but is not otherwised aligned with the X/Z faces. (This - // just affects what type of symmetry is required if you need seamless - // tiling all the way around the cube) - - // +Z "front" face - vertex(-1, -1, 1, 0, 0); - vertex( 1, -1, 1, 1, 0); - vertex( 1, 1, 1, 1, 1); - vertex(-1, 1, 1, 0, 1); - - // -Z "back" face - vertex( 1, -1, -1, 0, 0); - vertex(-1, -1, -1, 1, 0); - vertex(-1, 1, -1, 1, 1); - vertex( 1, 1, -1, 0, 1); - - // +Y "bottom" face - vertex(-1, 1, 1, 0, 0); - vertex( 1, 1, 1, 1, 0); - vertex( 1, 1, -1, 1, 1); - vertex(-1, 1, -1, 0, 1); - - // -Y "top" face - vertex(-1, -1, -1, 0, 0); - vertex( 1, -1, -1, 1, 0); - vertex( 1, -1, 1, 1, 1); - vertex(-1, -1, 1, 0, 1); - - // +X "right" face - vertex( 1, -1, 1, 0, 0); - vertex( 1, -1, -1, 1, 0); - vertex( 1, 1, -1, 1, 1); - vertex( 1, 1, 1, 0, 1); - - // -X "left" face - vertex(-1, -1, -1, 0, 0); - vertex(-1, -1, 1, 1, 0); - vertex(-1, 1, 1, 1, 1); - vertex(-1, 1, -1, 0, 1); - - endShape(); -} - -void mouseDragged() { - float rate = 0.01; - rotx += (pmouseY-mouseY) * rate; - roty += (mouseX-pmouseX) * rate; -} diff --git a/java/examples/3D/Transform/Bird/Bird.pde b/java/examples/3D/Transform/Bird/Bird.pde deleted file mode 100644 index dacd405d1..000000000 --- a/java/examples/3D/Transform/Bird/Bird.pde +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Simple 3D Bird - * by Ira Greenberg. - * - * Using a box and 2 rects to simulate a flying bird. - * Trig functions handle the flapping and sinuous movement. - */ - -float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; -float px = 0, py = 0, pz = 0; -float flapSpeed = 0.2; - -void setup(){ - size(640, 360, P3D); - noStroke(); -} - -void draw(){ - background(0); - lights(); - - // Flight - px = sin(radians(ang3)) * 170; - py = cos(radians(ang3)) * 300; - pz = sin(radians(ang4)) * 500; - translate(width/2 + px, height/2 + py, -700+pz); - rotateX(sin(radians(ang2)) * 120); - rotateY(sin(radians(ang2)) * 50); - rotateZ(sin(radians(ang2)) * 65); - - // Body - fill(153); - box(20, 100, 20); - - - // Left wing - fill(204); - pushMatrix(); - rotateY(sin(radians(ang)) * -20); - rect(-75, -50, 75, 100); - popMatrix(); - - // Right wing - pushMatrix(); - rotateY(sin(radians(ang)) * 20); - rect(0, -50, 75, 100); - popMatrix(); - - // Wing flap - ang += flapSpeed; - if (ang > 3) { - flapSpeed *= -1; - } - if (ang < -3) { - flapSpeed *= -1; - } - - // Increment angles - ang2 += 0.01; - ang3 += 2.0; - ang4 += 0.75; -} - diff --git a/java/examples/3D/Transform/Birds/Bird.pde b/java/examples/3D/Transform/Birds/Bird.pde deleted file mode 100644 index 84ada2603..000000000 --- a/java/examples/3D/Transform/Birds/Bird.pde +++ /dev/null @@ -1,99 +0,0 @@ -class Bird { - - // Properties - float offsetX, offsetY, offsetZ; - float w, h; - int bodyFill; - int wingFill; - float ang = 0, ang2 = 0, ang3 = 0, ang4 = 0; - float radiusX = 120, radiusY = 200, radiusZ = 700; - float rotX = 15, rotY = 10, rotZ = 5; - float flapSpeed = 0.4; - float rotSpeed = 0.1; - - // Constructors - Bird(){ - this(0, 0, 0, 60, 80); - } - - Bird(float offsetX, float offsetY, float offsetZ, - float w, float h){ - this.offsetX = offsetX; - this.offsetY = offsetY; - this.offsetZ = offsetZ; - this.h = h; - this.w = w; - bodyFill = color(153); - wingFill = color(204); - } - - void setFlight(float radiusX, float radiusY, float radiusZ, - float rotX, float rotY, float rotZ){ - this.radiusX = radiusX; - this.radiusY = radiusY; - this.radiusZ = radiusZ; - - this.rotX = rotX; - this.rotY = rotY; - this.rotZ = rotZ; - } - - void setWingSpeed(float flapSpeed){ - this.flapSpeed = flapSpeed; - } - - void setRotSpeed(float rotSpeed){ - this.rotSpeed = rotSpeed; - } - - void fly() { - pushMatrix(); - float px, py, pz; - - // Flight - px = sin(radians(ang3)) * radiusX; - py = cos(radians(ang3)) * radiusY; - pz = sin(radians(ang4)) * radiusZ; - - translate(width/2 + offsetX + px, height/2 + offsetY+py, -700 + offsetZ+pz); - - rotateX(sin(radians(ang2)) * rotX); - rotateY(sin(radians(ang2)) * rotY); - rotateZ(sin(radians(ang2)) * rotZ); - - // Body - fill(bodyFill); - box(w/5, h, w/5); - - // Left wing - fill(wingFill); - pushMatrix(); - rotateY(sin(radians(ang)) * 20); - rect(0, -h/2, w, h); - popMatrix(); - - // Right wing - pushMatrix(); - rotateY(sin(radians(ang)) * -20); - rect(-w, -h/2, w, h); - popMatrix(); - - // Wing flap - ang += flapSpeed; - if (ang > 3) { - flapSpeed*=-1; - } - if (ang < -3) { - flapSpeed*=-1; - } - - // Ang's run trig functions - ang2 += rotSpeed; - ang3 += 1.25; - ang4 += 0.55; - popMatrix(); - } -} - - - diff --git a/java/examples/3D/Transform/Birds/Birds.pde b/java/examples/3D/Transform/Birds/Birds.pde deleted file mode 100644 index 5026bd2ae..000000000 --- a/java/examples/3D/Transform/Birds/Birds.pde +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Crazy Flocking 3D Birds - * by Ira Greenberg. - * - * Simulates a flock of birds using a Bird class and nested - * pushMatrix() / popMatrix() functions. - * Trigonometry functions handle the flapping and sinuous movement. - */ - -// Flock array -int birdCount = 200; -Bird[]birds = new Bird[birdCount]; -float[]x = new float[birdCount]; -float[]y = new float[birdCount]; -float[]z = new float[birdCount]; -float[]rx = new float[birdCount]; -float[]ry = new float[birdCount]; -float[]rz = new float[birdCount]; -float[]spd = new float[birdCount]; -float[]rot = new float[birdCount]; - -void setup() { - size(640, 360, P3D); - noStroke(); - - // Initialize arrays with random values - for (int i = 0; i < birdCount; i++){ - birds[i] = new Bird(random(-300, 300), random(-300, 300), - random(-500, -2500), random(5, 30), random(5, 30)); - - x[i] = random(20, 340); - y[i] = random(30, 350); - z[i] = random(1000, 4800); - rx[i] = random(-160, 160); - ry[i] = random(-55, 55); - rz[i] = random(-20, 20); - spd[i] = random(.1, 3.75); - rot[i] = random(.025, .15); - } -} - -void draw() { - background(0); - lights(); - for (int i = 0; i < birdCount; i++){ - birds[i].setFlight(x[i], y[i], z[i], rx[i], ry[i], rz[i]); - birds[i].setWingSpeed(spd[i]); - birds[i].setRotSpeed(rot[i]); - birds[i].fly(); - } -} - - diff --git a/java/examples/3D/Transform/PushPopCubes/PushPopCubes.pde b/java/examples/3D/Transform/PushPopCubes/PushPopCubes.pde deleted file mode 100644 index 52ae70fdc..000000000 --- a/java/examples/3D/Transform/PushPopCubes/PushPopCubes.pde +++ /dev/null @@ -1,144 +0,0 @@ -/** - * PushPop Cubes - * by Ira Greenberg. - * - * Array of rotating cubes creates - * dynamic field patterns. Color - * controlled by light sources. Example - * of pushMatrix() and popMatrix(). - */ - -// Cube class required -float ang; -int rows = 21; -int cols = 21; -int cubeCount = rows*cols; -int colSpan, rowSpan; -float rotspd = 2.0; -Cube[] cubes = new Cube[cubeCount]; -float[] angs = new float[cubeCount]; -float[] rotvals = new float[cubeCount]; - -void setup(){ - size(640, 360, P3D); - - colSpan = width/(cols-1); - rowSpan = height/(rows-1); - noStroke(); - - // instantiate cubes - for (int i = 0; i < cubeCount; i++){ - cubes[i] = new Cube(12, 12, 6, 0, 0, 0); - /* 3 different rotation options - - 1st option: cubes each rotate uniformly - - 2nd option: cubes each rotate randomly - - 3rd option: cube columns rotate as waves - To try the different rotations, leave one - of the rotVals[i] lines uncommented below - and the other 2 commented out. */ - - //rotvals[i] = rotspd; - //rotvals[i] = random(-rotspd * 2, rotspd * 2); - rotvals[i] = rotspd += .01; - } -} - -void draw(){ - int cubeCounter = 0; - background(0); - fill(200); - - // Set up some different colored lights - pointLight(51, 102, 255, width/3, height/2, 100); - pointLight(200, 40, 60, width/1.5, height/2, -150); - - // Raise overall light in scene - ambientLight(170, 170, 100); - - // Translate, rotate and draw cubes - for (int i = 0; i < cols; i++){ - for (int j = 0; j < rows; j++){ - pushMatrix(); - /* Translate each block. - pushmatix and popmatrix add each cube - translation to matrix, but restore - original, so each cube rotates around its - owns center */ - translate(i * colSpan, j * rowSpan, -20); - //rotate each cube around y and x axes - rotateY(radians(angs[cubeCounter])); - rotateX(radians(angs[cubeCounter])); - cubes[cubeCounter].drawCube(); - popMatrix(); - cubeCounter++; - } - } - // Angs used in rotate function calls above - for (int i = 0; i < cubeCount; i++){ - angs[i] += rotvals[i]; - } -} - -// Simple Cube class, based on Quads -class Cube { - - // Properties - int w, h, d; - int shiftX, shiftY, shiftZ; - - // Constructor - Cube(int w, int h, int d, int shiftX, int shiftY, int shiftZ){ - this.w = w; - this.h = h; - this.d = d; - this.shiftX = shiftX; - this.shiftY = shiftY; - this.shiftZ = shiftZ; - } - - /* Main cube drawing method, which looks - more confusing than it really is. It's - just a bunch of rectangles drawn for - each cube face */ - void drawCube(){ - - // Front face - beginShape(QUADS); - vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, h + shiftY, -d/2 + shiftZ); - vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ); - - // Back face - vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ); - vertex(w + shiftX, -h/2 + shiftY, d + shiftZ); - vertex(w + shiftX, h + shiftY, d + shiftZ); - vertex(-w/2 + shiftX, h + shiftY, d + shiftZ); - - // Left face - vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ); - vertex(-w/2 + shiftX, h + shiftY, d + shiftZ); - vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ); - - // Right face - vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, -h/2 + shiftY, d + shiftZ); - vertex(w + shiftX, h + shiftY, d + shiftZ); - vertex(w + shiftX, h + shiftY, -d/2 + shiftZ); - - // Top face - vertex(-w/2 + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, -h/2 + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, -h/2 + shiftY, d + shiftZ); - vertex(-w/2 + shiftX, -h/2 + shiftY, d + shiftZ); - - // Bottom face - vertex(-w/2 + shiftX, h + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, h + shiftY, -d/2 + shiftZ); - vertex(w + shiftX, h + shiftY, d + shiftZ); - vertex(-w/2 + shiftX, h + shiftY, d + shiftZ); - endShape(); - } -} - diff --git a/java/examples/3D/Transform/Rotate1/Rotate1.pde b/java/examples/3D/Transform/Rotate1/Rotate1.pde deleted file mode 100644 index 7aafc250a..000000000 --- a/java/examples/3D/Transform/Rotate1/Rotate1.pde +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Rotate 1. - * - * Rotating simultaneously in the X and Y axis. - * Transformation functions such as rotate() are additive. - * Successively calling rotate(1.0) and rotate(2.0) - * is equivalent to calling rotate(3.0). - */ - -float a = 0.0; -float rSize; // rectangle size - -void setup() { - size(640, 360, P3D); - rSize = width / 6; - noStroke(); - fill(204, 204); -} - -void draw() { - background(0); - - a += 0.005; - if(a > TWO_PI) { - a = 0.0; - } - - translate(width/2, height/2); - - rotateX(a); - rotateY(a * 2.0); - rect(-rSize, -rSize, rSize*2, rSize*2); - - rotateX(a * 1.001); - rotateY(a * 2.002); - rect(-rSize, -rSize, rSize*2, rSize*2); - -} diff --git a/java/examples/3D/Transform/Rotate2/Rotate2.pde b/java/examples/3D/Transform/Rotate2/Rotate2.pde deleted file mode 100644 index 1d5af0d49..000000000 --- a/java/examples/3D/Transform/Rotate2/Rotate2.pde +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Rotate 2. - * - * The push() and pop() functions allow for more control over transformations. - * The push function saves the current coordinate system to the stack - * and pop() restores the prior coordinate system. - */ - -float a; // Angle of rotation -float offset = PI/24.0; // Angle offset between boxes -int num = 12; // Number of boxes -color[] colors = new color[num]; // Colors of each box -color safecolor; - -boolean pink = true; - -void setup() -{ - size(640, 360, P3D); - noStroke(); - for(int i=0; i0){ - buff = buff.substring(1); - } - break; - case 13: // Avoid special keys - case 10: - case 65535: - case 127: - case 27: - break; - default: - if(textWidth(buff+k)+leftmargin < width-rightmargin){ - didntTypeYet = false; - buff=k+buff; - } - break; - } -} - diff --git a/java/examples/3D/Typography/Typing/data/Univers45.vlw b/java/examples/3D/Typography/Typing/data/Univers45.vlw deleted file mode 100644 index 040e02170..000000000 Binary files a/java/examples/3D/Typography/Typing/data/Univers45.vlw and /dev/null differ diff --git a/java/examples/3D/Form/BrickTower/BrickTower.pde b/java/examples/Topics/Geometry/BrickTower/BrickTower.pde similarity index 100% rename from java/examples/3D/Form/BrickTower/BrickTower.pde rename to java/examples/Topics/Geometry/BrickTower/BrickTower.pde diff --git a/java/examples/3D/Form/BrickTower/Cube.pde b/java/examples/Topics/Geometry/BrickTower/Cube.pde similarity index 100% rename from java/examples/3D/Form/BrickTower/Cube.pde rename to java/examples/Topics/Geometry/BrickTower/Cube.pde diff --git a/java/examples/3D/Form/Icosahedra/Dimension3D.pde b/java/examples/Topics/Geometry/Icosahedra/Dimension3D.pde old mode 100755 new mode 100644 similarity index 100% rename from java/examples/3D/Form/Icosahedra/Dimension3D.pde rename to java/examples/Topics/Geometry/Icosahedra/Dimension3D.pde diff --git a/java/examples/3D/Form/Icosahedra/Icosahedra.pde b/java/examples/Topics/Geometry/Icosahedra/Icosahedra.pde old mode 100755 new mode 100644 similarity index 100% rename from java/examples/3D/Form/Icosahedra/Icosahedra.pde rename to java/examples/Topics/Geometry/Icosahedra/Icosahedra.pde diff --git a/java/examples/3D/Form/Icosahedra/Icosahedron.pde b/java/examples/Topics/Geometry/Icosahedra/Icosahedron.pde old mode 100755 new mode 100644 similarity index 100% rename from java/examples/3D/Form/Icosahedra/Icosahedron.pde rename to java/examples/Topics/Geometry/Icosahedra/Icosahedron.pde diff --git a/java/examples/3D/Form/Icosahedra/Shape3D.pde b/java/examples/Topics/Geometry/Icosahedra/Shape3D.pde old mode 100755 new mode 100644 similarity index 100% rename from java/examples/3D/Form/Icosahedra/Shape3D.pde rename to java/examples/Topics/Geometry/Icosahedra/Shape3D.pde diff --git a/java/examples/3D/Form/Primitives3D/Primitives3D.pde b/java/examples/Topics/Geometry/Primitives3D/Primitives3D.pde similarity index 100% rename from java/examples/3D/Form/Primitives3D/Primitives3D.pde rename to java/examples/Topics/Geometry/Primitives3D/Primitives3D.pde diff --git a/java/examples/3D/Form/RGBCube/RGBCube.pde b/java/examples/Topics/Geometry/RGBCube/RGBCube.pde similarity index 100% rename from java/examples/3D/Form/RGBCube/RGBCube.pde rename to java/examples/Topics/Geometry/RGBCube/RGBCube.pde diff --git a/java/examples/3D/Form/ShapeTransform/ShapeTransform.pde b/java/examples/Topics/Geometry/ShapeTransform/ShapeTransform.pde similarity index 100% rename from java/examples/3D/Form/ShapeTransform/ShapeTransform.pde rename to java/examples/Topics/Geometry/ShapeTransform/ShapeTransform.pde diff --git a/java/examples/3D/Form/Toroid/Toroid.pde b/java/examples/Topics/Geometry/Toroid/Toroid.pde similarity index 100% rename from java/examples/3D/Form/Toroid/Toroid.pde rename to java/examples/Topics/Geometry/Toroid/Toroid.pde diff --git a/java/examples/3D/Form/Vertices/Vertices.pde b/java/examples/Topics/Geometry/Vertices/Vertices.pde similarity index 100% rename from java/examples/3D/Form/Vertices/Vertices.pde rename to java/examples/Topics/Geometry/Vertices/Vertices.pde diff --git a/java/examples/3D/Image/Explode/Explode.pde b/java/examples/Topics/Image Processing/Explode/Explode.pde similarity index 100% rename from java/examples/3D/Image/Explode/Explode.pde rename to java/examples/Topics/Image Processing/Explode/Explode.pde diff --git a/java/examples/3D/Image/Explode/data/eames.jpg.tmp b/java/examples/Topics/Image Processing/Explode/data/eames.jpg.tmp similarity index 100% rename from java/examples/3D/Image/Explode/data/eames.jpg.tmp rename to java/examples/Topics/Image Processing/Explode/data/eames.jpg.tmp diff --git a/java/examples/3D/Image/Extrusion/Extrusion.pde b/java/examples/Topics/Image Processing/Extrusion/Extrusion.pde similarity index 100% rename from java/examples/3D/Image/Extrusion/Extrusion.pde rename to java/examples/Topics/Image Processing/Extrusion/Extrusion.pde diff --git a/java/examples/3D/Image/Zoom/Zoom.pde b/java/examples/Topics/Image Processing/Zoom/Zoom.pde similarity index 100% rename from java/examples/3D/Image/Zoom/Zoom.pde rename to java/examples/Topics/Image Processing/Zoom/Zoom.pde diff --git a/java/examples/3D/Transform/CubesWithinCube/Cube.pde b/java/examples/Topics/Motion/CubesWithinCube/Cube.pde similarity index 100% rename from java/examples/3D/Transform/CubesWithinCube/Cube.pde rename to java/examples/Topics/Motion/CubesWithinCube/Cube.pde diff --git a/java/examples/3D/Transform/CubesWithinCube/CubesWithinCube.pde b/java/examples/Topics/Motion/CubesWithinCube/CubesWithinCube.pde similarity index 100% rename from java/examples/3D/Transform/CubesWithinCube/CubesWithinCube.pde rename to java/examples/Topics/Motion/CubesWithinCube/CubesWithinCube.pde