frederickk
YaBB Newbies
Offline
Posts: 18
3d jellyfish-esque wave
Jul 13th , 2008, 3:06am
i'm trying to build a wave that moves in and out of itself kinda like this: http://www.thebarricades.de/kenfrederick/transfer/wave.swf but 3d and smoother, i know there has to be a simpler way to do this. below is my clunky code. thanks in advance! Ken ---- import processing.opengl.*; //----------------------------------------------------------------------------- //variables //----------------------------------------------------------------------------- float r,g,b, r_y,r_x,r_z, abstand; int zahl, index; void setup(){ size(600,600,OPENGL); noFill(); zahl = 17; abstand = 5; } void draw(){ background(0); stroke(50); line(width*0.5,0, width*0.5,height); line(0,height*0.5, width,height*0.5); translate(width*0.5,height*0.5); /* camera(0.0, 0.0, mouseX*4, // eyeX, eyeY, eyeZ 0.0, 0.0, 0.0, // centerX, centerY, centerZ 0.0, 1.0, 0.0); // upX, upY, upZ */ rotateY(radians(map(mouseX, 0,width, 0,360))); //----------------------------------------------------------------------------- //part I //first one -> 0.5 (reverse) //----------------------------------------------------------------------------- for(int i=int(zahl*0.5); i>0; i--) { //for(int i=0; i<int(zahl*0.5); i++) { //rotateY(radians(map(mouseX, 0,width, 0,360))); r = map(i, 0,zahl, 0,255); g = map(i, 0,zahl, 255,0); b = 255; stroke(r,g,b); pushMatrix(); translate(0,0,i*sin(r_z)*abstand); ellipse(0,0,10*i,10*i); popMatrix(); } //----------------------------------------------------------------------------- //part II //0.5 -> last one //----------------------------------------------------------------------------- translate(0,0,-zahl*0.5); for(int i=int(zahl*0.5); i<zahl; i++) { //rotateY(radians(map(mouseX, 0,width, 0,360))); r = map(i, 0,zahl, 0,255); g = map(i, 0,zahl, 255,0); b = 255; stroke(r,g,b); pushMatrix(); translate(0,0,i*-sin(r_z)*abstand); ellipse(0,0,10*i,10*i); popMatrix(); } r_z += 0.02; }