Skip to content

Intrinsic attributes

Extract transform matrix from packed primitive

The following example shows how to extract the transformation matrix from a packed primitive and convert it to a quaternion. This is a useful technique when you need to extract the transformation from an RBD packed object and replace pieces with new geometry after sim.

Extract matrix4 from packed transform and convert it to quaternion. "packfulltransform" - is a matrix4 attribute that contains the full transform of the primitive.

Primitive.wrangle
matrix xform = primintrinsic(0, "packedfulltransform", @primnum);
removeprim(0, @primnum, 0);
matrix3 rotation = matrix3(xform);
vector4 orient = quaternion(rotation);
@orient = orient;

Extract matrix3 from packed transform and convert it to quaternion. "transform" - is a matrix3 attribute that contains the rotation of the primitive.

Primitive.wrangle
matrix3 xform = primintrinsic(0, "transform", @primnum);
removeprim(0, @primnum, 0);
vector4 orient = quaternion(xform);
@orient = orient;