Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

toxic::Camera Class Reference

The camera is located at the origin and looks toward Z-. More...

#include <camera.h>

Inheritance diagram for toxic::Camera:

toxic::Basis List of all members.

Public Member Functions

 Camera (const sheep::Matrix4 &m, sheep::Real hfov=DEFAULT_CAMERA_HFOV, sheep::Real aspect_ratio=DEFAULT_CAMERA_ASPECT_RATIO)
 m is the object space to world space transformation matrix.

void Finalize (const Context &context, const Scene *scene)
void EnableDepthOfField (sheep::Real fstop, sheep::Real focal_length, sheep::Real focal_distance)
void EnableAutoFocus (const sheep::Point2 &p)
Ray ComputeRay (const Context &context, const sheep::Point2 &p) const
sheep::Point2 Project (const sheep::Point3 &p) const

Private Attributes

sheep::Point3 m_location
 Location of the camera, expressed in world space.

sheep::Vector3 m_ex
sheep::Vector3 m_ey
sheep::Vector3 m_ez
 Basis vectors, expressed in world space. m_ex is scaled by the aspect ratio.

sheep::Vector3 m_u
sheep::Vector3 m_w
 m_u = m_ex * m_aspect_ratio, m_w = m_ez * (-m_focal_length).

sheep::Real m_hfov
 User defined horizontal field of view, expressed in radians.

sheep::Real m_aspect_ratio
 User defined aspect ratio.

sheep::Real m_focal_length
 Lens focal length (computed from horizontal field of view and aspect ratio values).

bool m_is_dof_enabled
 True if depth of field is enabled, false otherwise.

sheep::Real m_dof_fstop
 User defined f-stop number.

sheep::Real m_dof_focal_length
 User defined focal length (distinct from m_focal_length).

sheep::Real m_dof_focal_distance
 User defined distance of the focus plane from the lens center.

sheep::Real m_dof_lens_radius
 Lens radius (computed from DOF focal length value and f-stop number).

bool m_is_autofocus_enabled
 True if autofocus is enabled, false otherwise.

sheep::Point2 m_autofocus_target
 Focus point, expressed in NDC. Used only by the autofocus mechanism.


Detailed Description

The camera is located at the origin and looks toward Z-.

Normalized Device Coordinates (NDC) are normalized pixel coordinates so that x and y both run from -0.5 to +0.5 across the entire (uncropped) image, with (-0.5, -0.5) being at the lower left of the image, and (0.5, 0.5) being at the upper right of the image (regardless of the aspect ratio).

Definition at line 50 of file camera.h.


Constructor & Destructor Documentation

Camera::Camera const sheep::Matrix4 m,
sheep::Real  hfov = DEFAULT_CAMERA_HFOV,
sheep::Real  aspect_ratio = DEFAULT_CAMERA_ASPECT_RATIO
 

m is the object space to world space transformation matrix.

Definition at line 35 of file camera.cpp.

References m_aspect_ratio, m_ex, m_ez, m_focal_length, m_hfov, m_u, m_w, and sheep::PI.


Member Function Documentation

Ray Camera::ComputeRay const Context context,
const sheep::Point2 p
const
 

Returns a ray whose origin is at camera location, and which is directed toward the point 'p'. 'p' is a point on the film plane. It is expressed in NDC. The returned ray is expressed in world space. The direction of the returned ray IS unit-length.

Definition at line 103 of file camera.cpp.

References m_dof_focal_distance, m_dof_lens_radius, m_ex, m_ey, m_ez, m_is_dof_enabled, m_location, m_u, m_w, sheep::Point2::m_x, sheep::Vector3::m_y, sheep::Point2::m_y, sheep::Vector3::Normalize(), sheep::Vector3::Normalized(), and UniformDiskSampling().

void Camera::EnableAutoFocus const sheep::Point2 p  ) 
 

Enables autofocus. Autofocus computes the right focal distance so that point of the scene visible through point 'p' is in focus plane. 'p' is a point on the film plane, expressed in NDC.

Todo:
Create a new camera class for thin lens camera.

Definition at line 95 of file camera.cpp.

References m_autofocus_target, m_is_autofocus_enabled, sheep::Point2::m_x, and sheep::Point2::m_y.

void Camera::EnableDepthOfField sheep::Real  fstop,
sheep::Real  focal_length,
sheep::Real  focal_distance
 

Enables depth of field. From "The RenderMan Interface Version 3.2": 'focal_distance' sets the distance along the direction of view at which objects will be in focus. 'focal_length' sets the focal length of the camera. These two parameters should have the units of distance along the view direction in camera coordinates. 'fstop', or aperture number, determines the lens diameter: lens_diameter = focal_length / fstop.

Todo:
Create a new camera class for thin lens camera.

Definition at line 81 of file camera.cpp.

References m_dof_focal_distance, m_dof_focal_length, m_dof_fstop, m_dof_lens_radius, and m_is_dof_enabled.

void Camera::Finalize const Context context,
const Scene scene
 

This method must be called only once, after the camera is completely configured, and before it is used for the first time.

Definition at line 61 of file camera.cpp.

References toxic::Hit::m_abscissa, m_autofocus_target, toxic::Ray::m_direction, m_dof_focal_distance, m_ey, m_is_autofocus_enabled, m_location, toxic::Ray::m_origin, m_u, m_w, sheep::Point2::m_x, sheep::Point2::m_y, sheep::Vector3::Normalize(), and toxic::Scene::Trace().

Point2 Camera::Project const sheep::Point3 p  )  const
 

Definition at line 142 of file camera.cpp.

References m_aspect_ratio, m_ex, m_ey, m_ez, m_focal_length, and m_location.


Member Data Documentation

sheep::Real toxic::Camera::m_aspect_ratio [private]
 

User defined aspect ratio.

Definition at line 97 of file camera.h.

Referenced by Camera(), and Project().

sheep::Point2 toxic::Camera::m_autofocus_target [private]
 

Focus point, expressed in NDC. Used only by the autofocus mechanism.

Definition at line 107 of file camera.h.

Referenced by EnableAutoFocus(), and Finalize().

sheep::Real toxic::Camera::m_dof_focal_distance [private]
 

User defined distance of the focus plane from the lens center.

Definition at line 104 of file camera.h.

Referenced by ComputeRay(), EnableDepthOfField(), and Finalize().

sheep::Real toxic::Camera::m_dof_focal_length [private]
 

User defined focal length (distinct from m_focal_length).

Definition at line 103 of file camera.h.

Referenced by EnableDepthOfField().

sheep::Real toxic::Camera::m_dof_fstop [private]
 

User defined f-stop number.

Definition at line 102 of file camera.h.

Referenced by EnableDepthOfField().

sheep::Real toxic::Camera::m_dof_lens_radius [private]
 

Lens radius (computed from DOF focal length value and f-stop number).

Definition at line 105 of file camera.h.

Referenced by ComputeRay(), and EnableDepthOfField().

sheep::Vector3 toxic::Camera::m_ex [private]
 

Definition at line 92 of file camera.h.

Referenced by Camera(), ComputeRay(), and Project().

sheep::Vector3 toxic::Camera::m_ey [private]
 

Definition at line 92 of file camera.h.

Referenced by ComputeRay(), Finalize(), and Project().

sheep::Vector3 toxic::Camera::m_ez [private]
 

Basis vectors, expressed in world space. m_ex is scaled by the aspect ratio.

Definition at line 92 of file camera.h.

Referenced by Camera(), ComputeRay(), and Project().

sheep::Real toxic::Camera::m_focal_length [private]
 

Lens focal length (computed from horizontal field of view and aspect ratio values).

Definition at line 98 of file camera.h.

Referenced by Camera(), and Project().

sheep::Real toxic::Camera::m_hfov [private]
 

User defined horizontal field of view, expressed in radians.

Definition at line 96 of file camera.h.

Referenced by Camera().

bool toxic::Camera::m_is_autofocus_enabled [private]
 

True if autofocus is enabled, false otherwise.

Definition at line 106 of file camera.h.

Referenced by EnableAutoFocus(), and Finalize().

bool toxic::Camera::m_is_dof_enabled [private]
 

True if depth of field is enabled, false otherwise.

Definition at line 101 of file camera.h.

Referenced by ComputeRay(), and EnableDepthOfField().

sheep::Point3 toxic::Camera::m_location [private]
 

Location of the camera, expressed in world space.

Definition at line 91 of file camera.h.

Referenced by ComputeRay(), Finalize(), and Project().

sheep::Vector3 toxic::Camera::m_u [private]
 

Definition at line 93 of file camera.h.

Referenced by Camera(), ComputeRay(), and Finalize().

sheep::Vector3 toxic::Camera::m_w [private]
 

m_u = m_ex * m_aspect_ratio, m_w = m_ez * (-m_focal_length).

Definition at line 93 of file camera.h.

Referenced by Camera(), ComputeRay(), and Finalize().


The documentation for this class was generated from the following files:
Generated on Tue May 11 01:31:57 2004 for toxic by doxygen 1.3.6