/* i rendered the code with the following settings: Width=320 Height=240 Antialias=On Antialias_Threshold=0.3 Initial_Frame = 0 Final_Frame = 99 the frame at which the error occurs varies. sometimes it's #7, sometimes something else ;-( thx again */ global_settings { max_trace_level 256 } #include "colors.inc" #macro vstrex(Vektor) concat("<",vstr(3,Vektor,",",0,1),">") #end //=============================================== //=============================================== //=============================================== #declare Max_Particle_Count = 10000; //Gibt an, wieviele Partikel maximal //gleichzeitig "am Leben" sind #declare Particle = sphere { <0,0,0>, 0.1 } //Dieses Objekt repräsentiert einen Partikel. Es //sollte im Ursprung zentriert sein, da es //nachher passend verschoben wird #declare Seconds_Per_Frame = 0.1; //Gibt die Sekunden po Frame an. Sorgt dafür, //dass die Animation nicht zu schnell oder //zu langsam abläuft. #declare Acceleration = <0,-9.81,0>; //Gibt eine Beschleunigung an, die jedes Teilchen //erfährt (z.B. Erdanziehung) #declare Environment = union { plane { y,0 pigment { Yellow } } cylinder { <-2.5,5,-3>,<-2.5,5,3>,0.5 pigment { Red } } } //Gibt die Umgebung an, mit der das System interagieren //soll #declare Particle_Radius = 0.1; //Gibt den Radius eines einzlnen Partikels an #declare Collision_Friction = 0.3; //Gibt die Reibung bei Kollisionen an: //0 - Totale Reibung //1 - Keine Reibung #declare Collision_Elasticity = 0.3; //Gibt die Elastizität der Partikel an: //0 - Total elastisch //1 - Total Hart #declare Data_Mode = 1; //0 - Daten nicht speichern //1 - Daten speichern //2 - Daten laden und speichern #declare Data_File = "temp.dat" //Dateiname für Partikeldaten //=============================================== //=============================================== //=============================================== #if (frame_number = 0) #declare mySeed = seed(0); #else #include "seed.inc" #end #macro Random(Seed,Min,Max) rand(Seed)*(Max-Min)+Min #end #local Particles_Per_Step = 500; #declare pc = 0; //Erzeugt einen Partikel #macro Create_Particle(Nr) #declare pc = pc + 1; #if (pc; #declare Particles[i][1] = <0,-2+rand(mySeed),-2+rand(mySeed)>; #declare Lifetime[i] = 1.5 + rand(mySeed); #end #end //=============================================== //=============================================== //=============================================== #declare Particles = array[Max_Particle_Count][2]; //Das Herzstück des Systems. In diesem //Array werden alle Partikel gespeichert, //jeder mit 2 Informationen: //Particles[n][0] enthält einen Positionsvektor //Particles[n][1] enthält einen Geschwindigkeitsvektor #declare Lifetime = array[Max_Particle_Count]; //Erwartet einen Geschwindigkeitsvektor V //und einen normierten Normalenvektor N #macro Get_Rebounded_Vector(V, N) vdot(V,N)*N*Collision_Elasticity - (V - vdot(V,N)*N)*Collision_Friction #end #macro Move_Particle(Nr) #declare Particles[Nr][0] = Particles[Nr][0] + Particles[Nr][1]*Seconds_Per_Frame; #declare Particles[Nr][1] = Particles[Nr][1] + Acceleration*Seconds_Per_Frame; #end //Führt einen Zeitschritt aus #macro Step(Show_Particles) #local i = 0; #while (i; #local Pos = Particles[i][0]; #local V = Particles[i][1]; #if (vlength(trace(Environment,Pos,V,Normal)-Pos)-vlength(V*Seconds_Per_Frame)0) //Kollision #declare Particles[i][1] = Get_Rebounded_Vector(V,vnormalize(Normal)); #end #end //#debug "4 " //Partikel als Objekt erstellen #if (Show_Particles != 0) object { Particle translate Particles[i][0] } #end //#debug "5 " #end //#debug "\n" #local i = i + 1; #end #end #macro Save_Particles(Filename) #local i = 0; #fopen Data Filename write #while (i look_at <-2.5,5,-1> } light_source { <5,5,-10> White } background { White } object { Environment } #if (frame_number != 0) Load_Particles("Particles.inc"); #end Step(0) blob { #local c = 0; #while (c < Max_Particle_Count) #ifdef (Particles[c][0]) sphere { Particles[c][0],0.2, 1 } #end #local c = c + 1; #end pigment { rgb<0.8,0.8,1> //filter 0.99 } //finish { phong 1 } } Save_Particles("Particles.inc") //Seed speichern #fopen Seed "seed.inc" write #write(Seed,"#declare mySeed = seed(",int(rand(mySeed)*1000),");\n") #fclose Seed plane { z,2 pigment { White } /*pigment { bozo color_map { [ 0.2 color VeryDarkBrown ] [ 0.3 color SemiSweetChoc ] [ 0.4 color BakersChoc ] [ 0.5 color Brown ] [ 0.7 color Sienna ] } scale 0.1 } normal { pigment_pattern { crackle colour_map { [0, rgb 0] [1, rgb 1] } } 2 } */ }