|
![](/i/fill.gif) |
Ken <tyl### [at] pacbell net> wrote:
: As the subject says could someone be so kind as to provide me with an
: example of how to set up the macro below to write the macros output to a
: file. Preferably with an optional switch to either render the file OR
: write the file. Yeah I checked the docs but my attempts have yet so far
: yielded poor results.
Do you mean something like this? If the last parameter is "" then it
just creates the object, else it writes it to the file specified by that
parameter.
#macro Diamond (NumSides, TopRadius, TopHeight, CentreRadius, BottomDepth, Filename)
#if(strcmp(Filename,"")!=0)
#fopen File Filename write
#write(File,"mesh {\n")
#else
mesh {
#end
#local ARK = pi / NumSides;
#declare //#local
BottomTip = <0, -BottomDepth, 0>;
#local TopCentre = <0, TopHeight, 0>;
#local LongSide = true;
#local CurrentPoint = <cos(-2.5*ARK), 0, sin(-2.5 * ARK)>;
#local P1 = CurrentPoint*CentreRadius;
#local P2 = CurrentPoint*TopRadius + (y * TopHeight);
#local C = -1.5*ARK;
#while (C < ((2*pi)+(-2.5*ARK)))
#if (LongSide = true )
#local CurrentPoint = <cos(C), 0, sin(C)>;
#else
#local CurrentPoint = <cos(C + ARK), 0, sin(C + ARK)>;
#end
#local P3 = CurrentPoint*CentreRadius;
#local P4 = CurrentPoint*TopRadius+(y*TopHeight);
#if(strcmp(Filename,"")=0)
triangle { P1, P3, BottomTip }
triangle { P1, P3, P4 }
triangle { P1, P4, P2 }
triangle { TopCentre, P4, P2 }
#else
#write(File," triangle { ",P1,", ",P3,", ",BottomTip," }\n")
#write(File," triangle { ",P1,", ",P3,", ",P4," }\n")
#write(File," triangle { ",P1,", ",P4,", ",P2," }\n")
#write(File," triangle { ",TopCentre,", ",P4,", ",P2," }\n")
#end
#local P1 = P3;
#local P2 = P4;
#local LongSide = (LongSide = true ? false : true);
#local C = C + (ARK * 2);
#end
#if(strcmp(Filename,"")=0)
}
#else
#write(File,"}\n")
#fclose File
#end
#end
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
![](/i/fill.gif) |