POV-Ray : Newsgroups : povray.newusers : trace function debug.. : Re: trace function debug.. Server Time
29 Jul 2024 00:37:46 EDT (-0400)
  Re: trace function debug..  
From: albe99
Date: 20 Apr 2007 01:15:02
Message: <web.46284b1435d026cadf6ff5fd0@news.povray.org>
...finally I wrote this:

//-------- Placing the trees -------------

#fopen FileHandle "tree_test.inc" write

#declare Seed=seed(2);
#declare Spacing=0.24;
#declare Cnt=0;

#declare PosX=-3;

#while (PosX < 3)

  #declare PosY=-3;

  #while (PosY < 3)

    // trace function
    #declare Norm = <0, 0, 0>;
    #declare Start = <PosX+(rand(Seed)-0.5)*Spacing,
PosY+(rand(Seed)-0.5)*Spacing, 1.0>;
    #declare Pos = trace (
                  Terrain_Obj,     // object to test
                  Start,           // starting point
                  -z,              // direction
                  Norm );          // normal


    #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0)   // if intersection is
found, normal differs from 0
      #if ((vdot(Norm, z)>0.85) & (Pos.z < 0.25))
      // criteria for placing trees: not too steep and not too high
        object {
          TreeA (0.05+rand(Seed)*0.02)
          translate Pos
        }

#write (FileHandle, concat("translate <",vstr(3, Pos,", ", 0,1),">n"))

        #declare Cnt=Cnt+1;
      #end
    #end

    #declare PosY=PosY+Spacing;

  #end

  #declare PosX=PosX+Spacing;
#end

#fclose FileHandle


Post a reply to this message

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