POV-Ray : Newsgroups : povray.general : Objects on a slope : Re: Objects on a slope Server Time
31 Jul 2024 12:24:59 EDT (-0400)
  Re: Objects on a slope  
From: Warp
Date: 13 Mar 2007 11:02:18
Message: <45f6cb0a@news.povray.org>
Jim Holsenback <jho### [at] hotmailcom> wrote:
> object {Object rotate y*(360 * DFactor) scale (0.1 * DFactor) Reorient_Trans 
> (Intercept, SLoc) translate Intercept}

> I'm 99% there and after some emperical testing I'm starting to think the 
> second parameter for the call to Reorient_Trans can't be a fixed point. 
> Here's what I've observed:  SLoc is the location of a small sphere that I'm 
> using to move around the scene and indeed the objects seem to track the 
> sphere. What about the objects that happen to be placed on or near the top 
> of the ridge versus the objects that are placed farther down the slope. 
> Conceptually the second parameter to Reorient_Trans would need to be another 
> call to trace but this time the target would be scaled just slightly larger, 
> but that doesn't sound very elegant. Any ideas?

  I'm not exactly sure what is it that you want to to do exactly.

  I understood that you wanted to reorient the objects so that they are
parallel to the heightfield surface where they are laying on.

  When you used trace() to get the location of that point on the heightfield
where you want to place the object, you can get the normal vector of the
heightfield at that point (using the fourth parameter of trace()).

  Once you have this normal vector, and assuming that your object's "up"
is in the 'y' direction and that it's centered at the origin, you simply
do a ReorientTrans(y, TheNormalVector) before translating the object to
its place.
  The ReorientTrans will rotate the object so that what was previously
pointing towards 'y' will now be pointing in the same direction as the
normal vector.

-- 
                                                          - Warp


Post a reply to this message

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