POV-Ray : Newsgroups : povray.general : Can you use the trace command on a heightfield? : Re: Can you use the trace command on a heightfield? Server Time
30 Jul 2024 06:20:17 EDT (-0400)
  Re: Can you use the trace command on a heightfield?  
From: Thomas de Groot
Date: 10 Apr 2010 03:23:55
Message: <4bc0278b$1@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> schreef in bericht 
news:web.4bbf648570f2d07d65f302820@news.povray.org...
> As has been mentioned:
> * The trace ray 'start' location needs to be somewhere *above* the
> HF...obviously  ;-)  Personally, I would use <xPos,1000,zPos> to be safe.
> * the 'start' vector is an actual location point; the trace ray direction 
> is a
> *directional* vector, NOT the location of a point, and shouldn't normally
> change--at least when tracing a HF.
>

Yes, and when you want to trace, say, a spherical object, like a planet, the 
following macro by Tim Attwood comes in handy:

//start code
//--- Tim Attwood's random distribution macro ---
#macro RandOnSurface(Obj, rsd, thresh)
   #local mn = min_extent(Obj)-thresh;
   #local mx = max_extent(Obj)+thresh;
   #local dist = 1000000;
   #while (dist>thresh)
      #local flag = 0;
      #while (flag = 0)
         #local rfrom = VRand_In_Box(mn, mx, rsd);
         #local rdir = vrotate(<1,1,1>,
            <360*rand(rsd),360*rand(rsd),360*rand(rsd)>);
         #declare Norm = <0, 0, 0>;
         #local hit = trace(Obj, rfrom, rdir, Norm);
         #if (vlength(Norm) != 0)
            #local flag = 1;
         #end
      #end
      #local dist = vlength( hit - rfrom);
   #end
   #local result = hit;
   (result)
#end
//end code

Thomas


Post a reply to this message

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