maya-usd

repository·dev·Indexed 21 days ago

https://github.com/autodesk/maya-usd

A plugin for Autodesk Maya providing deep integration with OpenUSD. It enables loading USD stages directly into the Maya viewport for interactive editing and provides C++ and Python APIs for USD data manipulation. The plugin includes scripting commands for importing (mayaUSDImport) and exporting (mayaUSDExport) USD data, as well as tools for managing layers, prim schemas, and custom import chasers.

Tokens
118.5K
Snippets
177
Records
336
Agent score
72%

What's inside maya-usd

  1. Overview of AL_USDMaya Repository Structure

    dev

    The repository is organized into several key functional areas:

    LocationDescription
    libThe core AL_USDMaya Library
    pluginThe Maya plugin and test plugin
    samplesTest inputs
    schemasMaya-specific schemas with translators
    translatorsReference Schema Translator Plugins
    tutorialsTutorials
    utilsContains the event system (AL_EventSystem)
    mayautilsAL_MayaUtils (depends on Maya only)
    usdmayautilsAL_USDMayaUtils (depends on USD and Maya)
  2. Overview of the AL_MayaTest library

    dev

    The AL_MayaTest library is a testing framework for Maya-based code, specifically designed to wrap googletest. It is used to test AL_USDMaya translators and any other Maya plugin code. It consists of two primary modules:

    • testHelpers: Provides useful helper methods for writing custom tests.
    • testHarness: Provides the glue code to create a Maya plugin that acts as a wrapper around googletest. This allows you to run tests interactively inside Maya or in batch mode.
  3. Overview of the Maya USD Plugin

    dev

    The maya-usd plugin provides deep integration for OpenUSD within Autodesk Maya. It enables a modern, cross-DCC (Digital Content Creation) referencing pipeline, allowing data to flow between products like Maya and 3ds Max.

    Key capabilities include:

    • Direct Stage Loading: Load USD stages directly in the viewport for interactive editing without the need for traditional import/export cycles.
    • Advanced Integration: Deep integration with Maya's Viewport, Outliner, and Attribute Editor.
    • Extensibility: A powerful API available in both C++ and Python to manipulate USD data directly or extend the import/export processes.
    • Authoring Environments: Supports Edit Routing for powerful authoring, connection to BifrostUSD for procedural USD editing, and material editing via LookdevX.
  4. Overview of Maya Helper Classes

    dev

    The lib/AL_USDMaya/AL/maya module provides a collection of non-USD specific helper and convenience classes designed to reduce boilerplate when developing Maya plugins. Key utilities include:

    • Common.h: Macros for reducing boilerplate code.
    • CommandGuiHelper.h: Automatically generates simple UIs from MPxCommands.
    • DGNodeHelper.h: Utilities for getting/setting types on Dependency Graph (DG) Nodes.
    • FileTranslatorBase.h: Macros and templates to automate the setup of Maya import/export plugins.
    • FileTranslatorOptions.h: Utility for parsing file translator options passed by Maya.
    • MenuBuilder.h: Generates menu entries for an entire plugin.
    • NodeHelper.h: Functions for adding static/dynamic attributes to MPxNode, retrieving data from a MDataBlock, and AE (Attribute Editor) template generators.
    • SIMD.h: Low-level SSE/AVX routines (not Maya-dependent).
  5. Core Modules and Developer Documentation

    dev

    The Maya USD plugin provides several core modules for developers looking to extend or interact with USD within Maya. Key areas of functionality include:

    • Command Interface: Common plug-in base commands for interacting with USD.
    • File I/O & Translation: Managing import/export options, adding new options, and using SchemaAPI translators.
    • Plugin Development: Tutorials for creating custom import/export plugins in both Python and C++.
    • UFE (Universal Scene Description Framework Engine): Working with UFE transforms (e.g., UsdTransform3d).
    • Rendering & Materials: MaterialX support, MaterialX code generation, and Hydra integration for Maya.
    • Scene Management: Layer saving, layer locking, edit routing, and Maya Reference Edit Router functionality.
    • UI & UX: Undo/Redo support and Attribute Editor (AE) templates for USD schemas.
  6. What is the OpUndo Undo/Redo Helper Framework?

    dev

    The OpUndo system is a C++ framework designed to support undo/redo operations across multiple heterogeneous frameworks used within the MayaUSD plugin (such as UFE, USD, OpenMaya, MEL, Python, and pure C++).

    Important Distinction: OpUndo is not an undo/redo stack or an undo manager. It does not replace Maya's built-in undo system. Instead, it is a mechanism to record the specific individual steps (items) that need to be undone or redone so that Maya's undo system can trigger them correctly.

  7. What is the Camera Proxy node?

    dev

    The AL_usd_ProxyUsdGeomCamera node acts as a bridge between a Maya camera and a USD UsdGeomCamera.

    Its primary purpose is to allow interactive editing of USD camera attributes directly from Maya. Instead of duplicating data between Maya and USD, the proxy node reads from and writes directly to the USD camera attributes. When connected to a Maya camera, it drives the Maya camera attributes while simultaneously updating the underlying USD stage, ensuring both environments stay in sync.

  8. What is AL_USDMaya?

    dev

    AL_USDMaya is a USD-Maya bridge designed to represent Maya data in Maya and USD data in USD. It is specifically tailored for complex workflows where native Maya entities (like complex referenced rigs or assets not easily represented in USD) need to be embedded in USD scenes and imported into Maya in their native form.

    Key capabilities include:

    • Live Connection: Maintains a sync between the USD and Maya scenes, responding to events to keep them in alignment.
    • Dynamic Representations: Allows artists to swap representations of objects (e.g., swapping a Rig for a Geometry Cache or different Levels of Detail).
    • Heavyweight Scene Elements: Supports representing large elements like sets or crowds in the Maya viewport using OpenGL, allowing manipulation via both USD and Maya tools/UI.
  9. What is Mesh Translation in Maya USD

    dev

    Mesh Translation is the process of moving Mesh information from USD/Hydra into Maya, allowing you to use Maya's native geometry manipulation tools, and then writing those changes back to USD/Hydra.

    By default, Mesh typed prims are not automatically translated into Maya geometry when using a ProxyShape. To bring a mesh into Maya for editing, you must explicitly use the AL_usdmaya_TranslatePrim command.

  10. What is Edit Routing in Maya USD

    dev

    By default, USD modifications in Maya are written to the current edit target (the layer selected in the Layer Editor). Edit routing is a mechanism that allows you to intercept these modifications and redirect them to a specific USD layer instead of the current target.

    This is achieved by registering a routing function (an 'edit router') that receives information about the USD prim being modified and the operation being performed. The router can then return a specific layer ID or handle to redirect the edit. If the router returns nothing, the modification proceeds to the current targeted layer.

  11. How animation frame sampling works in `usdExport`

    dev

    Animation export in usdExport uses two main parameters: -frameRange and -frameStride.

    1. Frame Stride (-ft): This is the primary way to control sampling density. A stride of 0.5 doubles the samples; a stride of 2.0 takes every other frame. Note that the last frame in the range might be skipped if the stride doesn't land exactly on it.
    2. Frame Samples (-fs): An advanced option for fine-grained control. These samples are evaluated relative to the current time.

    Processing Order:

    1. The current time starts at the first frame of the range.
    2. Frame samples are evaluated (relative to the current time).
    3. The time advances by the frameStride.
    4. This repeats until the end of the range.
    5. All resulting time samples are sorted before export.

    Example Behavior: If frameRange is [1, 3], frameStride is 1.0, and frameSample is [-0.1, 0.2], the exported time samples will be: 0.9, 1.2, 1.9, 2.2, 2.9, 3.2.

  12. How Schema Translators work in Maya USD

    dev

    A Schema Translator is the primary mechanism used to map USD data into Maya forms. When the AL_USDMaya import functionality encounters a 'Typed' USDSchema that has a registered translator, it executes that translator to convert the USD data into Maya objects.

    Capabilities of a Schema Translator include:

    • Converting a USD prim hierarchy into Maya DAG Nodes or DG Nodes.
    • Setting up Maya scene parameters (e.g., start/end frame ranges).
    • Connecting USD attributes to Maya attributes (e.g., driving a Maya camera from a USD camera).
    • Copying data from a USD prim to a matching Maya prim.
    • Performing arbitrary scene operations or delegating work to existing Python pipeline code.
    • Handling custom USD schemas for DCC-native types (e.g., MayaReferences).

    Note: Currently, there is no support for USD export via translators.