DD::Image::Transform Class Reference

Inherits DD::Image::Iop.

List of all members.

Public Member Functions

void _validate (bool)
void setclip (const Box &)
void _request (int x, int y, int r, int t, ChannelMask, int count)
void engine (int y, int x, int r, ChannelMask allchan, Row &row)
 Transform (Node *node=0)
TransformgetTransform ()
virtual void setInputsValid (bool)
virtual HandlesMode doAnyHandles (ViewerContext *ctx)
void build_handles (ViewerContext *ctx)
void draw_handle (ViewerContext *ctx)
Matrix4matrix ()
virtual void matrix (const Matrix4 &m)
bool transform (double x, double y, double &X, double &Y, double &Z)
bool concat_transform (double x, double y, double &X, double &Y, double &Z)
void reset ()
void multiply (const Matrix4 &m)
void multiply (const Transform &t)
void premultiply (const Matrix4 &m)
void premultiply (const Transform &t)
void scale (float s)
void scale (float x, float y, float z=1.0)
void rotateX (float radians)
void rotateY (float radians)
void rotateZ (float radians)
void rotate (float radians)
void rotate (float a, float x, float y, float z)
void skew (float a)
void translate (float x, float y)
void translate (float x, float y, float z)
const Filterfilter () const
int filter_type () const
void filter_type (int t)
bool clamp () const
void clamp (bool v)
bool black_outside () const
void black_outside (bool v)
const char * Class () const
const char * node_help () const
unsigned node_color () const
const Matrix4concat_matrix () const
Iopconcat_input () const
void filter_knobs (Knob_Callback)
void motionblur_knobs (Knob_Callback cb)
void knobs (Knob_Callback)
float getMotionBlur () const
bool isMotionBlurring () const
float motionBlurSample (int x, int y, Interest &i, ChannelMask iChannels, Pixel &out)
 do motion blurring for the pixel, returns the guestimated path length of the sample
void sample (const Vector2 &center, const Vector2 &dU, const Vector2 &dV, Filter *filter, Pixel &out)
void sample (float cx, float cy, float w, float h, Filter *filter, Pixel &out)
bool set_texturemap (ViewerContext *, bool)
OprealParent ()

Static Public Member Functions

static double mitchell (double b, double c, double x)

Protected Member Functions

bool degenerate ()
virtual void matrixAt (const OutputContext &, Matrix4 &dest)
void concatMatrixAt (const OutputContext &, Matrix4 &dest)
void append (Hash &hash)
void updateConcat (bool setInfo)
 update the concat_matrix_ / concat_input_ / concat_clamp_ / concat_black_outside_

Protected Attributes

Matrix4 matrix_
Matrix4 concat_matrix_
Iopconcat_input_
bool clamp_
bool black_outside_
bool concat_clamp_
bool concat_black_outside_
bool can_concat
float _motionblur
 amount of motion blur to do, '1' being heuristically'enough'
ShutterControls _shutter
 shutter controls for motion blurring
Filter filter_

Friends

class TransformI

Detailed Description

Transforms the input image by a 4x4 transformation matrix.


Constructor & Destructor Documentation

Transform::Transform ( Node *  node = 0)

The constructor sets the transformation to the identity matrix.

References _motionblur, and DD::Image::Matrix4::makeIdentity().


Member Function Documentation

bool Transform::degenerate ( ) [protected]

_validate() calls this when the output image is invisible or otherwise cannot be calculated. It deletes the tp object to indicate this.

References DD::Image::IopInfo::black_outside(), DD::Image::IopInfoOwner::info_, DD::Image::Box::set(), and DD::Image::Op::slowness().

Referenced by _validate().

void Transform::matrixAt ( const OutputContext context,
Matrix4 dest 
) [protected, virtual]

For implementing motion blur, return the matrix at various times. Default version changes the knobs and calls validate(), but a subclass can replace this if there is a faster way.

References matrix(), DD::Image::Op::outputContext(), DD::Image::Op::setKnobsToContext(), and DD::Image::Op::validate().

void Transform::append ( Hash hash) [protected, virtual]

Since _validate is fetching out values of knobs at nearby times to do motionblurring, we have to hash those in here, otherwise changing the velocity of the curve without changing its value will not result in the hash changing.

Reimplemented from DD::Image::Op.

References _shutter, DD::Image::Matrix4::append(), DD::Image::ShutterControls::calcOffset(), DD::Image::ShutterControls::getDuration(), matrix(), DD::Image::Op::outputContext(), and DD::Image::Op::validate().

void Transform::setclip ( const Box box)

After _validate() is called a subclass can call this to force the Transform to clip the output to a rectangle and put black outside it. The rectangle is exactly 1 pixel inside the passed Box (ie the box includes the black edge). The info() is set to this box. This is used by Reformat.

References DD::Image::IopInfoOwner::info_, and DD::Image::Box::set().

void Transform::setInputsValid ( bool  nowValid) [virtual]

this needs calling whenever the input pointers change even if they are pointing to equivalent Ops, as the Transform keeps its own pointers to its inputs.

Reimplemented from DD::Image::Op.

References DD::Image::Iop::input(), and updateConcat().

double Transform::mitchell ( double  b,
double  c,
double  x 
) [static]

Evaluate a Mitchell filter at position x. This can be used by Nuke to view the filter shapes.

Matrix4 * Transform::matrix ( )

This virtual function should return the matrix used. A subclass can call reset() and then scale, translate, etc to get the matrix wanted and then return Transform::matrix(). You can also skip doing anything and return Transform::matrix() if valid() is true, since you know the matrix has been calculated then.

Referenced by _validate(), append(), matrixAt(), and updateConcat().

bool Transform::transform ( double  x,
double  y,
double &  X,
double &  Y,
double &  Z 
)

Transform an input uv position into an output xyw.

Returns false for w <= 0. Such a point is not visible and has no output x/y position. However this version makes a "guess" as to what direction visible pixels that are near uv are and returns very large values for x,y in that direction. This is useful for calculating resulting bounding boxes.

bool Transform::concat_transform ( double  x,
double  y,
double &  X,
double &  Y,
double &  Z 
)

Same as transform() but it uses the concatenated matrix, thus transforming coordinates from concat_input(). This only works after validate() has been called.

void DD::Image::Transform::reset ( ) [inline]

Set the transformation to the identity.

void DD::Image::Transform::multiply ( const Matrix4 m) [inline]

Transform further by an arbitrary transformation matrix. Like OpenGL all transformation operations are done by post-multiply, so this transformation is applied in the object's space. For instance a rotate(1) followed by a translate(1,0) will move the center of the object along a diagonal line.

void Transform::rotateX ( float  radians) [inline]

Rotate about x (top towards camera) by angle radians.

void Transform::rotateY ( float  radians) [inline]

Rotate about y (left edge towards camera) by angle radians.

void Transform::rotateZ ( float  radians) [inline]

Rotate about z (counter-clockwise) by angle radians.

int Transform::filter ( ) const [inline]

Return the current filter type.

void DD::Image::Transform::clamp ( bool  v) [inline]

If true then any negative intermediate results are set to zero. This can improve the results from high-contrast images and filters with negative lobes if you know nothing in the input is negative, by deleting a lot of the ringing in black areas.

The default value is false.

void DD::Image::Transform::black_outside ( bool  v) [inline]

If true the transform will act as though any data outside the incoming bounding box is black. It will also produce an alpha channel if there is none in the input.

If this is false, Transform will replicate the pixels outside the bounding box instead. This will prevent any antialiasing on the edge. This is used by the Reformat operator, and may be useful for tile or camera shake type operators.

The default value is true.

unsigned Transform::node_color ( ) const [virtual]

All transform operators default to a purpleish color.

Reimplemented from DD::Image::Op.

const Matrix4 & DD::Image::Transform::concat_matrix ( ) const [inline]

After _validate() is done, this returns the transformation between the concat_input() and the output of this operator.

Referenced by updateConcat().

Iop * DD::Image::Transform::concat_input ( ) const [inline]

After _validate() is done this returns the operator that input will actually be read from.

Referenced by updateConcat().

void Transform::filter_knobs ( Knob_Callback  cb)

Subclasses should call this to insert a filter-selection control into their control panels. This adds the "filter type" and "clamp" controls.

References DD::Image::Bool_knob(), DD::Image::Filter::knobs(), DD::Image::Knob::NODEGRAPH_ONLY, DD::Image::SetFlags(), and DD::Image::Tooltip().

Referenced by knobs().

void Transform::motionblur_knobs ( Knob_Callback  cb)

Adds the motionblur amount and shutter knobs

do the shutter controls

References _motionblur, _shutter, DD::Image::Float_knob(), DD::Image::ShutterControls::knobs(), DD::Image::Knob::NODEGRAPH_ONLY, DD::Image::SetFlags(), and DD::Image::Tooltip().

Referenced by knobs().

void Transform::knobs ( Knob_Callback  cb) [virtual]
void Transform::sample ( float  cx,
float  cy,
float  w,
float  h,
Filter filter,
Pixel out 
) [virtual]

Disables motion blur!

Reimplemented from DD::Image::Iop.

References sample().

bool Transform::set_texturemap ( ViewerContext ctx,
bool  gl 
) [virtual]

Uses the input's texture map, but changes the OpenGL texture matrix to show it correctly translated.

Reimplemented from DD::Image::Iop.

References DD::Image::Matrix4::array(), and DD::Image::Iop::set_texturemap().