#macro rprism(solid_sides,solid_radius,solid_length,rounding_radius,mergeflag) /* Rprism creates a regular N-sides prism. It accepts 5 parameter : Solid_Sides : The nubmer of sides the prism has. Solid_radius : The distance from the center of the prism's cross section to the POINTS of the prism ( NOT the middle of the vertical faces! ). Note that this radius will lie OUtside the prism if rounding is used. This represents the MAXIMUM radius of the prism. Solid_Length : The length of the prism in the Y direction. rounding_radius : The radius of the circle used to 'round off' the sharp corners of the solid. If this value is 0 a simple prism is created. mergeflag : toggles between a union of all the pieces ( less processing time ), or a merge ( needed for transparent textures ). True values result in a merge Note that the resulting shape is centered around the origin point <0,0,0>. */ #if (rounding_radius) #if (mergeflag) merge { #else union { #end // if #end // if prism { linear_sweep linear_spline -(solid_length/2), // height 1 +(solid_length/2), // height 2 (solid_sides+1), // number of points #local counter = 0; #while (counter<(solid_sides+1)) < vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>).x, vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>).z > #declare counter = counter +1; #end // while } #if (rounding_radius) #local counter = 0; #while (counter,<0,counter*360/solid_sides,0>); #local vect2 = vrotate(<(solid_radius-rounding_radius),0,0>,<0,(counter+1)*360/solid_sides,0>); #local vect3 = vrotate(,<0,(counter+0.5)*360/solid_sides,0>); <0,0>, < vect1.x, vect1.z > < (vect1+vect3).x, (vect1+vect3).z >, < (vect2+vect3).x, (vect2+vect3).z >, < vect2.x, vect2.z >, <0,0> } sphere { vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>), rounding_radius translate <0,(solid_length/2)-rounding_radius,0> } cylinder { vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>), vrotate(<(solid_radius-rounding_radius),0,0>,<0,(counter+1)*360/solid_sides,0>), rounding_radius translate <0,(solid_length/2)-rounding_radius,0> } sphere { vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>), rounding_radius translate <0,-(solid_length/2)+rounding_radius,0> } cylinder { vrotate(<(solid_radius-rounding_radius),0,0>,<0,counter*360/solid_sides,0>), vrotate(<(solid_radius-rounding_radius),0,0>,<0,(counter+1)*360/solid_sides,0>), rounding_radius translate <0,-(solid_length/2)+rounding_radius,0> } cylinder { vrotate(<(solid_radius-rounding_radius),-(solid_length/2)+rounding_radius,0>,<0,counter*360/solid_sides,0>), vrotate(<(solid_radius-rounding_radius),+(solid_length/2)-rounding_radius,0>,<0,counter*360/solid_sides,0>), rounding_radius } #local counter = counter + 1; #end // while #end // if #if (rounding_radius) } // end CSG #end #end // macro /* Example ---------- object { rprism(6,0.5,1,0.1,0) translate <0,0.5,0> pigment { red 1.0 } } */