POV-Ray : Newsgroups : povray.advanced-users : Is there a better way to do this? : Re: Is there a better way to do this? Server Time
29 Jul 2024 08:14:20 EDT (-0400)
  Re: Is there a better way to do this?  
From: David Wallace
Date: 19 Aug 2002 12:49:51
Message: <3d6121af@news.povray.org>
Getting a good value from trace is not the easiest thing in the world.  For
my latest IRTC entry I used trace to get locations to place boulders, and
just about everything else, in a landscape.  You have to start with huge y
values ( far above the surface ) and point down:

 #declare Land = height_field {
   png "texland.png"
   smooth
   translate <-.5, 0.25, -.5>
   texture { texLand }
  scale <1e5, 4500, 1e5>
 }
 #declare csBase = <4500, 34000,  6500>;
 #declare csNorm = <0,0,0>;
 #declare cSrc = trace(Land, csBase, -y, csNorm)+y*5;

You have to take care not to miss the HF (vlength(csNorm)=0).  You should
get the altitude of the ground at that point.  Keep in mind that the entire
surface must be defined under one variable, using union and merge where
necessary.  If you define an isosurface using a known y=f(x,z) function and
trace() gives you an answer inconsistent with a verifiable calculation,
that's a bug and needs to be reported to the POV Team.  Use

#debug concat("Intersection found at ",vstr(3,cSrc,",",0,3)," .\n")

to check your work.

"Mike" <mla### [at] yahoocom> wrote in message
news:web.3d59bd05ca87489de9d3dc080@news.povray.org...
> I started by trying to get trace to work, but the values I got back were
> wrong.  If I traced a point to the surface of the ground (with a direction
> vector of <0,-1,0>, I would get very wrong y values if the ground was
> perfectly flat.  The best example I can give is in the code I posted
> earlier (see thread titled "Collision Detection").  In that example, I had
> a ball going over some spheres.  In the case that the ball was directly
> above the ground spheres, I would recieve a y offset that was close to
> double what it should have been.
>
> Maybe I just need a better understanding of how trace works and how to use
> it.  I would love to explore that, but have had trouble locating resources
> or tutorials.
>
> Mike
>
>
> Rune wrote:
> >So you're creating a 3d array of points (with certain x, y, and z
> >spacing), and removing those points above the surface?
> >
> >Why not just create a 2d array (with certain x and z spacing) and use
> >trace() to find the y values of each grid point?
> >
> >But I may have misunderstood you...
> >
> >Rune
> >--
> >3D images and anims, include files, tutorials and more:
> >rune|vision:  http://runevision.com (updated July 12)
> >POV-Ray Ring: http://webring.povray.co.uk
> >
>
>


Post a reply to this message

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