|
![](/i/fill.gif) |
Hi,
I discovered that the panoramic camera of povray 3.1g (Linux) completely
ignores any specified camera `angle'. I'm actually not quite clear on
how this was supposed to work, but I propose the following patch:
---8<---
diff -ur povray31-orig/source/render.c povray31/source/render.c
--- povray31-orig/source/render.c Sat May 1 15:01:28 1999
+++ povray31/source/render.c Thu Mar 15 00:51:22 2001
@@ -2841,19 +2841,33 @@
case PANORAMIC_CAMERA:
- /* Convert the x coordinate to be a DBL from 0.0 to 1.0. */
+ /* Convert the x coordinate to be a DBL from -0.5 to 0.5. */
- x0 = x / (DBL)Frame.Screen_Width;
+ x0 = x / (DBL)(Frame.Screen_Width - 1) - 0.5;
/* Convert the y coordinate to be a DBL from -1.0 to 1.0. */
y0 = 2.0 * ((DBL)(Frame.Screen_Height - 1) - y) /
(DBL)Frame.Screen_Height - 1.0;
+ /* Get aspect ratio (do this only once). */
+
+ if (Precompute_Camera_Constants)
+ {
+ VLength(lx, FCR);
+ VLength(ly, FCU);
+
+ Camera_Aspect_Ratio = lx / ly;
+
+ VNormalize(FCR, FCR);
+ VNormalize(FCU, FCU);
+ VNormalize(FCD, FCD);
+ }
+
/* Get cylindrical coordinates. */
- x0 = (1.0 - x0) * M_PI;
+ x0 = x0 * M_PI_180 * Frame.Camera->Angle;
- y0 = M_PI_2 * y0;
+ y0 = y0 * M_PI_360 * Frame.Camera->Angle / Camera_Aspect_Ratio;
cx = cos(x0);
sx = sin(x0);
@@ -2876,7 +2890,7 @@
/* Create primary ray. */
- VLinComb3(Ray->Direction, cx, FCR, ty, FCU, sx, FCD);
+ VLinComb3(Ray->Direction, sx, FCR, ty, FCU, cx, FCD);
initialize_ray_container_state(Ray, Precompute_Camera_Constants);
--->8---
The behaviour is now as follows: `angle' gives the horizontal viewing
angle, with -angle/2 relative to the look_at direction at the left
border of the image and +angle/2 at the right border. The total
vertical viewing angle is given by angle * the image aspect ratio
length(up)/length(right), again with zero at the image center.
I'm using the thusly patched version to create 360-degree panoramic
views that can be displayed using the freely available PTViewer
application, which allows you to pan around in the image as if you
were turning the camera. Makes a great new toy :-)
Alex
--
Alexander Jolk * Ale### [at] phys uni-karlsruhe de * +49-721-608-3572
Post a reply to this message
|
![](/i/fill.gif) |