Hi,
Having difficulty with this one.
I have 30 ellipses that are moving in Z direction (think the rings in the film, Metropolis). They are intended to be looking like they are travelling towards the ground and just before they hit the ground they spread out (grow in size) and scale out along the ground, as if a shockwave that had been hurtling towards the ground then sends shockwaves out across the ground as it hits it. Though, in this case, it's not a right angle change in direction, it's a soft one just before it hits the ground.
At the moment I've been telling the ellipses that if they're at a certain Z distance, to start scaling in size. This gives the effect of them anticipating hitting the ground but doesn't allow them to then spread out along the ground. Any ideas?
(by the way, the ground is imaginary for now - just imagine it as the furthest Z distance the ellipses currently travel. Just before they reach the limit of Z they'll start to scale their X and Y size and once they reach Z, they'll stay at it but keep scaling X and Y up. Also, this code uses the peasycam library for testing but it can be commented out of needed).
Thanks in advance.
- import peasy.org.apache.commons.math.*;
- import peasy.*;
- import peasy.org.apache.commons.math.geometry.*;
- PeasyCam cam;
- float[] ellipseZ = new float[30];
- float[] xSize = new float[30];
- float[] ySize = new float[30];
- float furthestellipse;
- float squarePosition;
- void setup() {
- size(720,576,P3D);
- frameRate(25);
- //hint(DISABLE_OPENGL_2X_SMOOTH);
- //give each ellipse a Z position
- for (int i=0; i < ellipseZ.length; i++) {
- ellipseZ[i] = i * -20;
- xSize[i] = 30;
- ySize[i] = 30;
- }
- furthestellipse = ellipseZ[ellipseZ.length - 1];
- cam = new PeasyCam(this, 100);
- cam.setMinimumDistance(50);
- cam.setMaximumDistance(500);
- }
- void draw() {
- background(40);
- stroke(215);
- strokeWeight(2);
- for (int i = 0; i < 30; i++) {
- if (ellipseZ[i] > 20) {
- xSize[i] = xSize[i] + 2;
- ySize[i] = ySize[i] + 2;
- }
- pushMatrix();
- noFill();
- translate(0,0,ellipseZ[i]);
- //quad(-20,-30,20,-30,20,30,-20,30);
- ellipse(0,0,xSize[i],ySize[i]);
- popMatrix();
- // move ellipse to end if camera past it
- if (ellipseZ[i] > 60) {
- ellipseZ[i] = furthestellipse;
- xSize[i] = 30;
- ySize[i] = 30;
- furthestellipse = ellipseZ[i];
- }
- ellipseZ[i] = ellipseZ[i] + 4;
- };
- }
1