|
|
amjad wrote:
...
> In real life camera is a simple panning or tilting can be represented
> using the simple single rotation matrices?
...
The code below will do that for a perspective camera.
Tor Olav
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Panning, Tilting and Rolling a perspective camera
// By Tor Olav Kristensen, 7. September 2004
#version 3.6;
#include "colors.inc"
#include "transforms.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Something to look at
#declare pBoxCornerA = <1, 2, 1>;
#declare pBoxCornerB = <2, 3, 2>;
box {
pBoxCornerA, pBoxCornerB
pigment { color White }
}
#declare pBoxCenter = (pBoxCornerA + pBoxCornerB)/2;
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Default camera parameters
#declare pLocation = 0*y;
#declare vDirection = z;
#declare vRight = 1.33*x;
#declare vUp = y;
#declare vSky = y;
/*
#declare DefaultCamera =
camera {
perspective
location pLocation
direction vDirection
right vRight
up vUp
sky vSky
}
*/
// Where to look from and where to look
#declare pLocation = <1, 2, -3>*2;
#declare pLookAt = pBoxCenter;
/*
// If POV-Ray where to calculate the new camera vectors
#declare LookAtCamera =
camera {
location pLocation
look_at pLookAt
}
*/
// Calculate the new camera vectors "manually"
#declare vLookAt = pLookAt - pLocation;
#declare vDirection = vlength(vDirection)*vnormalize(vLookAt);
#declare vRight = vlength(vRight)*vnormalize(vcross(vSky, vDirection));
#declare vUp = vlength(vUp)*vnormalize(vcross(vDirection, vRight));
#declare LookAtCamera =
camera {
location pLocation
direction vDirection
right vRight
up vUp
}
#declare Angle = 20; // Degrees
#declare PannedCamera =
camera {
LookAtCamera
translate -pLocation
Axis_Rotate_Trans(vUp, Angle)
translate pLocation
}
#declare TiltedCamera =
camera {
LookAtCamera
translate -pLocation
Axis_Rotate_Trans(vRight, Angle)
translate pLocation
}
#declare RolledCamera =
camera {
LookAtCamera
translate -pLocation
Axis_Rotate_Trans(vDirection, Angle)
translate pLocation
}
camera { LookAtCamera }
//camera { TiltedCamera }
//camera { PannedCamera }
//camera { RolledCamera }
light_source { <1, 2, -3>*100 color White }
background { color Blue/2 }
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|