usdex.core#
usdex.core provides higher-level convenience functions top of lower-level OpenUSD concepts, so developers can quickly adopt OpenUSD best practices when mapping their native data sources to OpenUSD-legible data models.
Functions:
|
Verify the expected usdex modules are being loaded at runtime. |
|
Decorator used to deprecate public functions |
Test whether the |
|
Activates the |
|
Deactivates the |
|
|
Set the |
Get the current |
|
|
Set the |
Get the current |
|
|
Check if the |
|
Set metadata on the |
|
Save the given |
|
Export the given |
|
Create and configure a Usd.Stage so that the defining metadata is explicitly authored. |
|
Configure a stage so that the defining metadata is explicitly authored. |
|
Save the given |
|
Overloaded function. |
|
Produce a valid prim name from the input name |
|
Take a vector of the preferred names and return a matching vector of valid and unique names. |
|
Take a prim and a preferred name. |
|
Take a prim and a vector of the preferred names. |
|
Produce a valid property name using the Bootstring algorithm. |
|
Take a vector of the preferred names and return a matching vector of valid and unique names. |
|
Return this prim's display name (metadata). |
|
Sets this prim's display name (metadata) |
|
Clears this prim's display name (metadata) in the current EditTarget (only) |
|
Block this prim's display name (metadata) |
Calculate the effective display name of this prim |
|
|
Overloaded function. |
|
Get the local transform of a prim at a given time. |
|
Get the local transform of a prim at a given time in the form of a 4x4 matrix. |
|
Get the local transform of a prim at a given time in the form of common transform components. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Overloaded function. |
|
Determines if a UsdPrim has a |
|
Get the "correct" light attribute for a light that could have any combination of authored old and new UsdLux schema attributes |
|
Overloaded function. |
|
Overloaded function. |
|
Create a |
|
Authors a direct binding to the given material on this prim. |
|
Get the effective surface Shader of a Material for the universal render context. |
|
Overloaded function. |
|
Adds a diffuse texture to a preview material |
|
Adds a normals texture to a preview material |
|
Adds an ORM (occlusion, roughness, metallic) texture to a preview material |
Adds a single channel roughness texture to a preview material |
|
Adds a single channel metallic texture to a preview material |
|
|
Adds a single channel opacity texture to a preview material |
|
Adds |
|
Removes any |
|
Get the str matching a given ColorSpace |
|
Translate an sRGB color value to linear color space |
|
Translate a linear color value to sRGB color space |
Classes:
Controls the diagnostics that will be emitted when the |
|
Control the output stream to which diagnostics are logged. |
|
The NameCache class provides a mechanism for generating unique and valid names for UsdPrims and their UsdProperties. |
|
|
|
Enumerates the rotation order of the 3-angle Euler rotation. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Texture color space (encoding) types |
- usdex.core.version() str#
Verify the expected usdex modules are being loaded at runtime.
- Returns:
A human-readable version string for the usdex modules.
- usdex.core.deprecated(version: str, message: str)#
Decorator used to deprecate public functions
Example:
@deprecated("0.5", "Use `baz` instead") def foo(bar: str) -> str: return baz(bar)
- Parameters:
version – The major.minor version in which the function was first deprecated
message – A user facing message about the deprecation, ideally with a suggested alternative function. Do not include the version in this message, it will be prefixed automatically.
- class usdex.core.DiagnosticsLevel#
Controls the diagnostics that will be emitted when the
Delegateis active.Members:
eFatal : Only
Tf.Fatalare emitted.eError : Emit
Tf.ErrorandTf.Fatal, but suppressTf.WarnandTf.Statusdiagnostics.eWarning : Emit
Tf.Warn,Tf.Error, andTf.Fatal, but suppressTf.Statusdiagnostics.eStatus : All diagnostics are emitted.
Attributes:
- property name#
- class usdex.core.DiagnosticsOutputStream#
Control the output stream to which diagnostics are logged.
Members:
eNone : All diagnostics are suppressed.
eStdout : All diagnostics print to the
stdoutstream.eStderr : All diagnostics print to the
stderrstream.Attributes:
- property name#
- usdex.core.isDiagnosticsDelegateActive() bool#
Test whether the
Delegateis currently active.When active, the
Delegatereplaces the defaultTfDiagnosticMgrprinting with a more customized result. SeeactivateDiagnosticsDelegate()for more details.- Returns:
Whether the Delegate is active
- usdex.core.activateDiagnosticsDelegate() None#
Activates the
Delegateto specializeTfDiagnosticshandling.The
Tfmodule from OpenUSD provides various diagnostic logging abilities, including the ability to override the default message handler (which prints tostderr) with one or more custom handlers.This function can be used to activate a specialized
TfDiagnosticMgr::Delegateprovided by OpenUSD Exchange. The primary advantages of thisDelegateare:Diagnostics can be filtered by
DiagnosticsLevel.Diagnostics can be redirected to
stdout,stderr, or muted entirely usingDiagnosticsOutputStream.The message formatting is friendlier to end-users.
Note
Use of this
Delegateis entirely optional and it is not activated by default when loading this module. To active it, client code must explicitly callactivateDiagnosticsDelegate(). This is to allow clients to opt-in and to prevent double printing for clients that already have their ownTfDiagnosticMgr::Delegateimplementation.
- usdex.core.deactivateDiagnosticsDelegate() None#
Deactivates the
Delegateto restore defaultTfDiagnosticshandling.When deactivated, the default
TfDiagnosticMgrprinting is restored, unless some otherDelegateis still active.
- usdex.core.setDiagnosticsLevel( ) None#
Set the
DiagnosticsLevelfor theDelegateto filterTfDiagnosticsby severity.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate().- Parameters:
value – The highest severity
DiagnosticsLevelthat should be emitted.
- usdex.core.getDiagnosticsLevel() usdex.core._usdex_core.DiagnosticsLevel#
Get the current
DiagnosticsLevelfor theDelegate.This can be called at any time, but the filtering will only take affect after calling
activateDiagnosticsDelegate().- Returns:
The current
DiagnosticsLevelfor theDelegate.
- usdex.core.setDiagnosticsOutputStream( ) None#
Set the
DiagnosticsOutputStreamfor theDelegateto redirectTf.Diagnosticsto different streams.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate().- Parameters:
value – The stream to which all diagnostics should be emitted.
- usdex.core.getDiagnosticsOutputStream() usdex.core._usdex_core.DiagnosticsOutputStream#
Get the current
DiagnosticsOutputStreamfor theDelegate.This can be called at any time, but will only take affect after calling
activateDiagnosticsDelegate().- Returns:
The current
DiagnosticsOutputStreamfor theDelegate.
- usdex.core.hasLayerAuthoringMetadata(layer: pxr.Sdf.Layer) bool#
Check if the
Sdf.Layerhas metadata indicating the provenance of the data.Note
This metadata is strictly informational, it is not advisable to drive runtime behavior from this metadata. In the future, the “creator” key may change, or a more formal specification for data provenance may emerge.
Checks the CustomLayerData for a “creator” key.
- Parameters:
layer – The layer to check
- Returns:
A bool indicating if the metadata exists
- usdex.core.setLayerAuthoringMetadata(layer: pxr.Sdf.Layer, value: str) None#
Set metadata on the
Sdf.Layerindicating the provenance of the data.It is desirable to capture data provenance information into the metadata of SdfLayers, in order to keep track of what tools & versions were used throughout content creation pipelines, and to capture notes from the content author. While OpenUSD does not currently have a formal specification for this authoring metadata, some conventions have emerged throughout the OpenUSD Ecosystem.
The most common convention for tool tracking is to include a “creator” string in the
Sdf.Layer.customLayerData. Similarly, notes from the content author should be captured viaSdf.Layer.SetComment. While these are trivial usingSdf.Layerpublic methods, they are also easy to forget, and difficult to discover.This function assists authoring applications in settings authoring metadata, so that each application can produce consistant provenance information. The metadata should only add information which can be used to track the data back to its origin. It should not be used to store sensitive information about the content, nor about the end user (i.e. do not use it to store Personal Identifier Information).
Example
layer = Sdf.Layer.CreateAnonymous() authoring_metadata = "My Content Editor® 2024 SP 2, USD Exporter Plugin v1.1.23.11" usdex.core.exportLayer(layer, file_name, authoring_metadata, user_comment);
Note
This metadata is strictly informational, it is not advisable to drive runtime behavior from this metadata. In the future, the “creator” key may change, or a more formal specification for data provenance may emerge.
- Parameters:
layer – The layer to modify
value – The provenance information for this layer
- usdex.core.saveLayer(
- layer: pxr.Sdf.Layer,
- authoringMetadata: str | None = None,
- comment: str | None = None,
Save the given
Sdf.Layerwith an optional commentNote
This does not impact sublayers or any stages that this layer may be contributing to. See
setLayerAuthoringMetadatafor details. This is to preserve authoring metadata on referenced layers that came from other applications.- Parameters:
layer – The stage to be saved.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadatafor details.comment –
The comment will be authored in the layer as the
Sdf.Layercomment.- Returns:
A bool indicating if the save was successful.
- usdex.core.exportLayer(
- layer: pxr.Sdf.Layer,
- identifier: str,
- authoringMetadata: str,
- comment: str | None = None,
- fileFormatArgs: Dict[str, str] = {},
Export the given
Sdf.Layerto an identifier with an optional comment.Note
This does not impact sublayers or any stages that this layer may be contributing to. See
setLayerAuthoringMetadatafor details. This is to preserve authoring metadata on referenced layers that came from other applications.- Parameters:
layer – The layer to be exported.
identifier – The identifier to be used for the new layer.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadatafor details. If the “creator” key already exists, it will not be overwritten & this data will be ignored.comment – The comment will be authored in the layer as the
Sdf.Layercomment.fileFormatArgs – Additional file format-specific arguments to be supplied during layer export.
- Returns:
A bool indicating if the export was successful.
- usdex.core.createStage(
- identifier: str,
- defaultPrimName: str,
- upAxis: str,
- linearUnits: float,
- authoringMetadata: str,
- fileFormatArgs: dict | None = None,
Create and configure a Usd.Stage so that the defining metadata is explicitly authored.
See configureStage for more details.
Note
The extension of the identifier must be associated with a file format that supports editing.
- Parameters:
identifier – The identifier to be used for the root layer of this stage.
defaultPrimName – Name of the root prim root prim.
upAxis – The up axis for all the geometry contained in the stage.
linearUnits – The meters per unit for all linear measurements in the stage.
authoringMetadata – The provenance information from the host application. See setLayerAuthoringMetadata for details.
fileFormatArgs – Additional file format-specific arguments to be supplied during Stage creation.
- Returns:
The newly created stage or None
- usdex.core.configureStage(
- stage: pxr.Usd.Stage,
- defaultPrimName: str,
- upAxis: str,
- linearUnits: float,
- authoringMetadata: str | None = None,
Configure a stage so that the defining metadata is explicitly authored.
The default prim will be used as the target of a Reference or Payload to this layer when no explicit prim path is specified. A root prim with the given
defaultPrimNamewill be defined on the stage. If a new prim is defined then the type name will be set toScope.The stage metrics of Up Axis and Linear Units will be authored.
The root layer will be annotated with authoring metadata, unless previously annotated. This is to preserve authoring metadata on referenced layers that came from other applications. See
setLayerAuthoringMetadatafor more details.- Parameters:
stage – The stage to be configured.
defaultPrimName – Name of the default root prim.
upAxis – The up axis for all the geometry contained in the stage.
linearUnits – The meters per unit for all linear measurements in the stage.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadatafor details.
- Returns:
A bool indicating if the metadata was successfully authored.
- usdex.core.saveStage(
- stage: pxr.Usd.Stage,
- authoringMetadata: str | None = None,
- comment: str | None = None,
Save the given
Usd.Stagewith metadata applied to all dirty layers.Save all dirty layers and sublayers contributing to this stage.
All dirty layers will be annotated with authoring metadata, unless previously annotated. This is to preserve authoring metadata on referenced layers that came from other applications.
The comment will be authored in all layers as the SdfLayer comment.
- Parameters:
stage – The stage to be saved.
authoringMetadata – The provenance information from the host application. See
setLayerAuthoringMetadatafor details. If the “creator” key already exists on a given layer, it will not be overwritten & this data will be ignored.comment – The comment will be authored in all dirty layers as the
Sdf.Layercomment.
- usdex.core.isEditablePrimLocation(*args, **kwargs)#
Overloaded function.
isEditablePrimLocation(stage: pxr.Usd.Stage, path: pxr.Sdf.Path) -> tuple
Validate that prim opinions could be authored at this path on the stage
This validates that the
stageandpathare valid, and that the path is absolute. If a prim already exists at the given path it must not be an instance proxy.If the location is invalid and
reasonis non-null, an error message describing the validation error will be set.- Parameters:
stage - The stage to consider.
path - The absolute to consider.
- Returns:
Tuple[bool, str] with a bool indicating if the location is valid, and the string is a non-empty reason if the location is invalid.
isEditablePrimLocation(prim: pxr.Usd.Prim, name: str) -> tuple
Validate that prim opinions could be authored for a child prim with the given name
This validates that the
primis valid, and that thenameis a valid identifier. If a prim already exists at the given path it must not be an instance proxy.If the location is invalid and
reasonis non-null, an error message describing the validation error will be set.- Parameters:
parent - The UsdPrim which would be the parent of the proposed location.
name - The name which would be used for the UsdPrim at the proposed location.
- Returns:
Tuple[bool, str] with a bool indicating if the location is valid, and the string is a non-empty reason if the location is invalid.
- usdex.core.getValidPrimName(name: str) str#
Produce a valid prim name from the input name
- Parameters:
name – The input name
- Returns:
A string that is considered valid for use as a prim name.
- usdex.core.getValidPrimNames(
- names: List[str],
- reservedNames: list(str) = [],
Take a vector of the preferred names and return a matching vector of valid and unique names.
- Parameters:
names – A vector of preferred prim names.
reservedNames – A vector of reserved prim names. Names in the vector will not be included in the returns.
- Returns:
A vector of valid and unique names.
- usdex.core.getValidChildName(prim: pxr.Usd.Prim, name: str) str#
Take a prim and a preferred name. Return a valid and unique name as the child name of the given prim.
- Parameters:
prim – The USD prim where the given prim name should live under.
names – A preferred prim name.
- Returns:
A valid and unique name.
- usdex.core.getValidChildNames(prim: pxr.Usd.Prim, names: List[str])#
Take a prim and a vector of the preferred names. Return a matching vector of valid and unique names as the child names of the given prim.
- Parameters:
prim – The USD prim where the given prim names should live under.
names – A vector of preferred prim names.
- Returns:
A vector of valid and unique names.
- class usdex.core.NameCache#
The NameCache class provides a mechanism for generating unique and valid names for UsdPrims and their UsdProperties.
The class ensures that generated names are valid according to OpenUSD name requirements and are unique within the context of sibling Prim and Property names.
The cache provides a performant alternative to repeated queries by caching generated names and managing reserved names for Prims and Properties.
Because reserved names are held in the cache, collisions can be avoided in cases where the Prim or Property has not been authored in the Stage. Names can be requested individually or in bulk, supporting a range of authoring patterns. Cache entries are based on prim path and are not unique between stages or layers.
The name cache can be used in several authoring contexts, by providing a particular parent type: - SdfPath: Useful when generating names before authoring anything in USD. - UsdPrim: Useful when authoring in a UsdStage. - SdfPrimSpec: Useful when authoring in an SdfLayer
When a cache entry is first created it will be populated with existing names depending on the scope of the supplied parent. - Given an SdfPath no names will be reserved - Given a UsdPrim it’s existing child Prim and Property names (after composition) will be reserved - Given an SdfPrimSpec it’s existing child Prim and Property names (before composition) will be reserved
The parent must be stable to be useable as a cache key. - An SdfPath must be an absolute prim path containing no variant selections. - A UsdPrim must be valid. - An SdfPrimSpec must not be NULL or dormant.
The pseudo root cannot have properties, therefore it is not useable as a parent for property related functions.
Warning
This class does not automatically invalidate cached values based on changes to the prims from which values were cached. Additionally, a separate instance of this class should be used per-thread, calling methods from multiple threads is not safe.
Methods:
clear(*args, **kwargs)Overloaded function.
clearPrimNames(*args, **kwargs)Overloaded function.
clearPropertyNames(*args, **kwargs)Overloaded function.
getPrimName(*args, **kwargs)Overloaded function.
getPrimNames(*args, **kwargs)Overloaded function.
getPropertyName(*args, **kwargs)Overloaded function.
getPropertyNames(*args, **kwargs)Overloaded function.
update(*args, **kwargs)Overloaded function.
updatePrimNames(*args, **kwargs)Overloaded function.
updatePropertyNames(*args, **kwargs)Overloaded function.
- clear(*args, **kwargs)#
Overloaded function.
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim path
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim
clear(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved prim and property names for a prim.
- Args:
parent: The parent prim spec
- clearPrimNames(*args, **kwargs)#
Overloaded function.
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
clearPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved child names for a prim.
- Args:
parent: The parent prim path
- clearPropertyNames(*args, **kwargs)#
Overloaded function.
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim path
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim
clearPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Clear the reserved property names for a prim.
- Args:
parent: The parent prim spec
- getPrimName(*args, **kwargs)#
Overloaded function.
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim path name: Preferred name
- Returns:
Valid and unique name token
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim name: Preferred name
- Returns:
Valid and unique name token
getPrimName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, name: str) -> str
Make a name valid and unique for use as the name of a child of the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim spec name: Preferred name
- Returns:
Valid and unique name token
- getPrimNames(*args, **kwargs)#
Overloaded function.
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim path names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of a children of the given prim.
- Args:
parent: The parent prim spec names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
- getPropertyName(*args, **kwargs)#
Overloaded function.
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim path name: Preferred name
- Returns:
Valid and unique name token
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim name: Preferred name
- Returns:
Valid and unique name token
getPropertyName(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, name: str) -> str
Make a name valid and unique for use as the name of a property on the given prim.
An invalid token is returned on failure.
- Args:
parent: The parent prim spec name: Preferred name
- Returns:
Valid and unique name token
- getPropertyNames(*args, **kwargs)#
Overloaded function.
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.Path, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim path names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
getPropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec, names: List[str]) -> list(str)
Make a list of names valid and unique for use as the names of properties on the given prim.
- Args:
parent: The parent prim spec names: Preferred names
- Returns:
A vector of Valid and unique name tokens ordered to match the preferred names
- update(*args, **kwargs)#
Overloaded function.
update(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved child and property names for a prim to include existing children and properties.
- Args:
parent: The parent prim
update(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved child and property names for a prim to include existing children and properties.
- Args:
parent: The parent prim spec
- updatePrimNames(*args, **kwargs)#
Overloaded function.
updatePrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved child names for a prim to include existing children.
- Args:
parent: The parent prim
updatePrimNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved child names for a prim to include existing children.
- Args:
parent: The parent prim spec
- updatePropertyNames(*args, **kwargs)#
Overloaded function.
updatePropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Usd.Prim) -> None
Update the reserved property names for a prim to include existing properties.
- Args:
parent: The parent prim
updatePropertyNames(self: usdex.core._usdex_core.NameCache, parent: pxr.Sdf.PrimSpec) -> None
Update the reserved property names for a prim to include existing properties.
- Args:
parent: The parent prim spec
- class usdex.core.ValidChildNameCache(**kwargs)#
- usdex.core.getValidPropertyName(name: str) str#
Produce a valid property name using the Bootstring algorithm.
- Parameters:
name – The input name
- Returns:
A string that is considered valid for use as a property name.
- usdex.core.getValidPropertyNames(
- names: List[str],
- reservedNames: list(str) = [],
Take a vector of the preferred names and return a matching vector of valid and unique names.
- Parameters:
names – A vector of preferred property names.
reservedNames – A vector of reserved prim names. Names in the vector will not be included in the return.
- Returns:
A vector of valid and unique names.
- usdex.core.getDisplayName(prim: pxr.Usd.Prim) str#
Return this prim’s display name (metadata).
- Parameters:
prim – The prim to get the display name from
- Returns:
Authored value, or an empty string if no display name has been set.
- usdex.core.setDisplayName(prim: pxr.Usd.Prim, name: str) bool#
Sets this prim’s display name (metadata)
DisplayName is meant to be a descriptive label, not necessarily an alternate identifier; therefore there is no restriction on which characters can appear in it
- Parameters:
prim – The prim to set the display name for
name – The value to set
- Returns:
True on success, otherwise false
- usdex.core.clearDisplayName(prim: pxr.Usd.Prim) bool#
Clears this prim’s display name (metadata) in the current EditTarget (only)
- Parameters:
prim – The prim to clear the display name for
- Returns:
True on success, otherwise false
- usdex.core.blockDisplayName(prim: pxr.Usd.Prim) bool#
Block this prim’s display name (metadata)
The fallback value will be explicitly authored to cause the value to resolve as if there were no authored value opinions in weaker layers
- Parameters:
prim – The prim to block the display name for
- Returns:
True on success, otherwise false
- usdex.core.computeEffectiveDisplayName(prim: pxr.Usd.Prim) str#
Calculate the effective display name of this prim
If the display name is un-authored or empty then the prim’s name is returned
- Parameters:
prim – The prim to compute the display name for
- Returns:
The effective display name
- usdex.core.defineXform(*args, **kwargs)#
Overloaded function.
defineXform(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, transform: Optional[pxr.Gf.Transform] = None) -> pxr.UsdGeom.Xform
Defines an xform on the stage.
- Parameters:
stage - The stage on which to define the xform
path - The absolute prim path at which to define the xform
transform - Optional local transform to set
- Returns:
UsdGeom.Xform schema wrapping the defined Usd.Prim. Returns an invalid schema on error.
defineXform(parent: pxr.Usd.Prim, name: str, transform: Optional[pxr.Gf.Transform] = None) -> pxr.UsdGeom.Xform
Defines an xform on the stage.
- Parameters:
parent - Prim below which to define the xform
name - Name of the xform
transform - Optional local transform to set
- Returns:
UsdGeom.Xform schema wrapping the defined Usd.Prim. Returns an invalid schema on error.
- class usdex.core.RotationOrder#
Enumerates the rotation order of the 3-angle Euler rotation.
Members:
eXyz
eXzy
eYxz
eYzx
eZxy
eZyx
Attributes:
- property name#
- usdex.core.getLocalTransform(
- prim: pxr.Usd.Prim,
- time: pxr.Usd.TimeCode = nan,
Get the local transform of a prim at a given time.
- Parameters:
prim – The prim to get local transform from.
time – Time at which to query the value.
- Returns:
Transform value as a transform.
- usdex.core.getLocalTransformMatrix(
- prim: pxr.Usd.Prim,
- time: pxr.Usd.TimeCode = nan,
Get the local transform of a prim at a given time in the form of a 4x4 matrix.
- Parameters:
prim – The prim to get local transform from.
time – Time at which to query the value.
- Returns:
Transform value as a 4x4 matrix.
- usdex.core.getLocalTransformComponents(
- prim: pxr.Usd.Prim,
- time: pxr.Usd.TimeCode = nan,
Get the local transform of a prim at a given time in the form of common transform components.
- Parameters:
prim – The prim to get local transform from.
time – Time at which to query the value.
- Returns:
Transform value as a tuple of translation, pivot, rotation, rotation order, scale.
- usdex.core.setLocalTransform(*args, **kwargs)#
Overloaded function.
setLocalTransform(prim: pxr.Usd.Prim, transform: pxr.Gf.Transform, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim.
- Parameters:
prim - The prim to set local transform on.
transform - The transform value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(prim: pxr.Usd.Prim, matrix: pxr.Gf.Matrix4d, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim from a 4x4 matrix.
- Parameters:
prim - The prim to set local transform on.
matrix - The matrix value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
setLocalTransform(prim: pxr.Usd.Prim, translation: pxr.Gf.Vec3d, pivot: pxr.Gf.Vec3d, rotation: pxr.Gf.Vec3f, rotationOrder: usdex.core._usdex_core.RotationOrder, scale: pxr.Gf.Vec3f, time: pxr.Usd.TimeCode = nan) -> bool
Set the local transform of a prim from common transform components.
- Parameters:
prim - The prim to set local transform on.
translation - The translation value to set.
pivot - The pivot position value to set.
rotation - The rotation value to set in degrees.
rotationOrder - The rotation order of the rotation value.
scale - The scale value to set.
time - Time at which to write the value.
- Returns:
A bool indicating if the local transform was set.
- usdex.core.definePointCloud(*args, **kwargs)#
Overloaded function.
definePointCloud(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, points: pxr.Vt.Vec3fArray, ids: Optional[pxr.Vt.Int64Array] = None, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Points
Defines a
UsdGeom.Pointsprim on the stage.Attribute values will be validated and in the case of invalid data the Points will not be defined. An invalid
UsdGeom.Pointsobject will be returned in this case.Values will be authored for all attributes required to completely describe the Points, even if weaker matching opinions already exist.
Point Count
Points
Extent
The “extent” of the Points will be computed and authored based on the
pointsandwidthsprovided.The following common primvars can optionally be authored at the same time using a
PrimvarDatato specify interpolation, data, and optionally indices or elementSize.Ids
Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widthsandprimvars:normals, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the points.
path The absolute prim path at which to define the points.
points Vertex/CV positions for the points described in local space.
ids Values for the id specification for the points.
widths Values for the width specification for the points.
normals Values for the normals primvar for the points. Only Vertex normals are considered valid.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.Pointsschema wrapping the definedUsd.Prim
definePointCloud(prim: pxr.Usd.Prim, name: str, points: pxr.Vt.Vec3fArray, ids: Optional[pxr.Vt.Int64Array] = None, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Points
Defines a
UsdGeom.Pointsprim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim The stage on which to define the points.
name The absolute prim path at which to define the points.
points Vertex/CV positions for the points described in local space.
ids Values for the id specification for the points.
widths Values for the width specification for the points.
normals Values for the normals primvar for the points. Only Vertex normals are considered valid.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.Pointsschema wrapping the definedUsd.Prim
- usdex.core.definePolyMesh(*args, **kwargs)#
Overloaded function.
definePolyMesh(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, faceVertexCounts: pxr.Vt.IntArray, faceVertexIndices: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, uvs: Optional[usdex.core._usdex_core.Vec2fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Mesh
Defines a basic polygon mesh on the stage.
All interrelated attribute values will be authored, even if weaker matching opinions already exist.
The following common primvars can optionally be authored at the same time.
Normals
Primary UV Set
Display Color
Display Opacity
- Parameters:
stage - The stage on which to define the mesh
path - The absolute prim path at which to define the mesh
faceVertexCounts - The number of vertices in each face of the mesh
faceVertexIndices - Indices of the positions from the
pointsto use for each face vertexpoints - Vertex positions for the mesh described points in local space
normals - Values to be authored for the normals primvar
uvs - Values to be authored for the uv primvar
displayColor - Value to be authored for the display color primvar
displayOpacity - Value to be authored for the display opacity primvar
- Returns:
UsdGeom.Meshschema wrapping the definedUsd.Prim.
definePolyMesh(parent: pxr.Usd.Prim, name: str, faceVertexCounts: pxr.Vt.IntArray, faceVertexIndices: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, uvs: Optional[usdex.core._usdex_core.Vec2fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.Mesh
Defines a basic polygon mesh on the stage.
All interrelated attribute values will be authored, even if weaker matching opinions already exist.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the mesh
name - Name of the mesh
faceVertexCounts - The number of vertices in each face of the mesh
faceVertexIndices - Indices of the positions from the
pointsto use for each face vertexpoints - Vertex positions for the mesh described points in local space
normals - Values to be authored for the normals primvar
uvs - Values to be authored for the uv primvar
displayColor - Value to be authored for the display color primvar
displayOpacity - Value to be authored for the display opacity primvar
- Returns:
UsdGeom.Meshschema wrapping the definedUsd.Prim.
- usdex.core.defineLinearBasisCurves(*args, **kwargs)#
Overloaded function.
defineLinearBasisCurves(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Linear
UsdGeom.BasisCurvesprim on the stage.Attribute values will be validated and in the case of invalid data the Curves will not be defined. An invalid
UsdGeom.BasisCurvesobject will be returned in this case.Values will be authored for all attributes required to completely describe the Curves, even if weaker matching opinions already exist.
Curve Vertex Counts
Points
Type
Wrap
Extent
The “extent” of the Curves will be computed and authored based on the
pointsandwidthsprovided.The following common primvars can optionally be authored at the same time using a
PrimvarDatato specify interpolation, data, and optionally indices or elementSize.Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widthsandprimvars:normals, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the curves.
path The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- wrap Determines how the start and end points of the curve behave. Accepted values for linear curves are
UsdGeom.Tokens.nonperiodicandUsdGeom.Tokens.periodic.
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurvesschema wrapping the definedUsd.Prim
defineLinearBasisCurves(prim: pxr.Usd.Prim, name: str, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Linear
UsdGeom.BasisCurvesprim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim The stage on which to define the curves.
name The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- wrap Determines how the start and end points of the curve behave. Accepted values for linear curves are
UsdGeom.Tokens.nonperiodicandUsdGeom.Tokens.periodic.
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurvesschema wrapping the definedUsd.Prim
- usdex.core.defineCubicBasisCurves(*args, **kwargs)#
Overloaded function.
defineCubicBasisCurves(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, basis: str = ‘bezier’, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Cubic
UsdGeom.BasisCurvesprim on the stage.Attribute values will be validated and in the case of invalid data the Curves will not be defined. An invalid
UsdGeom.BasisCurvesobject will be returned in this case.Values will be authored for all attributes required to completely describe the Curves, even if weaker matching opinions already exist.
Curve Vertex Counts
Points
Type
Basis
Wrap
Extent
The “extent” of the Curves will be computed and authored based on the
pointsandwidthsprovided.The following common primvars can optionally be authored at the same time using a
PrimvarDatato specify interpolation, data, and optionally indices or elementSize.Widths
Normals
Display Color
Display Opacity
For both widths and normals, if they are provided, they are authored as
primvars:widthsandprimvars:normals, so that indexing is possible and to ensure that the value takes precedence in cases where both the non-primvar and primvar attributes are authored.- Parameters:
stage The stage on which to define the curves.
path The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- basis The basis specifies the vstep and matrix used for cubic interpolation. Accepted values for cubic curves are
UsdGeom.Tokens.bezier,UsdGeom.Tokens.bspline, orUsdGeom.Tokens.catmullRom.
- wrap Determines how the start and end points of the curve behave. Accepted values are
UsdGeom.Tokens.nonperiodic, UsdGeom.Tokens.periodic, andUsdGeom.Tokens.pinned(bspline and catmullRom only).
- wrap Determines how the start and end points of the curve behave. Accepted values are
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurvesschema wrapping the definedUsd.Prim
defineCubicBasisCurves(prim: pxr.Usd.Prim, name: str, curveVertexCounts: pxr.Vt.IntArray, points: pxr.Vt.Vec3fArray, basis: str = ‘bezier’, wrap: str = ‘nonperiodic’, widths: Optional[usdex.core._usdex_core.FloatPrimvarData] = None, normals: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayColor: Optional[usdex.core._usdex_core.Vec3fPrimvarData] = None, displayOpacity: Optional[usdex.core._usdex_core.FloatPrimvarData] = None) -> pxr.UsdGeom.BasisCurves
Defines a batched Cubic
UsdGeom.BasisCurvesprim on the stage.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
prim The stage on which to define the curves.
name The absolute prim path at which to define the curves.
curveVertexCounts The number of vertices in each independent curve. The length of this array determines the number of curves.
points Vertex/CV positions for the curves described in local space.
- basis The basis specifies the vstep and matrix used for cubic interpolation. Accepted values for cubic curves are
UsdGeom.Tokens.bezier,UsdGeom.Tokens.bspline, orUsdGeom.Tokens.catmullRom.
- wrap Determines how the start and end points of the curve behave. Accepted values are
UsdGeom.Tokens.nonperiodic, UsdGeom.Tokens.periodic, andUsdGeom.Tokens.pinned(bspline and catmullRom only).
- wrap Determines how the start and end points of the curve behave. Accepted values are
widths Values for the width specification for the curves.
normals Values for the normals primvar for the curves. If authored, the curves are considered oriented ribbons rather than tubes.
displayColor Values to be authored for the display color primvar.
displayOpacity Values to be authored for the display opacity primvar.
- Returns
UsdGeom.BasisCurvesschema wrapping the definedUsd.Prim
- usdex.core.defineCamera(*args, **kwargs)#
Overloaded function.
defineCamera(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, cameraData: pxr.Gf.Camera) -> pxr.UsdGeom.Camera
Defines a basic 3d camera on the stage.
Note that
Gf.Camerais a simplified form of 3d camera data that does not account for time-sampled data, shutter window, stereo role, or exposure. If you need to author those properties, do so after defining theUsdGeom.Camera.An invalid UsdGeomCamera will be returned if camera attributes could not be authored successfully.
- Parameters:
stage - The stage on which to define the camera
path - The absolute prim path at which to define the camera
cameraData - The camera data to set, including the world space transform matrix
- Returns:
A
UsdGeom.Cameraschema wrapping the definedUsd.Prim.
defineCamera(parent: pxr.Usd.Prim, name: str, cameraData: pxr.Gf.Camera) -> pxr.UsdGeom.Camera
Defines a basic 3d camera on the stage.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the camera
name - Name of the camera
cameraData - The camera data to set, including the world space transform matrix
- Returns:
A
UsdGeom.Cameraschema wrapping the definedUsd.Prim.
- class usdex.core.FloatPrimvarData#
PrimvarDatathat holdsVt.FloatArrayvalues (e.g widths or scale factors).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.FloatPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.FloatArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.IntPrimvarData#
PrimvarDatathat holdsVt.IntArrayvalues (e.g simple switch values or booleans consumable by shaders).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.IntPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.IntArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Int64PrimvarData#
PrimvarDatathat holdsVt.Int64Arrayvalues (e.g ids that might be very large).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Int64PrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Int64Array#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Vec3fPrimvarData#
PrimvarDatathat holdsVt.Vec3fArrayvalues (e.g normals, colors, or other vectors).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Vec3fPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Vec3fArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.Vec2fPrimvarData#
PrimvarDatathat holdsVt.Vec2fArrayvalues (e.g texture coordinates).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.Vec2fPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.Vec2fArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.StringPrimvarData#
PrimvarDatathat holdsVt.StringArrayvalues (e.g human readable descriptors).This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.StringPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.StringArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- class usdex.core.TokenPrimvarData#
PrimvarDatathat holdsVt.TokenArrayvalues (e.g more efficient human readable descriptors).This is a more efficient format than raw strings if you have many repeated values across different prims.
Note
TfTokenlifetime lasts the entire process. Too many tokens in memory may consume resources somewhat unexpectedly.This is a read-only class to manage all
UsdGeom.Primvardata as a single object without risk of detaching (copying) arrays.UsdGeom.Primvarsare often used when authoringUsdGeom.PointBasedprims (e.g meshes, curves, and point clouds) to describe surface varying properties that can affect how a prim is rendered, or to drive a surface deformation.However,
UsdGeom.Primvardata can be quite intricate to use, especially with respect to indexed vs non-indexed primvars, element size, the complexities ofVt.Arraydetach (copy-on-write) semantics, and the ambiguity of “native” attributes vs primvar attributes (e.g. mesh normals).This class aims to provide simpler entry points to avoid common mistakes with respect to
UsdGeom.Primvardata handling.All of the USD authoring “define” functions in this library accept optional
PrimvarDatato define e.g normals, display colors, etc.Methods:
effectiveSize(self)The effective size of the data, having accounted for values, indices, and element size.
elementSize(self)The element size.
getPrimvarData(primvar[, time])Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.hasIndices(self)Whether this is indexed or non-indexed
PrimvarDataindex(self)Update the values and indices of this
PrimvarDataobject to avoid duplicate values.indices(self)Access to the indices array.
interpolation(self)The geometric interpolation.
isIdentical(self, other)Check that all data between two
PrimvarDataobjects is identical.isValid(self)Whether the data is valid or invalid.
setPrimvar(self, primvar[, time])Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.values(self)Access to the values array.
- effectiveSize( ) int#
The effective size of the data, having accounted for values, indices, and element size.
This is the number of variable values that “really” exist, as far as a consumer is concerned. The indices & elementSize are used as a storage optimization, but the consumer should consider the effective size as the number of “deduplicated” individual values.
- Returns:
The effective size of the data.
- elementSize( ) int#
The element size.
Any value less than 1 is considered “non authored” and indicates no element size. This should be the most common case, as element size is a fairly esoteric extension of
UsdGeom.Primvardata to account for non-typed array strides such as spherical harmonics float[9] arrays.See
UsdGeom.Primvar.GetElementSize()for more details.- Returns:
The primvar element size.
- static getPrimvarData(
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Construct a
PrimvarDatafrom aUsdGeom.Primvarthat has already been authored.The primvar may be indexed, non-indexed, with or without elements, or it may not even be validly authored scene description. Use
isValid()to confirm that valid data has been gathered.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are read.
- Returns:
The read-only
PrimvarData.
- hasIndices( ) bool#
Whether this is indexed or non-indexed
PrimvarData- Returns:
Whether this is indexed or non-indexed
PrimvarData.
- index( ) bool#
Update the values and indices of this
PrimvarDataobject to avoid duplicate values.- Updates will not be made in the following conditions:
If element size is greater than one.
If the existing indexing is efficient.
If there are no duplicate values.
If the existing indices are invalid
- Returns:
True if the values and/or indices were modified.
- indices( ) pxr.Vt.IntArray#
Access to the indices array.
This method throws a runtime error if the
PrimvarDatais not indexed. For exception-free access, checkhasIndices()before calling this.Note
It may contain an empty or invalid indices array. Use
PrimvarData.isValid()to validate that the indices are not out-of-range.- Returns:
The primvar indices
- interpolation( ) str#
The geometric interpolation.
It may be an invalid interpolation. Use
PrimvarData.isValid()orUsdGeom.Primvar.IsValidInterpolation()to confirm.- Returns:
The geometric interpolation.
- isIdentical( ) bool#
Check that all data between two
PrimvarDataobjects is identical.This differs from the equality operator in that it ensures the
Vt.Arrayvalues and indices have not detached.- Parameters:
other – The other
PrimvarData.- Returns:
True if all the member data is equal and arrays are identical.
- isValid( ) bool#
Whether the data is valid or invalid.
This is a validation check with respect to the
PrimvarDataitself & the requirements ofUsdGeom.Prim. It does not validate with respect to specific surface topology data, as no such data is available or consistant acrossUsdGeom.PointBasedprim types.This validation checks the following, in this order, and returns false if any condition fails:
The interpolation matches
UsdGeom.Primvar.IsValidInterpolation().The values are not empty. Note that individual values may be invalid (e.g
NaNvalues on aVt.FloatArray) but this will not be considered a failure, as some workflows allow forNaNto indicate non-authored elements or “holes” within the data.If it is non-indexed, and has elements, that the values divide evenly by elementSize.
If it is indexed, and has elements, that the indices divide evenly by elementSize.
If it is indexed, that the indices are all within the expected range of the values array.
- Returns:
Whether the data is valid or invalid.
- setPrimvar(
- self: usdex.core._usdex_core.TokenPrimvarData,
- primvar: pxr.UsdGeom.Primvar,
- time: pxr.Usd.TimeCode = nan,
Set data on an existing
UsdGeom.Primvarfrom aPrimvarDatathat has already been authored.Any existing authored data on the primvar will be overwritten or blocked with the
PrimvarDatamembers.To copy data from one
UsdGeom.Primvarto another, usedata: PrimvarData = PrimvarData.get(primvar: UsdGeom.Primvar)to gather the data, then usesetPrimvar(primvar: UsdGeom.Primvar)to author it.- Parameters:
primvar – The previously authored
UsdGeom.Primvar.time – The time at which the attribute values are written.
- Returns:
Whether the
UsdGeom.Primvarwas completely authored from the member data. Any failure to author may leave the primvar in an unknown state (e.g. it may have been partially authored).
- values( ) pxr.Vt.TokenArray#
Access to the values array.
Bear in mind the values may need to be accessed via
indices()or using anelementSize()stride.It may contain an empty or invalid values array.
- Returns:
The primvar values.
- usdex.core.isLight(prim: pxr.Usd.Prim) bool#
Determines if a UsdPrim has a
UsdLux.LightAPIschema applied- Parameters:
prim – The prim to check for an applied
UsdLux.LightAPIschema- Returns:
True if the prim has a
UsdLux.LightAPIschema applied
- usdex.core.getLightAttr(defaultAttr: pxr.Usd.Attribute) pxr.Usd.Attribute#
Get the “correct” light attribute for a light that could have any combination of authored old and new UsdLux schema attributes
The new attribute names have “inputs:” prepended to the names to make them connectable.
Light has only “intensity” authored: return “intensity” attribute
Light has only “inputs:intensity” authored: return “inputs:intensity” attribute
Light has both “inputs:intensity” and “intensity” authored: return “inputs:intensity”
- Parameters:
defaultAttr – The attribute to read from the light schema: eg.
UsdLux.RectLight.GetHeightAttr()- Returns:
The attribute from which the light value should be read
- usdex.core.defineDomeLight(*args, **kwargs)#
Overloaded function.
defineDomeLight(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, intensity: float = 1.0, texturePath: Optional[str] = None, textureFormat: str = ‘automatic’) -> pxr.UsdLux.DomeLight
Creates a dome light with an optional texture.
A dome light represents light emitted inward from a distant external environment, such as a sky or IBL light probe.
Texture Format values:
automatic- Tries to determine the layout from the file itself.latlong- Latitude as X, longitude as Y.mirroredBall- An image of the environment reflected in a sphere, using an implicitly orthogonal projection.angular- Similar to mirroredBall but the radial dimension is mapped linearly to the angle, for better sampling at the edges.cubeMapVerticalCross- Set to “automatic” by default.
Note:
The DomeLight schema requires the dome’s top pole to be aligned with the world’s +Y axis. In USD 23.11 a new UsdLuxDomeLight_1 schema was added which gives control over the pole axis. However, it is not widely supported yet, so we still prefer to author the original DomeLight schema and expect consuming application and renderers to account for the +Y pole axis.
- Parameters:
stage - The stage in which the light should be authored
path - The path which the light prim should be written to
intensity - The intensity value of the dome light
texturePath - The path to the texture file to use on the dome light.
textureFormat - How the texture should be mapped on the dome light.
- Returns:
The dome light if created successfully.
defineDomeLight(parent: pxr.Usd.Prim, name: str, intensity: float = 1.0, texturePath: Optional[str] = None, textureFormat: str = ‘automatic’) -> pxr.UsdLux.DomeLight
Creates a dome light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the light
name - Name of the light
intensity - The intensity value of the dome light
texturePath - The path to the texture file to use on the dome light.
textureFormat - How the texture should be mapped on the dome light.
- Returns:
The dome light if created successfully.
- usdex.core.defineRectLight(*args, **kwargs)#
Overloaded function.
defineRectLight(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, width: float, height: float, intensity: float = 1.0, texturePath: Optional[str] = None) -> pxr.UsdLux.RectLight
Creates a rectangular (rect) light with an optional texture.
A rect light represents light emitted from one side of a rectangle.
- Parameters:
stage - The stage in which the light should be authored
path - The path which the light prim should be written to
width - The width of the rectangular light, in the local X axis.
height - The height of the rectangular light, in the local Y axis.
intensity - The intensity value of the rectangular light
texturePath - Optional - The path to the texture file to use on the rectangular light.
- Returns:
The rect light if created successfully.
defineRectLight(parent: pxr.Usd.Prim, name: str, width: float, height: float, intensity: float = 1.0, texturePath: Optional[str] = None) -> pxr.UsdLux.RectLight
Creates a rectangular (rect) light with an optional texture.
This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the light
name - Name of the light
width - The width of the rectangular light, in the local X axis.
height - The height of the rectangular light, in the local Y axis.
intensity - The intensity value of the rectangular light
texturePath - Optional - The path to the texture file to use on the rectangular light.
- Returns:
The rect light if created successfully.
- usdex.core.createMaterial(
- parent: pxr.Usd.Prim,
- name: str,
Create a
UsdShade.Materialas the child of the Prim parent- Parameters:
parent – Parent prim of the material
name – Name of the material to be created
- Returns:
The newly created
UsdShade.Material. Returns an invalid material object on error.
- usdex.core.bindMaterial(
- prim: pxr.Usd.Prim,
- material: pxr.UsdShade.Material,
Authors a direct binding to the given material on this prim.
Validates both the prim and the material, applies the
UsdShade.MaterialBindingAPIto the target prim, and binds the material to the target prim.Note
The material is bound with the default “all purpose” used for both full and preview rendering, and with the default “fallback strength” meaning descendant prims can override with a different material. If alternate behavior is desired, use the
UsdShade.MaterialBindingAPIdirectly.- Parameters:
prim – The prim that the material will affect
material – The material to bind to the prim
- Returns:
Whether the material was successfully bound to the target prim.
- usdex.core.computeEffectivePreviewSurfaceShader(
- material: pxr.UsdShade.Material,
Get the effective surface Shader of a Material for the universal render context.
- Parameters:
material – The Material to consider
- Returns:
The connected Shader. Returns an invalid shader object on error.
- usdex.core.definePreviewMaterial(*args, **kwargs)#
Overloaded function.
definePreviewMaterial(stage: pxr.Usd.Stage, path: pxr.Sdf.Path, color: pxr.Gf.Vec3f, opacity: float = 1.0, roughness: float = 0.5, metallic: float = 0.0) -> pxr.UsdShade.Material
Defines a PBR
UsdShade.Materialdriven by aUsdPreviewSurfaceshader network for the universal render context.The input parameters reflect a subset of the UsdPreviewSurface specification commonly used when authoring materials using the metallic/metalness workflow (as opposed to the specular workflow). Many other inputs are available and can be authored after calling this function (including switching to the specular workflow).
- Parameters:
stage - The stage on which to define the Material
path - The absolute prim path at which to define the Material
color - The diffuse color of the Material
opacity - The Opacity Amount to set, 0.0-1.0 range where 1.0 = opaque and 0.0 = invisible
roughness - The Roughness Amount to set, 0.0-1.0 range where 1.0 = flat and 0.0 = glossy
metallic - The Metallic Amount to set, 0.0-1.0 range where 1.0 = max metallic and 0.0 = no metallic
- Returns:
The newly defined
UsdShade.Material. Returns an Invalid prim on error
definePreviewMaterial(parent: pxr.Usd.Prim, name: str, color: pxr.Gf.Vec3f, opacity: float = 1.0, roughness: float = 0.5, metallic: float = 0.0) -> pxr.UsdShade.Material
Defines a PBR
UsdShade.Materialdriven by aUsdPreviewSurfaceshader network for the universal render context.This is an overloaded member function, provided for convenience. It differs from the above function only in what arguments it accepts.
- Parameters:
parent - Prim below which to define the Material
name - Name of the Material
color - The diffuse color of the Material
opacity - The Opacity Amount to set, 0.0-1.0 range where 1.0 = opaque and 0.0 = invisible
roughness - The Roughness Amount to set, 0.0-1.0 range where 1.0 = flat and 0.0 = glossy
metallic - The Metallic Amount to set, 0.0-1.0 range where 1.0 = max metallic and 0.0 = no metallic
- Returns:
The newly defined
UsdShade.Material. Returns an Invalid prim on error
- usdex.core.addDiffuseTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a diffuse texture to a preview material
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addNormalTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a normals texture to a preview material
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).The UsdPreviewSurface specification requires the texture reader to provide data that is properly scaled and ready to be consumed as a tangent space normal. Textures stored in 8-bit file formats require scale and bias adjustment to transform the normals into tangent space.
This module cannot read the provided
texturePathto inspect the channel data (the file may not resolve locally, or even exist yet). To account for this, it performs the scale and bias adjustment when the texturePath extension matches a list of known 8-bit formats:["bmp", "tga", "jpg", "jpeg", "png", "tif"]. Similarly, it assumes that the raw normals data was written into the file, regardless of any file format specific color space metadata. If either of these assumptions is incorrect for your source data, you will need to adjust thescale,bias, andsourceColorSpacesettings after calling this function.- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addOrmTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds an ORM (occlusion, roughness, metallic) texture to a preview material
An ORM texture is a normal 3-channel image asset, where the R channel represents occlusion, the G channel represents roughness, and the B channel represents metallic/metallness.
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addRoughnessTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel roughness texture to a preview material
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addMetallicTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel metallic texture to a preview material
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addOpacityTextureToPreviewMaterial(
- material: pxr.UsdShade.Material,
- texturePath: pxr.Sdf.AssetPath,
Adds a single channel opacity texture to a preview material
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).- Parameters:
material – The material prim
texturePath – The
Sdf.AssetPathfor the texture
- Returns:
Whether or not the texture was added to the material
- usdex.core.addPreviewMaterialInterface(material: pxr.UsdShade.Material) bool#
Adds
UsdShade.Inputsto the material prim to create an “interface” to the underlying Preview Shader network.All non-default-value
UsdShade.Inputson the effective surface shader for the universal render context will be “promoted” to theUsdShade.Materialas newUsdShade.Inputs. They will be connected to the original source inputs on the shaders, to drive those values, and they will be authored with a value matching what had been set on the shader inputs at the time this function was called.Additionally,
UsdUVTexture.fileinputs on connected shaders will be promoted to the material, following the same logic as direct surface inputs.Note
It is preferable to author all initial shader attributes (including textures) before calling
addPreviewMaterialInterface().Warning
This function will fail if there is any other render context driving the material surface. It is only suitable for use on Preview Shader networks, such as the network generated by
definePreviewMaterial()and its associatedadd*Texturefunctions. If you require multiple contexts, you should instead construct a Material Interface directly, or with targetted end-user interaction.- Parameters:
material – The material prim
- Returns:
Whether or not the Material inputs were added successfully
- usdex.core.removeMaterialInterface(
- material: pxr.UsdShade.Material,
- bakeValues: bool = True,
Removes any
UsdShade.Inputsfound on the material prim.All
UsdShade.Inputson theUsdShade.Materialwill be disconnected from any underlying shader inputs, then removed from the material. The current values may be optionally “baked down” onto the shader inputs in order to retain the current material behavior, or may be discarded in order to revert to a default appearance based on the shader definitions.Note
While
addPreviewMaterialInterfaceis specific to Preview Material shader networks,removeMaterialInterfaceaffects all render contexts and will remove allUsdShade.Inputsreturned viaUsdShade.Material.GetInterfaceInputs(), baking down the values onto all consumer shaders, regardless of render context.- Parameters:
material – The material prim
bakeValues – Whether or not the current Material inputs values are set on the underlying Shader inputs
- Returns:
Whether or not the Material inputs were removed successfully
- class usdex.core.ColorSpace#
Texture color space (encoding) types
Members:
eAuto : Check for gamma or metadata in the texture itself
eRaw : Use linear sampling (typically used for Normal, Roughness, Metallic, Opacity textures, or when using high dynamic range file formats like EXR)
eSrgb : Use sRGB sampling (typically used for Diffuse textures when using PNG files)
Attributes:
- property name#
- usdex.core.getColorSpaceToken(value: usdex.core._usdex_core.ColorSpace) str#
Get the str matching a given ColorSpace
The string representation is typically used when setting shader inputs, such as
inputs:sourceColorSpaceonUsdUVTexture.- Parameters:
value – The
ColorSpace- Returns:
The str for the given
ColorSpacevalue
- usdex.core.sRgbToLinear(color: pxr.Gf.Vec3f) pxr.Gf.Vec3f#
Translate an sRGB color value to linear color space
Many 3D modeling applications define colors in sRGB (0-1) color space. Many others use a linear color space that aligns with how light and color behave in the natural world. When authoring
UsdShade.Shadercolor input data, including external texture assets, you may need to translate between color spaces.Note
Color is a complex topic in 3D rendering and providing utilities covering the full breadth of color science is beyond the scope of this module. See this [MathWorks article](https://www.mathworks.com/help/images/understanding-color-spaces-and-color-space-conversion.html) for a relatively brief introduction. If you need more specific color handling please use a dedicated color science library like [OpenColorIO](https://opencolorio.org).
- Parameters:
color – sRGB representation of a color to be translated to linear color space
- Returns:
The translated color in linear color space
- usdex.core.linearToSrgb(color: pxr.Gf.Vec3f) pxr.Gf.Vec3f#
Translate a linear color value to sRGB color space
Many 3D modeling applications define colors in sRGB (0-1) color space. Many others use a linear color space that aligns with how light and color behave in the natural world. When authoring
UsdShade.Shadercolor input data, including external texture assets, you may need to translate between color spaces.Note
Color is a complex topic in 3D rendering and providing utilities covering the full breadth of color science is beyond the scope of this module. See this [MathWorks article](https://www.mathworks.com/help/images/understanding-color-spaces-and-color-space-conversion.html) for a relatively brief introduction. If you need more specific color handling please use a dedicated color science library like [OpenColorIO](https://opencolorio.org).
- Parameters:
color – linear representation of a color to be translated to sRGB color space
- Returns:
The translated color in sRGB color space