POV-Ray : Newsgroups : povray.advanced-users : Write to file example needed Server Time
2 Nov 2024 11:24:35 EDT (-0400)
  Write to file example needed (Message 1 to 9 of 9)  
From: Ken
Subject: Write to file example needed
Date: 17 Aug 1999 01:00:29
Message: <37B8EC59.9E201405@pacbell.net>
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.

Thank you,


  #version 3.1

  #macro Diamond (NumSides, TopRadius, TopHeight, CentreRadius, BottomDepth)
  mesh{
  #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);

  triangle {       P1,P3, BottomTip}
  triangle {       P1,P3,        P4}
  triangle {       P1,P4,        P2}
  triangle {TopCentre,P4,        P2}

  #local P1 = P3;
  #local P2 = P4;
  #local LongSide = (LongSide = true ? false : true);

  #local C = C + (ARK * 2);
  #end }
  #end

  // --- End File ---------------------------------------



-- 
Ken Tyler

See my 700+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Nieminen Mika
Subject: Re: Write to file example needed
Date: 17 Aug 1999 03:24:02
Message: <37b90e12@news.povray.org>
Ken <tyl### [at] pacbellnet> 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

From: Ken
Subject: Re: Write to file example needed
Date: 17 Aug 1999 03:44:09
Message: <37B912B8.212EA839@pacbell.net>
Nieminen Mika wrote:
> 
> Ken <tyl### [at] pacbellnet> 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)

That looks like it should do it. I'll test it out and if I run into any problems
I let you know. Can I assume that in the file name parameter an extention can
be provided i.e. mesh.inc ?

 Thanks for the example Warp.

-- 
Ken Tyler

See my 700+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Ken
Subject: Re: Write to file example needed
Date: 17 Aug 1999 05:15:20
Message: <37B92819.4CF0181F@pacbell.net>
Nieminen Mika wrote:
> 
> Ken <tyl### [at] pacbellnet> 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.

Is there any way to append to an existing file with the fopen command ?

Just wondering :)

-- 
Ken Tyler

See my 700+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Nieminen Mika
Subject: Re: Write to file example needed
Date: 17 Aug 1999 10:52:07
Message: <37b97717@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: Is there any way to append to an existing file with the fopen command ?

: Just wondering :)

  At last I can tell this to you: Read the manual ;)

  Yes it is possible. If I remember correctly, you can write "append"
instead of "write" in the #fopen command.

-- 
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

From: Nieminen Mika
Subject: Re: Write to file example needed
Date: 17 Aug 1999 10:53:01
Message: <37b9774d@news.povray.org>
Ken <tyl### [at] pacbellnet> wrote:
: Can I assume that in the file name parameter an extention can
: be provided i.e. mesh.inc ?

  Why not? Of course you can.

-- 
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

From: Ken
Subject: Re: Write to file example needed
Date: 17 Aug 1999 10:54:33
Message: <37B9779C.933A51EB@pacbell.net>
Nieminen Mika wrote:
> 
> Ken <tyl### [at] pacbellnet> wrote:
> : Is there any way to append to an existing file with the fopen command ?
> 
> : Just wondering :)
> 
>   At last I can tell this to you: Read the manual ;)

Manual ? Is there a reference to that in the docs ? :)
 
>   Yes it is possible. If I remember correctly, you can write "append"
> instead of "write" in the #fopen command.

thanks,

-- 
Ken Tyler

See my 700+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Alberto
Subject: Re: Write to file example needed
Date: 17 Aug 1999 11:41:10
Message: <37B9830D.7F7532C9@ma.usb.ve>
Take a look under section 4.2.3 in the pov.doc.

Alberto

Ken wrote:

> Nieminen Mika wrote:
> >
> > Ken <tyl### [at] pacbellnet> wrote:
> > : Is there any way to append to an existing file with the fopen command ?
> >
> > : Just wondering :)
> >
> >   At last I can tell this to you: Read the manual ;)
>
> Manual ? Is there a reference to that in the docs ? :)
>
> >   Yes it is possible. If I remember correctly, you can write "append"
> > instead of "write" in the #fopen command.
>
> thanks,
>
> --
> Ken Tyler
>
> See my 700+ Povray and 3D Rendering and Raytracing Links at:
> http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Ken
Subject: Re: Write to file example needed
Date: 18 Aug 1999 00:02:24
Message: <37BA3047.E90D20C1@pacbell.net>
Alberto wrote:
> 
> Take a look under section 4.2.3 in the pov.doc.
> 
> Alberto

I know that :] What I meant is if there is a reference to reading the manual
in the documentation. It was a joke but perhaps poorly worded.

-- 
Ken Tyler

See my 700+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.