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