// Distributed Objects // Create by Chris Bartlett 20.02.2005 // Permission is granted for all forms of reuse // Usage notes // ----------- // This example illustrates how to keep a list of positions in an array and // check that subsequent positions are not within a given minimum distance of // previously used positions. // Warnings // - The closer you get to the maximum number of objects that can be crammed // into the space the less efficient it gets. // - If you give it a space too small to fit enough objects it'll loop forever. camera {location<-2,1,-25> look_at<0,0,0>} light_source{<30,30,-20> color rgb 2} light_source{<-20,10,-25> color rgb 2} #declare NumberOfObjects = 400; #declare SafetyZone = 1; // Radius of the safety zone around an object #declare Space = <20,10,40>; // The container for the objects #declare SpaceStation = torus {0.4,0.1} #declare Positions = array[NumberOfObjects]; #declare MyRand = seed(42); // Any number will do #local i=0; #while (i-0.5)*Space; // Check the new position against any we've already used #local TooClose = 0; #local j = 0; #while (j*360 translate Positions[i] pigment {color rgb } } #local i=i+1; #end #end