|
![](/i/fill.gif) |
Slime wrote:
> Oh, wait. I hadn't thought about the case where the up and right
> vectors
> weren't already perpendicular. *Does* it straighten them out in this
> case,
> or does it align the right vector as I described, or does it align the
> up
> vector as I described?
I just did some testing:
* look_at straightens all vectors (even when direction-location = look_at).
* sky alone has no effect.
* I can't figure what really happens when right, sky and look_at are
aligned - but I am under the impression this defines a degenerated
camera that traces only one "point" (not pixel, one ray only). Not very
important.
I tried to match POV behavior in SDL - this is not thoroughly tested but
it seems to work quite nicely.
// --- BEGIN SDL ---
// Trying to reproduce POV original sky/look_at behavior in SDL
camera{
// Declare camera parameters
#local Camera_location = <0,.1,-3> ;
#local Camera_direction = 1*vnormalize(<0,0,1>) ;
#local Camera_up = 1*vnormalize(<0,1,2>) ;
#local Camera_right = 1*vnormalize(<1,0,0>) ;
#local Camera_sky = 1*vnormalize(<0,1,0>) ;
#local Camera_look_at = <-.5,1,.5> ;
#if (0) // choose between POV coded behaviour and SDL behaviour
location Camera_location
direction Camera_direction
up Camera_up
right Camera_right
sky Camera_sky
look_at Camera_look_at
#else
// new look_at to account for location
#declare New_look_at=Camera_look_at-Camera_location ;
// examine handedness
#declare Camera_handedness = vdot( Camera_direction, vcross(
Camera_right, Camera_up ) );
#declare Camera_handedness = Camera_handedness / abs(
Camera_handedness );
// new direction is look_at, conserve length (=zoom) and orientation
#declare New_direction = vnormalize( New_look_at) * vlength(
Camera_direction );
// if look_at and sky are aligned
#if (vlength(vcross(New_look_at, Camera_sky))<1e-6)
// do nothing ;
#declare New_right = Camera_right ;
#else
// else, new right is normal to the look_at-sky plane, conserve
// length and orientation
#declare New_right= vnormalize( vcross ( Camera_sky, New_look_at
) ) * vlength( Camera_right ) * Camera_handedness;
#end
// new up is normal to the look_at-right plane, conserve length
// and orientation
#declare New_up = vnormalize ( vcross ( New_look_at, New_right ) )
* vlength( Camera_up )* Camera_handedness;
// look_at and New_right can't be aligned
location Camera_location
direction New_direction
up New_up
right New_right
#end
}
// --- END SDL ---
Povingly,
Philippe
Post a reply to this message
|
![](/i/fill.gif) |