#declare RR = 5; // camera range /* Render different views */ #switch (clock) #case (0) #declare VP = <-RR,0,0>; #break #case (1) #declare VP = <0,-RR,0>; #break #case (2) #declare VP = <0,0,-RR>; #break #case (3) #declare VP = <-0.7*RR,-0.7*RR,0>; #break #case (4) #declare VP = <0,-0.7*RR,-0.7*RR>; #break #case (5) #declare VP = <-0.7*RR,0,-0.7*RR>; #break #case (6) #declare VP = <-0.7*RR,-0.7*RR,-0.7*RR>; #break #end /* Perspective camera */ camera { location VP up y right x // square image angle 60 sky <0,0,1> look_at <0,0,0> } /* Coloured lights o each axis */ light_source { <-2*RR,0,0> color rgb <1,0.5,0.5> } light_source { <0,-2*RR,0> color rgb <0.5,1.0,0.5> } light_source { <0,0,-2*RR> color rgb <0.5,0.5,1.0> } /* The following is a "simple" implementation of a supershape. The parameters for the two shapes are given by SS1 and SS2 variables below, namely m,a,b,n1,n2,n3 as per the formulation given here http://astronomy.swin.edu.au/~pbourke/surfaces/supershape3d/ It will left up the reader to improve this, for example, it is useful to be able to vary the range of the longitude and latitude, namely the range over which variables t1,t2,p1, and p2 vary. This formulation doesn't create normals, sorry, you'll need to use high resolutions for smooth surfaces. */ #macro SuperShape(SS1m,SS1a,SS1b,SS1n1,SS1n2,SS1n3,SS2m,SS2a,SS2b,SS2n1,SS2n2,SS2n3,resol) #declare SS1 = function(T) { pow( pow(abs(cos(SS1m*T/4))/SS1a,SS1n2) + pow(abs(sin(SS1m*T/4))/SS1b,SS1n3), 1/SS1n1) } #declare SS2 = function(T) { pow( pow(abs(cos(SS2m*T/4))/SS2a,SS2n2) + pow(abs(sin(SS2m*T/4))/SS2b,SS2n3), 1/SS2n1) } #declare i = 0; #while (i < resol) // longitude -pi to pi #declare j = 0; #while (j < resol/2) // latitude -pi/2 to pi/2 #declare t1 = -pi + i*2*pi/resol; #declare t2 = -pi + (i+1)*2*pi/resol; #declare p1 = -pi/2 + j*2*pi/resol; #declare p2 = -pi/2 + (j+1)*2*pi/resol; #declare zeros = 0; #declare r0 = SS1(t1); #if (r0 = 0) #declare zeros = zeros+1; #end #declare r1 = SS2(p1); #if (r1 = 0) #declare zeros = zeros+1; #end #declare r2 = SS1(t2); #if (r2 = 0) #declare zeros = zeros+1; #end #declare r3 = SS2(p2); #if (r3 = 0) #declare zeros = zeros+1; #end #if (zeros = 0) #declare r0 = 1 / r0; #declare r1 = 1 / r1; #declare r2 = 1 / r2; #declare r3 = 1 / r3; #declare pa = ; #declare pb = ; #declare pc = ; #declare pd = ; #if (vlength(pa - pb) > 0) #if (vlength(pa - pc) > 0) triangle { pa, pb, pc } #end #end #if (vlength(pc - pd) > 0) #if (vlength(pc - pa) > 0) triangle { pc, pd, pa } #end #end #end // if #declare j = j + 1; #end // j #declare i = i + 1; #end // i #end // macro /* Lets use it */ mesh { SuperShape(1,1,1 77,0.81,71.7, 8,1,1,0.63,2.92,0.24, 200) //SuperShape(9,1,1,92,0.3,-45, 4,1,1,-0.8,88,-0.35, 202) //SuperShape(4,1,1,1,1,1, 0,1,1,1,1,1, 100) scale <1,1,1> // Change this for scaling translate <0,0,0> // Change this to move the shape from the origin texture { pigment { color rgb <0.5,0.5,0.5> } } }