//Written by: Stephen Lavedas //Creates a sphere (roughly) of connected points //Center is the center point of the sphere //MRadius is the radius of the sphere //mRadius is the radius of the cylinders and spherical points //Levels determines the sophistication of the Major sphere //(how many points used to define it) #macro CBall(Center, MRadius, mRadius, Levels, Tex) #declare Points = array[1024] #declare BPoint = <1,0,0>; #declare AxisX = <1,0,0>; #declare AxisY = <0,1,0>; #declare AxisZ = <0,0,1>; //This is what determines the number of points in the sphere, if you divide a //triangle into smaller triangles, the number of triangles going down the side //is determined by 2^Level #declare Theta = 90/(pow(2,Levels)); #declare Angle = 90; #declare Num = 0; #declare Length = 0; #while (Angle >= 0) #declare Points[Length] = vaxis_rotate(BPoint, AxisY, Angle); #declare I = 0; #if (Num > 0) #declare Phi = 90/Num; #declare TempPoint = Points[Length]; #declare Length = Length + 1; //Now create the rest of the points around the hemisphere #while (I < Num * 4 - 1) #declare Points[Length] = vaxis_rotate(TempPoint, AxisZ, Phi * (I + 1)); #declare Length = Length + 1; #declare I = I + 1; #end #end #declare Angle = Angle - Theta; #declare Num = Num + 1; #end //copy the points except for the shared ones around to the other side //of the sphere to complete it. #declare TLength = Length; #declare I = 0; #while (I < TLength) #declare Num = 0; #if (vaxis_rotate(Points[I], AxisZ, 180).z != 0) #declare Points[Length] = ; #declare Length = Length + 1; #end #declare I = I + 1; #end #declare I = 0; #while (I < Length) #declare Points[I] = Points[I] * MRadius + Center; #declare I = I + 1; #end //now that we have all the points, let's draw and connect them all union { #declare i = 0; #while (i < Length) sphere{ Points[i],mRadius texture {Tex} } #declare j = i + 1; #while (j < Length) cylinder{ Points[i], Points[j],mRadius texture {Tex} } #declare j = j + 1; #end #declare i = i + 1; #end } #end