UsdVol module

Summary: The UsdVol module provides schemas for representing volumes (smoke, fire, etc).


Classes:

Field3DAsset

Field3D field primitive.

FieldAsset

Base class for field primitives defined by an external file.

FieldBase

Base class for field primitives.

OpenVDBAsset

OpenVDB field primitive.

Tokens

Volume

A renderable volume primitive.

class pxr.UsdVol.Field3DAsset

Field3D field primitive. The FieldAsset filePath attribute must specify a file in the Field3D format on disk.

For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdVolTokens. So to set an attribute to the value”rightHanded”, use UsdVolTokens->rightHanded as the value.

Methods:

CreateFieldDataTypeAttr(defaultValue, ...)

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateFieldPurposeAttr(defaultValue, ...)

See GetFieldPurposeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

Define

classmethod Define(stage, path) -> Field3DAsset

Get

classmethod Get(stage, path) -> Field3DAsset

GetFieldDataTypeAttr()

Token which is used to indicate the data type of an individual field.

GetFieldPurposeAttr()

Optional token which can be used to indicate the purpose or grouping of an individual field.

GetSchemaAttributeNames

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

CreateFieldDataTypeAttr(defaultValue, writeSparsely) Attribute

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateFieldPurposeAttr(defaultValue, writeSparsely) Attribute

See GetFieldPurposeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

static Define()

classmethod Define(stage, path) -> Field3DAsset

Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefined() ) on this stage.

If a prim adhering to this schema at path is already defined on this stage, return that prim. Otherwise author an SdfPrimSpec with specifier == SdfSpecifierDef and this schema’s prim type name for the prim at path at the current EditTarget. Author SdfPrimSpec s with specifier == SdfSpecifierDef and empty typeName at the current EditTarget for any nonexistent, or existing but not Defined ancestors.

The given path must be an absolute prim path that does not contain any variant selections.

If it is impossible to author any of the necessary PrimSpecs, (for example, in case path cannot map to the current UsdEditTarget ‘s namespace) issue an error and return an invalid UsdPrim.

Note that this method may return a defined prim whose typeName does not specify this schema class, in case a stronger typeName opinion overrides the opinion at the current EditTarget.

Parameters
static Get()

classmethod Get(stage, path) -> Field3DAsset

Return a UsdVolField3DAsset holding the prim adhering to this schema at path on stage .

If no prim exists at path on stage , or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdVolField3DAsset(stage->GetPrimAtPath(path));
Parameters
GetFieldDataTypeAttr() Attribute

Token which is used to indicate the data type of an individual field.

Authors use this to tell consumers more about the field without opening the file on disk. The list of allowed tokens reflects the available choices for Field3d volumes.

Declaration

token fieldDataType

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

Allowed Values

half, float, double, half3, float3, double3

GetFieldPurposeAttr() Attribute

Optional token which can be used to indicate the purpose or grouping of an individual field.

Clients which consume Field3D files should treat this as the Field3D field name.

Declaration

token fieldPurpose

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

static GetSchemaAttributeNames()

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Parameters

includeInherited (bool) –

class pxr.UsdVol.FieldAsset

Base class for field primitives defined by an external file.

For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdVolTokens. So to set an attribute to the value”rightHanded”, use UsdVolTokens->rightHanded as the value.

Methods:

CreateFieldDataTypeAttr(defaultValue, ...)

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateFieldIndexAttr(defaultValue, writeSparsely)

See GetFieldIndexAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateFieldNameAttr(defaultValue, writeSparsely)

See GetFieldNameAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateFilePathAttr(defaultValue, writeSparsely)

See GetFilePathAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateVectorDataRoleHintAttr(defaultValue, ...)

See GetVectorDataRoleHintAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

Get

classmethod Get(stage, path) -> FieldAsset

GetFieldDataTypeAttr()

Token which is used to indicate the data type of an individual field.

GetFieldIndexAttr()

A file can contain multiple fields with the same name.

GetFieldNameAttr()

Name of an individual field within the file specified by the filePath attribute.

GetFilePathAttr()

An asset path attribute that points to a file on disk.

GetSchemaAttributeNames

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

GetVectorDataRoleHintAttr()

Optional token which is used to indicate the role of a vector valued field.

CreateFieldDataTypeAttr(defaultValue, writeSparsely) Attribute

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateFieldIndexAttr(defaultValue, writeSparsely) Attribute

See GetFieldIndexAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateFieldNameAttr(defaultValue, writeSparsely) Attribute

See GetFieldNameAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateFilePathAttr(defaultValue, writeSparsely) Attribute

See GetFilePathAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateVectorDataRoleHintAttr(defaultValue, writeSparsely) Attribute

See GetVectorDataRoleHintAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

static Get()

classmethod Get(stage, path) -> FieldAsset

Return a UsdVolFieldAsset holding the prim adhering to this schema at path on stage .

If no prim exists at path on stage , or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdVolFieldAsset(stage->GetPrimAtPath(path));
Parameters
GetFieldDataTypeAttr() Attribute

Token which is used to indicate the data type of an individual field.

Authors use this to tell consumers more about the field without opening the file on disk. The list of allowed tokens is specified with the specific asset type. A missing value is considered an error.

Declaration

token fieldDataType

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

GetFieldIndexAttr() Attribute

A file can contain multiple fields with the same name.

This optional attribute is an index used to disambiguate between these multiple fields with the same name.

Declaration

int fieldIndex

C++ Type

int

Usd Type

SdfValueTypeNames->Int

GetFieldNameAttr() Attribute

Name of an individual field within the file specified by the filePath attribute.

Declaration

token fieldName

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

GetFilePathAttr() Attribute

An asset path attribute that points to a file on disk.

For each supported file format, a separate FieldAsset subclass is required.

This attribute’s value can be animated over time, as most volume asset formats represent just a single timeSample of a volume. However, it does not, at this time, support any pattern substitutions like”$F”.

Declaration

asset filePath

C++ Type

SdfAssetPath

Usd Type

SdfValueTypeNames->Asset

static GetSchemaAttributeNames()

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Parameters

includeInherited (bool) –

GetVectorDataRoleHintAttr() Attribute

Optional token which is used to indicate the role of a vector valued field.

This can drive the data type in which fields are made available in a renderer or whether the vector values are to be transformed.

Declaration

token vectorDataRoleHint ="None"

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

Allowed Values

None, Point, Normal, Vector, Color

class pxr.UsdVol.FieldBase

Base class for field primitives.

Methods:

Get

classmethod Get(stage, path) -> FieldBase

GetSchemaAttributeNames

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

static Get()

classmethod Get(stage, path) -> FieldBase

Return a UsdVolFieldBase holding the prim adhering to this schema at path on stage .

If no prim exists at path on stage , or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdVolFieldBase(stage->GetPrimAtPath(path));
Parameters
static GetSchemaAttributeNames()

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Parameters

includeInherited (bool) –

class pxr.UsdVol.OpenVDBAsset

OpenVDB field primitive. The FieldAsset filePath attribute must specify a file in the OpenVDB format on disk.

For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdVolTokens. So to set an attribute to the value”rightHanded”, use UsdVolTokens->rightHanded as the value.

Methods:

CreateFieldClassAttr(defaultValue, writeSparsely)

See GetFieldClassAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

CreateFieldDataTypeAttr(defaultValue, ...)

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

Define

classmethod Define(stage, path) -> OpenVDBAsset

Get

classmethod Get(stage, path) -> OpenVDBAsset

GetFieldClassAttr()

Optional token which can be used to indicate the class of an individual grid.

GetFieldDataTypeAttr()

Token which is used to indicate the data type of an individual field.

GetSchemaAttributeNames

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

CreateFieldClassAttr(defaultValue, writeSparsely) Attribute

See GetFieldClassAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

CreateFieldDataTypeAttr(defaultValue, writeSparsely) Attribute

See GetFieldDataTypeAttr() , and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute’s default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false .

Parameters
  • defaultValue (VtValue) –

  • writeSparsely (bool) –

static Define()

classmethod Define(stage, path) -> OpenVDBAsset

Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefined() ) on this stage.

If a prim adhering to this schema at path is already defined on this stage, return that prim. Otherwise author an SdfPrimSpec with specifier == SdfSpecifierDef and this schema’s prim type name for the prim at path at the current EditTarget. Author SdfPrimSpec s with specifier == SdfSpecifierDef and empty typeName at the current EditTarget for any nonexistent, or existing but not Defined ancestors.

The given path must be an absolute prim path that does not contain any variant selections.

If it is impossible to author any of the necessary PrimSpecs, (for example, in case path cannot map to the current UsdEditTarget ‘s namespace) issue an error and return an invalid UsdPrim.

Note that this method may return a defined prim whose typeName does not specify this schema class, in case a stronger typeName opinion overrides the opinion at the current EditTarget.

Parameters
static Get()

classmethod Get(stage, path) -> OpenVDBAsset

Return a UsdVolOpenVDBAsset holding the prim adhering to this schema at path on stage .

If no prim exists at path on stage , or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdVolOpenVDBAsset(stage->GetPrimAtPath(path));
Parameters
GetFieldClassAttr() Attribute

Optional token which can be used to indicate the class of an individual grid.

This is a mapping to openvdb::GridClass where the values are GRID_LEVEL_SET, GRID_FOG_VOLUME, GRID_STAGGERED, and GRID_UNKNOWN.

Declaration

token fieldClass

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

Allowed Values

levelSet, fogVolume, staggered, unknown

GetFieldDataTypeAttr() Attribute

Token which is used to indicate the data type of an individual field.

Authors use this to tell consumers more about the field without opening the file on disk. The list of allowed tokens reflects the available choices for OpenVDB volumes.

Declaration

token fieldDataType

C++ Type

TfToken

Usd Type

SdfValueTypeNames->Token

Allowed Values

half, float, double, int, uint, int64, half2, float2, double2, int2, half3, float3, double3, int3, matrix3d, matrix4d, quatd, bool, mask, string

static GetSchemaAttributeNames()

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Parameters

includeInherited (bool) –

class pxr.UsdVol.Tokens

Attributes:

bool_

color

double2

double3

double_

field

fieldClass

fieldDataType

fieldIndex

fieldName

fieldPurpose

filePath

float2

float3

float_

fogVolume

half

half2

half3

int2

int3

int64

int_

levelSet

mask

matrix3d

matrix4d

none_

normal

point

quatd

staggered

string

uint

unknown

vector

vectorDataRoleHint

bool_ = 'bool'
color = 'Color'
double2 = 'double2'
double3 = 'double3'
double_ = 'double'
field = 'field'
fieldClass = 'fieldClass'
fieldDataType = 'fieldDataType'
fieldIndex = 'fieldIndex'
fieldName = 'fieldName'
fieldPurpose = 'fieldPurpose'
filePath = 'filePath'
float2 = 'float2'
float3 = 'float3'
float_ = 'float'
fogVolume = 'fogVolume'
half = 'half'
half2 = 'half2'
half3 = 'half3'
int2 = 'int2'
int3 = 'int3'
int64 = 'int64'
int_ = 'int'
levelSet = 'levelSet'
mask = 'mask'
matrix3d = 'matrix3d'
matrix4d = 'matrix4d'
none_ = 'None'
normal = 'Normal'
point = 'Point'
quatd = 'quatd'
staggered = 'staggered'
string = 'string'
uint = 'uint'
unknown = 'unknown'
vector = 'Vector'
vectorDataRoleHint = 'vectorDataRoleHint'
class pxr.UsdVol.Volume

A renderable volume primitive. A volume is made up of any number of FieldBase primitives bound together in this volume. Each FieldBase primitive is specified as a relationship with a namespace prefix of”field”.

The relationship name is used by the renderer to associate individual fields with the named input parameters on the volume shader. Using this indirect approach to connecting fields to shader parameters (rather than using the field prim’s name) allows a single field to be reused for different shader inputs, or to be used as different shader parameters when rendering different Volumes. This means that the name of the field prim is not relevant to its contribution to the volume prims which refer to it. Nor does the field prim’s location in the scene graph have any relevance, and Volumes may refer to fields anywhere in the scene graph. However, unless Field prims need to be shared by multiple Volumes, a Volume’s Field prims should be located under the Volume in namespace, for enhanced organization.

Methods:

BlockFieldRelationship(name)

Blocks an existing field relationship on this volume, ensuring it will not be enumerated by GetFieldPaths() .

CreateFieldRelationship(name, fieldPath)

Creates a relationship on this volume that targets the specified field.

Define

classmethod Define(stage, path) -> Volume

Get

classmethod Get(stage, path) -> Volume

GetFieldPath(name)

Checks if there is an existing field relationship with a given name, and if so, returns the path to the Field prim it targets, or else the empty path.

GetFieldPaths()

Return a map of field relationship names to the fields themselves, represented as prim paths.

GetSchemaAttributeNames

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

HasFieldRelationship(name)

Checks if there is an existing field relationship with a given name.

BlockFieldRelationship(name) bool

Blocks an existing field relationship on this volume, ensuring it will not be enumerated by GetFieldPaths() .

Returns true if the relationship existed, false if it did not. In other words the return value indicates whether the volume prim was changed.

The name lookup automatically applies the field relationship namespacing, if it isn’t specified in the name token.

Parameters

name (str) –

CreateFieldRelationship(name, fieldPath) bool

Creates a relationship on this volume that targets the specified field.

If an existing relationship exists with the same name, it is replaced (since only one target is allowed for each named relationship).

Returns true if the relationship was successfully created and set - it is legal to call this method for a field relationship that already”exists”, i.e. already posesses scene description, as this is the only method we provide for setting a field relatioonship’s value, to help enforce that field relationships can have only a single (or no) target.

fieldPath

- can be a prim path, or the path of another relationship, to effect Relationship Forwarding The name lookup automatically applies the field relationship namespacing, if it isn’t specified in the name token.

Parameters
  • name (str) –

  • fieldPath (Path) –

static Define()

classmethod Define(stage, path) -> Volume

Attempt to ensure a UsdPrim adhering to this schema at path is defined (according to UsdPrim::IsDefined() ) on this stage.

If a prim adhering to this schema at path is already defined on this stage, return that prim. Otherwise author an SdfPrimSpec with specifier == SdfSpecifierDef and this schema’s prim type name for the prim at path at the current EditTarget. Author SdfPrimSpec s with specifier == SdfSpecifierDef and empty typeName at the current EditTarget for any nonexistent, or existing but not Defined ancestors.

The given path must be an absolute prim path that does not contain any variant selections.

If it is impossible to author any of the necessary PrimSpecs, (for example, in case path cannot map to the current UsdEditTarget ‘s namespace) issue an error and return an invalid UsdPrim.

Note that this method may return a defined prim whose typeName does not specify this schema class, in case a stronger typeName opinion overrides the opinion at the current EditTarget.

Parameters
static Get()

classmethod Get(stage, path) -> Volume

Return a UsdVolVolume holding the prim adhering to this schema at path on stage .

If no prim exists at path on stage , or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdVolVolume(stage->GetPrimAtPath(path));
Parameters
GetFieldPath(name) Path

Checks if there is an existing field relationship with a given name, and if so, returns the path to the Field prim it targets, or else the empty path.

The name lookup automatically applies the field relationship namespacing, if it isn’t specified in the name token.

Parameters

name (str) –

GetFieldPaths() FieldMap

Return a map of field relationship names to the fields themselves, represented as prim paths.

This map provides all the information that should be needed to tie fields to shader parameters and render this volume.

The field relationship names that server as the map keys will have the field namespace stripped from them.

static GetSchemaAttributeNames()

classmethod GetSchemaAttributeNames(includeInherited) -> list[TfToken]

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

Parameters

includeInherited (bool) –

HasFieldRelationship(name) bool

Checks if there is an existing field relationship with a given name.

This query will return true even for a field relationship that has been blocked and therefore will not contribute to the map returned by GetFieldRelationships()

The name lookup automatically applies the field relationship namespacing, if it isn’t specified in the name token.

Parameters

name (str) –