DD::Image::CameraOp Class Reference

Inherits DD::Image::AxisOp.

Inherited by DD::Image::DefaultCamera, and DD::Image::LightOp.

List of all members.

Public Types

enum  {
  LENS_PERSPECTIVE, LENS_ORTHOGRAPHIC, LENS_UV, LENS_SPHERICAL,
  LENS_RENDER_CAMERA, LENS_USER_CAMERA
}
typedef void( LensFunc )(Scene *, CameraOp *, MatrixArray *transforms, const VArray &v, Vector4 &out, void *data)
typedef void( LensNFunc )(Scene *, CameraOp *, MatrixArray *transforms, VArray *vert_array, int n, void *data)

Public Member Functions

 CameraOp (Node *node)
void _validate (bool for_real)
void knobs (Knob_Callback)
virtual void projection_knobs (Knob_Callback)
virtual void lens_knobs (Knob_Callback)
unsigned node_color () const
void draw_handle (ViewerContext *)
void hfov (double v)
double film_width () const
void film_width (double v)
double film_height () const
void film_height (double v)
double focal_length () const
void focal_length (double v)
double Near () const
void Near (double v)
double Far () const
void Far (double v)
double focal_point () const
void focal_point (double v)
double fstop () const
void fstop (double v)
int projection_mode () const
void projection_mode (int i)
virtual bool projection_is_linear (int mode) const
virtual LensFunclens_function (int mode) const
virtual LensNFunc * lensNfunction (int mode) const
double lens_distort_a () const
double lens_distort_b () const
double lens_distort_c () const
double lens_distort_D () const
double lens_distortion () const
double lens_power () const
bool lens_distort_enabled () const
const Vector2win_translate () const
const Vector2win_scale () const
double win_roll () const
const Matrix4projection () const
virtual Matrix4 projection (int mode) const
virtual Matrix4 projectionAt (const DD::Image::OutputContext &)
const char * Class () const
const char * node_help () const
HandlesMode doAnyHandles (ViewerContext *ctx)
void build_handles (ViewerContext *)

Static Public Member Functions

static void to_format (Matrix4 &, const Format *)
static void from_format (Matrix4 &, const Format *)
static CameraOpdefault_camera ()

Static Public Attributes

static const char * projection_modes []
static const char * projection_modes_renderer []
static const Description description

Protected Attributes

double focal_length_
double haperture_
double vaperture_
double near_
double far_
 Near and far Z clipping planes.
Vector2 win_translate_
 Window coords translate XY.
Vector2 win_scale_
 Window coords scale XY.
double win_roll_
 Window coords rotate Z.
Matrix4 projection_
 Camera's projection matrix.
int projection_mode_
 Camera lens projection mode.
double focal_point_
 Focal point of camera.
double fstop_
 camera fstop
bool use_vertical_lock_
double lens_distort_a_
double lens_distort_b_
double lens_distort_c_
double lens_distort_D_
double lens_distortion_
double lens_power_
bool lens_distort_enabled_

Detailed Description

Op that defines a 3D camera.


Member Typedef Documentation

typedef void( DD::Image::CameraOp::LensFunc)(Scene *, CameraOp *, MatrixArray *transforms, const VArray &v, Vector4 &out, void *data)

Lens Projection/Distortion Function Type


Member Enumeration Documentation

anonymous enum
Enumerator:
LENS_PERSPECTIVE 

Standard perspective projection.

LENS_ORTHOGRAPHIC 

Standard orthographic projection.

LENS_UV 

Replace screen XY with UV coordinate.

LENS_SPHERICAL 

360x180 world spherically projected around camera

LENS_RENDER_CAMERA 

Renderer uses this option.

LENS_USER_CAMERA 

Camera user projection.


Member Function Documentation

bool CameraOp::projection_is_linear ( int  mode) const [virtual]

Returns true if current projection mode can be described linearly. This only true for perspective and orthographic modes if no lens distortion in being done.

References LENS_ORTHOGRAPHIC, LENS_PERSPECTIVE, LENS_SPHERICAL, and LENS_UV.

Referenced by DD::Image::rTriangle::add_to_render().

CameraOp::LensFunc * CameraOp::lens_function ( int  mode) const [virtual]

Returns the current lens function used to distort vertices during software rendering. Single VArray version returns a Vector4.

References LENS_ORTHOGRAPHIC, LENS_PERSPECTIVE, LENS_SPHERICAL, and LENS_UV.

CameraOp::LensNFunc * CameraOp::lensNfunction ( int  mode) const [virtual]

Returns the current lens function used to distort vertices during software rendering. Array function version that accepts a pointer to an array of VArray structures and thier number.

References LENS_ORTHOGRAPHIC, LENS_PERSPECTIVE, LENS_SPHERICAL, and LENS_UV.

Referenced by DD::Image::Render::_validate().

void CameraOp::to_format ( Matrix4 matrix,
const Format format 
) [static]

Multiply the passed matrix by the necessary transformation to put x=-1 at the left edge of the format, +1 at the right, and to center it vertically, and compensate for any pixel aspect. The output z and w are left unchanged.

Most Iops will need to do this using their output format to get the actual transformation from input space to output space. You would do this first, then multiply by the projection*local*parent.

References DD::Image::Format::pixel_aspect(), DD::Image::Box::r(), DD::Image::Matrix4::scale(), DD::Image::Box::t(), DD::Image::Matrix4::translate(), DD::Image::Box::w(), DD::Image::Box::x(), and DD::Image::Box::y().

void CameraOp::from_format ( Matrix4 matrix,
const Format format 
) [static]

Opposite transformation of to_format(). Multiplies the passed matrix by a transformation that scales the input format to go from x = -1 to x = 1 and to center it vertically around y = 0, and to remove any pixel aspect ratio. You multiply by this matrix last.

The 3DCard iop scales further so the image covers a range so that if the camera lens and "taking lens" are equal the image fills the field of view.

References DD::Image::Format::pixel_aspect(), DD::Image::Box::r(), DD::Image::Matrix4::scale(), DD::Image::Box::t(), DD::Image::Matrix4::translate(), DD::Image::Box::w(), DD::Image::Box::x(), and DD::Image::Box::y().

Referenced by DD::Image::GeoOp::build_matrix_handles().

const Matrix4 & DD::Image::CameraOp::projection ( ) const [inline]

Returns a transformation to an output image due to the camera lens. This will transform points at the left edge of the film to an x value of -1, and points at the right to an x value of +1. Vertically it will produce a square transform, ie for most film shapes the +/-1 value for y is outside the top or bottom of the rectangular frame.

The z output of this transformation is set to match the OpenGL near/far clipping planes at -1 and +1. These planes may be chosen by Nuke to make a nice display with OpenGL, and you should avoid having them have any effect on the output image. If you want the actual distance to an object from the camera, the w output of this transformation will give you that.

For most uses you want to multiply projection()*xform() and pass the result through to_format() to get the transformation from world space to output pixels.

Referenced by draw_handle(), and projection().

Matrix4 CameraOp::projection ( int  mode) const [virtual]

Return camera projection matrix for a particular projection mode. It needs to be overridden if subclasses implement a different logic to calculate the projection matrix.

References far_, LENS_PERSPECTIVE, DD::Image::Matrix4::projection(), projection(), radians(), DD::Image::Matrix4::rotateZ(), DD::Image::Matrix4::scale(), DD::Image::Matrix4::translate(), win_roll_, win_scale_, and win_translate_.

CameraOp * CameraOp::default_camera ( ) [static]

Return a default camera that can be used when the there is no camera attached to your renderer. This camera is at the origin, looking along -z, and has a lens ratio focal_length/film_width of 1.

Referenced by DD::Image::Render::_validate(), DD::Image::RenderScene::build_handles(), and DD::Image::RenderScene::render_camera().