import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import netscape.javascript.*; import javax.comm.*; import javax.sound.midi.*; import javax.sound.midi.spi.*; import javax.sound.sampled.*; import javax.sound.sampled.spi.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.sax.*; import javax.xml.transform.stream.*; import org.xml.sax.*; import org.xml.sax.ext.*; import org.xml.sax.helpers.*; public class relations_enviroment extends BApplet {// //*****************************************************************************************// // RELATIONS_ENVIRONMENT // // by Alessandro Capozzo March-May 2004, www.ghostagency.net - alessandro@ghostagency.net // // inspired by Reynolds' boids algorithm // // and all the similar beautyful works by proce55ing people. // // built with proce55ing alpha .68 // // ****************************************************************************************// // // A flock of worm-like shapes moves in a 3D space, each shapes position is orthogonally projected // on the enviroment walls, each creature could be connected with the others by an ephemeral net of relations. // Are realtions cause or effect? // //SETTING //var countList sets the number of 'worms', var num sets the number of nodes for each worm. Structure [] list; int num=3; int countList=65; float rotateView=PI*.3f; void setup() { size(400,400); framerate(30); list=new Structure[countList]; for(int index=0;index> http://www.red3d.com/cwr/steer/gdc99/ float ax=0; float ay=0; float az=0; int atrac=0; float ndelay=.13f; // cohesion: define new flock center for (int r1=0;r1limitV){ velocityX=limitV; } if(velocityY>limitV){ velocityY=limitV; } if(velocityX<-limitV){ velocityX=-limitV; } if(velocityY<-limitV){ velocityY=-limitV; } if(velocityZ<-limitV){ velocityZ=-limitV; } if(velocityZ<-limitV){ velocityZ=-limitV; } //new position bx=bx+(int)(velocityX); by=by+(int)(velocityY); bz=bz+(int)(velocityZ); // enviroment limits if(bx<30){ if(velocityX<0){ velocityX+=1; } if(bx<0){ bx+=30; } } if(by<30){ if(velocityY<0){ velocityY+=1; } if(by<0){ by+=30; } } if(bz<30){ if(velocityZ<0){ velocityZ+=1; } if(bz<0){ bz+=30; } } if (bx>(width-30)){ if(velocityX>0){ velocityX-=1; } if(bx>width){ bx-=30; } } if (bz>(width-30)){ if(velocityZ>0){ velocityZ-=1; } if(bz>width){ bz-=30; } } if (by>(height-30)){ if(velocityY>0){ velocityY-=1; } if(by>height){ by-=30; } } //draw projections stroke(200*(bx*.1f),200*(by*.1f),200*(bz*.1f),20); line(cont[0].bx,400,cont[me].bz,cont[0].bx,cont[0].by,cont[me].bz); line(400,cont[0].by,cont[0].bz,cont[0].bx,cont[0].by,cont[0].bz); line(cont[0].bx,cont[0].by,0,cont[0].bx,cont[0].by,cont[0].bz); stroke(200*(bx*.1f),10*(by*.08f),3*(bz*.01f),60); line(cont[0].bx,400,cont[me].bz,cont[0].bx,400,400); line(400,cont[0].by,cont[0].bz,400,0,cont[0].bz); line(cont[0].bx,cont[0].by,0,0,cont[0].by,0); // } } // determinig new node position, for not 'head' nodes void distance(){ objX=cont[me-1].bx-bx; objY=cont[me-1].by-by; objZ=cont[me-1].bz-bz; dista=sqrt(sq(objX)+sq(objY)+sq(objZ)); //__________________________ if(abs(dista)!=15){ // new angles and radius beta=(float)(Math.atan(objY/objX)); beta2=(float)(Math.atan(objZ/objY)); radius2=Math.abs((float)(15 * Math.sin(beta2))); radius=Math.abs((float)(15 * Math.cos(beta2))); //_________________________ if(objY>=0){ radius*=1; } else { radius*=-1; } if(objZ>=0){ radius2*=1; } else { radius2*=-1; } // **********this the 'core'**************** if(beta>0){ bx=cont[me-1].bx-(int)((radius)*cos(beta)); by=cont[me-1].by-(int)((radius)*sin(beta)); }else { bx=cont[me-1].bx+(int)((radius)*cos(beta)); by=cont[me-1].by+(int)((radius)*sin(beta)); } if(beta2>0){ bz=cont[me-1].bz-(int)((radius2)*sin(beta2)); } else { bz=cont[me-1].bz+(int)((radius2)*sin(beta2)); } //******************************************* // draw 'bodies segments' line(cont[me-1].bx,cont[me-1].by,cont[me-1].bz,bx,by,bz); stroke(st); } } } } }