|
![](/i/fill.gif) |
>Ilmari Karonen contributed:
>#declare Eye_D = Eye_Stare_At - Eye_Location; // vector difference
>object { Eye // at origin, looking along +z axis
> rotate <-degrees(atan2(Eye_D.y, vlength(Eye_D*<1,0,1>)), // height >(note
>negation)
> degrees(atan2(Eye_D.x, Eye_D.z))+(Eye_D.z<0 ? 180:0), // >direction
> 0> // no rotation around z-axis anymore
> translate Eye_Location
>}
>
I removed the negative sign from before degrees in the x component,
and got rid of the conditional statement from the y component leaving
just +(180). Because it was turning the Eye 180 degrees in the wrong
direction whenever the eye was looking in the +z direction(at origin
my eye is looking in the -z direction).
>I'm not quite sure about that y-component - it might look in the wrong
>direction
>if Eye_D.z is exactly 0. Anyway, the point is to do the rotation around >the
>y-axis (or whatever is your sky vector) last.
My sky vector is y.
My only problem now is that if my stare_at x and z vectors are both 0.0
POV barks at me about a "domain error in atan2".
Other than that, it works very nicely.
Thank you
--
...coffee?...yes please! extra sugar,extra cream...Thank you.
Post a reply to this message
|
![](/i/fill.gif) |