Home Reference VEX VEX functions 

ptransform vex function

Contexts: chop , cop , displace , fog , image3d , light , photon , pop , shadow , sop , surface

Tags: transform

Transforms a vector from one space to another.

  1. vector ptransform(vector , matrix )

  2. vector ptransform(string tospace, vector v)

    Transforms from “space:current” (see below).

  3. vector ptransform(string fromspace, string tospace, vector v)

The transform functions let you transform a vector from one space to another.

  • ptransform interprets the vector as a position.

  • vtransform interprets the vector as a direction vector, and so doesn’t apply the translations from the matrix.

  • ntransform interprets the vector as a normal vector, and so multiplies by the inverse transpose of the matrix (ignoring the translations).

The possible values for the space arguments are:

An object path

Use the object space of an object specifed by a path string.

Tip

In some cases, such as point instancing, mantra may automatically mangle object paths. You can generate an .ifd file and look inside to try to find what mantra is calling the object you want.

"space:object"

Object space of the current object.

"space:world"

Houdini world space.

"space:camera"

mantra camera space.

"space:texture"

Space assigned to the current shader.

"space:ndc"

Normal Device Coordinate space.

"space:current"

The current space the vector is in.

"space:world"

Houdini world space.

The version with only a tospace argument assumes fromspace is “space:current”. For example:

Pworld = ptransform("space:world", P);

…is equivalent to:

Pworld = ptransform("space:current", "space:world", P);

Examples

Transform a vector from its current space to object space:

ospace = ptransform("space:object", P)

Transform a vector from object space to mantra’s natural coordinate space (“camera” space):

ospace = ptransform("space:object", "space:current", P)