// by Greg M. Johnson http://members.xoom.com/gregjohn/animation.html. #declare num=100 ; // number of actors #declare framenum=375; // number of frames+1 (put number of frames +0 in povray.ini and read file) #declare RRR=seed(2022) ; // We'll be using random numbers! #declare UMAX=40 ; // maximum initial postion #declare VMAX=7 ; // maximum initial velocity #declare actorp= array[num+1] // position of each actor #declare actorv= array[num+1] // instantaneous velocity of each actor #declare actoravoid= array[num+1] // vector for best path to avoid collision with peers // WARNING! // This line declares the name of the file which contains the positions and velocities // of all your particles. MAKE SURE to correct the format of the // file name to include a proper drive and subdirectory for your computer! // When working with multiple tweaks, it is often helpful to change this filename frequently. #fopen MyFile2 "c:\pov31g\include\boid17awrite04.inc" write #write(MyFile2,"#declare Position=array[", framenum-1, "][", num, "][6] {\n") //initialize the three vectors for each actor. #declare n=0 ; #while (n; #declare actorv[n]=<0,0.001,0>; // this is the vector which tells each actor how to avoid collisions with nearest neighbor; set to 0 for now. #declare actoravoid[n]=<0,0,0>; #declare n=n+1 ; #end #declare tt=1; // tt is the "time" element. #while(tt; #declare n=n+1 ; #end // here we compute the actoravoid. Basically, it is a vector pointing away from every other actor, divided by distance squared. #declare i=0 ; #while (i; //you could also try: //#declare actave=<0,0,0>; //#declare actave=30*; //#declare actave=<0,30*cos(tt/framenum*8*pi),0>; //#declare actave=20*; //#declare actave=actorp[mod(n+1,num)]; // chase one friend... // Since actorv[n] is instantaneous velocity, particle only moves a fraction of actorv per time frame. #declare actorp[n]=actorp[n]+.125*actorv[n]; // a1 is the acceleration. // to play around with distance between actors, change the constant *(-actoravoid[n]) . // to play around with responsiveness to actave, change the constant *(-actorp[n]+actave) . #declare a1=10.*(-actoravoid[n])+0.1*(-actorp[n]+actave); // For a smoother, less responsive group, increase the constant * actorv[n] to a1. // For a jerkier, more responsive group, decrease the constant * actorv[n] to a1. #declare actorv[n]=.4*actorv[n]+a1; #declare n=n+1 ; #end // IN THIS FILE, THERE IS NO NEED TO TOUCH ANYTHING BELOW THIS LINE! #declare n=0 ; #while (n look_at <0, 0, 0> angle 30 } light_source{<10,200,-50>rgb 1.2} light_source{<10,-200,50>rgb .2} fog { fog_type 1 distance 2000 rgb <.2,.3,.7>}