POV-Ray : Newsgroups : povray.general : how to save looped positions to file? Server Time
26 Nov 2024 01:29:55 EST (-0500)
  how to save looped positions to file? (Message 1 to 2 of 2)  
From: ricky312
Subject: how to save looped positions to file?
Date: 31 May 2012 20:00:00
Message: <web.4fc805a652eb29129fa53fe60@news.povray.org>
for the next version of randscape i wanted to be able to save the positions of a
forest of trees created from a loop macro. I think i know how to open save etc.,
but i don't know the details i know this is a vector data but do i have to list
every vector? can someone help me with this.


Post a reply to this message

From: Thomas de Groot
Subject: Re: how to save looped positions to file?
Date: 1 Jun 2012 04:03:51
Message: <4fc87767$1@news.povray.org>
On 1-6-2012 1:58, ricky312 wrote:
> for the next version of randscape i wanted to be able to save the positions of a
> forest of trees created from a loop macro. I think i know how to open save etc.,
> but i don't know the details i know this is a vector data but do i have to list
> every vector? can someone help me with this.
>
>
I think this can help you:

Below is a macro writing vectors to a file. You can derive your own code 
from this I think:

//start code
// Designs a flat mesh conforming to the topography of surf
#macro MeshGen(Surf,MinX,MinZ,MaxX,MaxZ,Incr)

   #debug "   writing grid mesh...\n"
   #fopen GridMesh "GridMesh.inc" write
   #write (GridMesh,"mesh {\n")

   #local Z = MinZ;
   #while (Z <= MaxZ)  //start of Z loop

     #local X = MinX;
     #while (X <= MaxX)  //start of X loop
       //triangle A:
       #local Nor = <0, 0, 0>;
       #local Loc = <X, 1000, Z>;
       #local Pos = trace (Surf, Loc, -y, Nor);
       #write (GridMesh,"  triangle {<",vstr(3,Pos,", ",0,6),">, ")
       #local Z = Z + Incr;
       #local Nor = <0, 0, 0>;
       #local Loc = <X, 1000, Z>;
       #local Pos = trace (Surf, Loc, -y, Nor);
       #write (GridMesh,"<",vstr(3,Pos,", ",0,6),">, ")
       #local X = X + Incr;
       #local Nor = <0, 0, 0>;
       #local Loc = <X, 1000, Z>;
       #local Pos = trace (Surf, Loc, -y, Nor);
       #write (GridMesh,"<",vstr(3,Pos,", ",0,6),">}\n")
       //triangle B:
       #write (GridMesh,"  triangle {<",vstr(3,Pos,", ",0,6),">, ")
       #local Z = Z - Incr;
       #local Nor = <0, 0, 0>;
       #local Loc = <X, 1000, Z>;
       #local Pos = trace (Surf, Loc, -y, Nor);
       #write (GridMesh,"<",vstr(3,Pos,", ",0,6),">, ")
       #local X = X - Incr;
       #local Nor = <0, 0, 0>;
       #local Loc = <X, 1000, Z>;
       #local Pos = trace (Surf, Loc, -y, Nor);
       #write (GridMesh,"<",vstr(3,Pos,", ",0,6),">}\n")
       #local X = X + Incr;
     #end  //of X loop

     #local Z = Z + Incr;
   #end  //of Z loop

   #write (GridMesh,"}\n")
   #fclose GridMesh

#end  //of MeshGen
//end code

Thomas


Post a reply to this message

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