POV-Ray : Newsgroups : povray.advanced-users : Can I apply the camera transform matrix to objects? : Re: Can I apply the camera transform matrix to objects? Server Time
28 Jul 2024 12:33:13 EDT (-0400)
  Re: Can I apply the camera transform matrix to objects?  
From: Rune
Date: 15 Sep 2005 02:30:22
Message: <432914fe$1@news.povray.org>
zachrahan wrote:
> Good point. I've been trying to use these two macros, but they seem a
> bit under-determined for my needs. These only align a single axis of
> an object to point at a certain point, but the object remains free to
> "spin" about that axis. I'm trying to figure out a way to also
> specify an "up" vector for an object such that when the object is
> pointed at a given point, that "up" vector is parallel (in the
> viewing plane) to the Y-axis.
>
> That is, I'm looking for some sort of "look_at" / "up" transform for
> objects that is directly analogous to that available for the camera.
> I tried writing an equivalent of gluLookAt as a SDL macro, but that
> doesn't seem to quite work. Does anyone have any suggestions?

This is untested code, but it should work:

#include "math.inc"
#include "transforms.inc"

#macro SetLocationAndLookAt(Location,LookAt)
   #local Z = vnormalize(Location-LookAt);
   #local Y = VPerp_Adjust(y,Z);
   #local X = vcross(Y,Z);
   Matrix_Trans(X,Y,Z,Location)
#end

Rune
-- 
3D images and anims, include files, tutorials and more:
rune|vision:  http://runevision.com
POV-Ray Ring: http://webring.povray.co.uk


Post a reply to this message

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