POV-Ray : Newsgroups : povray.programming : spherical camera revisited : spherical camera revisited Server Time
28 Jul 2024 20:30:47 EDT (-0400)
  spherical camera revisited  
From: Mike
Date: 29 Jun 1999 19:55:46
Message: <37795B4D.D3EA5559@aol.com>
I posted an image binaries.images that was rendered with a new camera I
wrote.  While I'm here I'll let everyone in on how it works.

Basically you add the keyword spherical_camera and you can set the
vertical and horizontal field of view using v_angle and h_angle
repectively.  The camera renders as if the whole scene were projected on
a sphere in a reverse manner to how spherical_mapping works.  It can
also be thought of like the lattitude and longitude on a globe.

I used some of the matrix operations in matrices.c, so matrices.h needs
to be included in render.c.  Other than the camera, the rest is just
adding the new keywords and setting defaults for h_angle and v_angle
which are:

h_angle = 360, since this is longitude
v_angle = 180, since this is latitude

I was on-track for another way to do this, but I abandoned it for this
method because it's simple using the already present matrix functions
and it's also more decriptive this way.  Here's the new camera in
render.c:

/* MH 6/99
  * spherical camera: x is horizontal, y vertical
  * V_Angle - vertical FOV
     * H_Angle - horizontal FOV
  */

 case SPHERICAL_CAMERA:

      /* Convert the x coordinate to be a DBL from -0.5 to 0.5. */

      x0 = x / (DBL)Frame.Screen_Width - 0.5;

      /* Convert the y coordinate to be a DBL from -0.5 to 0.5. */

      y0 = ((DBL)(Frame.Screen_Height - 1) - y) /
(DBL)Frame.Screen_Height - 0.5;

      /* convert angle to radians */

      y0 *= (Frame.Camera->V_Angle / 360) * TWO_M_PI;

      x0 *= (Frame.Camera->H_Angle / 360) * TWO_M_PI;

       /* find direction of y on the virtual sphere */

   Compute_Axis_Rotation_Transform (&Trans, FCR, -y0);

   MTransPoint (V1, FCD, &Trans);

      /* Now take V1 and find direction of x at y */

   Compute_Axis_Rotation_Transform (&Trans, FCU, x0);

   /* Create primary ray. */

   MTransPoint (Ray->Direction, V1, &Trans);

   initialize_ray_container_state(Ray, Precompute_Camera_Constants);

      Precompute_Camera_Constants = FALSE;

      break;


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.