|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |