Writing transforms

From NVIDIA-Omniverse/ovrtx · View interactive version

Writing transforms is an AI agent skill from the GitHub repository NVIDIA-Omniverse/ovrtx. Writing 4x4 transform matrices to move, rotate, or scale prims. Use when user asks to move an object, set a transform, update position, animate a transform, or set a camera transform.

How to use this skill

Skill file

Writing Transforms

When to Use

Use this skill when the user asks to move an object, set a transform, update position, animate a transform, or set a camera transform.

Inputs

Resolve inputs in this order: existing repository files and referenced snippets, explicit user request, then broader agent context.

Prerequisites

Instructions

  1. Identify the target language, prim paths, transform representation, matrix convention, memory target, and sync/async requirement.
  2. Read the matching source snippet and copy its lifecycle pattern rather than inventing equivalent calls.
  3. Validate dtype, shape, semantic, and ownership rules before proposing or editing code.
  4. Keep bindings, mapped buffers, operation handles, and C strings alive only for the lifetimes documented by the referenced examples.
  5. When changing code, run the narrow docs test or example that owns the snippet whenever practical.

Output Format

Scripts

This skill has no scripts.

Limitations

Overview

Transforms control the position, rotation, and scale of prims in the scene. ovrtx supports three transform representations. The most common is a 4x4 matrix of doubles using the USD row-vector convention: translation is in the last row ([3][0..2]). Use the "omni:xform" attribute name, which is also used by the C convenience helpers in ovrtx_attributes.h.

Python

Write a 4x4 transform (single prim)

Source: tests/docs/python/test_attribute_shapes.py snippet doc-shape-mat4-array

Write transforms for multiple prims

Source: tests/docs/python/test_attribute_bindings.py snippet doc-bind-attribute-write

C

Write identity transform on a single prim

Source: examples/c/vulkan-interop/src/main.cpp snippet write-camera-transform

Batch write (N prims)

Source: examples/c/vulkan-interop/src/main.cpp snippet write-camera-transform

For multiple prims, increase prim_list.num_paths and provide a contiguous array of transforms.

C convenience helpers (`ovrtx_attributes.h`)

Instead of building DLTensor and binding descriptors manually, use the convenience helpers that handle the boilerplate:

Source: tests/docs/c/test_transform_helpers.cpp snippets doc-set-xform-mat-c, doc-set-xform-pos-rot-scale-c, doc-set-xform-pos-rot3x3-c, doc-set-reset-xform-stack-c.

#include <ovrtx/ovrtx_attributes.h> provides ovrtx_set_xform_mat(renderer, paths, count, transforms), ovrtx_set_xform_pos_rot_scale(...), ovrtx_set_xform_pos_rot3x3(...), and ovrtx_set_reset_xform_stack(...).

Tensor layout

Python and C expose different transform tensor layouts:

Source: tests/docs/python/test_attribute_shapes.py snippet doc-shape-mat4-array.

Source: tests/docs/c/test_attribute_shapes.cpp snippet doc-shape-mat4-array-c.

Semantics are a write-side conversion hint. ovrtx_read_attribute rejects any semantic other than OVRTX_SEMANTIC_NONE with "Semantic conversion is not supported for read_attribute". When reading a transform attribute, leave the semantic as OVRTX_SEMANTIC_NONE and ask for the raw storage layout.

Key Types / Functions

| Representation | Python | C | Size per prim |

|----------------|--------|---|---------------|

| 4x4 matrix (doubles) | Semantic.XFORM_MAT4x4 or dtype="float64", shape=(4, 4) | OVRTX_SEMANTIC_XFORM_MAT4x4 with ndim=1, shape=[N], dtype={kDLFloat, 64, 16} | 128 bytes |

| pos3d + rot4f + scale3f | (C only) | OVRTX_SEMANTIC_XFORM_POS3d_ROT4f_SCALE3f | 56 bytes |

| pos3d + rot3x3f | (C only) | OVRTX_SEMANTIC_XFORM_POS3d_ROT3x3f | 64 bytes |

C convenience helpers (#include <ovrtx/ovrtx_attributes.h>):

Python semantic: Semantic.XFORM_MAT4x4 (from from ovrtx import Semantic). For interop, the preferred approach is dtype="float64", shape=(4, 4) on bind_attribute/map_attribute, or passing an (N, 4, 4) float64 array directly to write_attribute (type is auto-inferred when the attribute already exists in the stage). The dtype parameter accepts string names ("float64"), NumPy dtypes (np.float64), or Python built-ins (float). The semantic= parameter is required when creating attributes from scratch via prim_mode=PrimMode.CREATE_NEW.

Troubleshooting

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.