3ds Max USD API Reference
Loading...
Searching...
No Matches
MaxUsdPrimWriter Class Reference

Base class for all built-in and user-defined prim writers. Translates 3dsMax nodes to USD prims. More...

#include <PrimWriter.h>

Public Types

enum class  ContextSupport { Unsupported , Supported , Fallback }
 The level of support a writer can offer for a given context. More...
 

Public Member Functions

MaxUSDAPI MaxUsdPrimWriter (const MaxUsdWriteJobContext &jobCtx)
 Constructor. More...
 
virtual MaxUSDAPI ~MaxUsdPrimWriter ()
 Destructor.
 
virtual MaxUSDAPI ContextSupport CanConvert (INode *node)
 Returns the level of support this writer can provide for a given 3dsMax node. More...
 
virtual MaxUSDAPI TfToken GetPrimType (INode *node)
 The prim type you are writing to. For performance reasons, all prims get created ahead of time in a single SdfChangeBlock. This means the prim writers are not responsible for creating the prims. The type specified here is mostly a hint for that first creation pass and, if required, it can be overridden from the Write() method (by defining a prim at the same path with a different type). Unless you always force the creation of an Xform prim (see RequireXformPrim()), you should return an Xformable type here; otherwise, it is not possible to apply the node's transform onto the prim later (an error will be raised in this scenario). More...
 
virtual MaxUSDAPI bool Write (INode *sourceNode, UsdPrim &targetPrim, bool applyOffsetTransform)
 Responsible for writing the prim's attribute for the given context. This is where the translation from the 3dsMax node to the USD prim happens. More...
 
virtual MaxUSDAPI WStr GetWriterName ()
 Returns the name of this prim writer. More...
 
virtual MaxUSDAPI TfToken GetObjectPrimSuffix (INode *)
 In a few scenarios, you need two prims to properly represent an INode. One for its transform, and one for the object it references (for example, in the case of a non-identity object offset transform, it must not inherit the transform, so you cannot use a single prim for the INode). When you do need to perform such a split, the object's prim has the same name as the node's prim, with an added suffix - the string returned here. More...
 
virtual MaxUSDAPI std::string GetPrimName (INode *node, const std::string &suggestedName)
 Returns the name that should be used for the prim. The base implementation should be sufficient in most cases, unless prim writers want to customize the prim's name. If so, it is their responsibility to ensure that the given name is unique amongst siblings. More...
 
virtual MaxUSDAPI maxUsd::XformSplitRequirement RequiresXformPrim (INode *node)
 Returns the requirement to split the object from its transform in the scene. More...
 
virtual MaxUSDAPI bool HandlesObjectOffsetTransform ()
 Whether or not we want to manually handle the object offset transform in the Write(). If we return true here, then the applyOffsetTransform argument of Write() can sometimes be set to true. More...
 
virtual MaxUSDAPI maxUsd::MaterialAssignRequirement RequiresMaterialAssignment (INode *node)
 Returns the material assignment requirement for this node. Some prim writers may not want the prims they produce to be assigned the source node's material automatically. More...
 
virtual MaxUSDAPI maxUsd::InstancingRequirement RequiresInstancing ()
 Returns the instancing requirement for this Prim Writer. Some Prim Writers may want to handle instancing themselves, or disable it entirely. More...
 
MaxUSDAPI const UsdStageRefPtr & GetUsdStage () const
 
MaxUSDAPI const std::string & GetFilename () const
 
virtual MaxUSDAPI boost::python::dict GetNodesToPrims () const
 

Protected Member Functions

MaxUSDAPI const USDSceneBuilderOptionsGetExportArgs () const
 Gets the current global export args in effect.
 
MaxUSDAPI const MaxUsdWriteJobContextGetJobContext () const
 

Detailed Description

Base class for all built-in and user-defined prim writers. Translates 3dsMax nodes to USD prims.

The PrimWriter is only responsible for providing translation of the 3dsMax Object referenced by the received Node. It should therefore not attempt to handle instancing, material assignment, and the transform of the Node itself. Instancing is handled by the calling code - if an object is instanced across multiple nodes, the PrimWriter is only called once, on the first node referencing the instanced object. The required Xform prim hierarchy is already generated. Similarly, the Node's transform is applied by the calling code, on the UsdGeomXformable prim built by the PrimWriter, after it is run. If the USD prim is not a UsdGeomXformable, a warning is raised, but it doesn't prevent the export from continuing.

Member Enumeration Documentation

◆ ContextSupport

The level of support a writer can offer for a given context.

A basic writer that gives correct results across most contexts should report Fallback, while a specialized writer that really shines in a given context should report Supported when the context is right and Unsupported if the context is not as expected.

Constructor & Destructor Documentation

◆ MaxUsdPrimWriter()

MaxUSDAPI MaxUsdPrimWriter::MaxUsdPrimWriter ( const MaxUsdWriteJobContext jobCtx)

Constructor.

Parameters
jobCtxThe write job context (options, target file, stage, etc.)

Member Function Documentation

◆ CanConvert()

virtual MaxUSDAPI ContextSupport MaxUsdPrimWriter::CanConvert ( INode *  node)
inlinevirtual

Returns the level of support this writer can provide for a given 3dsMax node.

Parameters
nodeThe node to check for support.
Returns
The level of support.

◆ GetObjectPrimSuffix()

virtual MaxUSDAPI TfToken MaxUsdPrimWriter::GetObjectPrimSuffix ( INode *  )
inlinevirtual

In a few scenarios, you need two prims to properly represent an INode. One for its transform, and one for the object it references (for example, in the case of a non-identity object offset transform, it must not inherit the transform, so you cannot use a single prim for the INode). When you do need to perform such a split, the object's prim has the same name as the node's prim, with an added suffix - the string returned here.

Returns
A suffix for the object prim.

◆ GetPrimName()

virtual MaxUSDAPI std::string MaxUsdPrimWriter::GetPrimName ( INode *  node,
const std::string &  suggestedName 
)
inlinevirtual

Returns the name that should be used for the prim. The base implementation should be sufficient in most cases, unless prim writers want to customize the prim's name. If so, it is their responsibility to ensure that the given name is unique amongst siblings.

Parameters
nodeThe node to get a prim name for.
suggestedNameA suggested name, from the node's name, and ensured unique amongst siblings.
Returns
The name that should be used (will be part of the prim's path /foo/bar/{Prim name}

◆ GetPrimType()

virtual MaxUSDAPI TfToken MaxUsdPrimWriter::GetPrimType ( INode *  node)
inlinevirtual

The prim type you are writing to. For performance reasons, all prims get created ahead of time in a single SdfChangeBlock. This means the prim writers are not responsible for creating the prims. The type specified here is mostly a hint for that first creation pass and, if required, it can be overridden from the Write() method (by defining a prim at the same path with a different type). Unless you always force the creation of an Xform prim (see RequireXformPrim()), you should return an Xformable type here; otherwise, it is not possible to apply the node's transform onto the prim later (an error will be raised in this scenario).

Parameters
nodeThe 3dsMax node for which to get the target USD prim type.
Returns
The prim's type.

◆ GetWriterName()

virtual MaxUSDAPI WStr MaxUsdPrimWriter::GetWriterName ( )
inlinevirtual

Returns the name of this prim writer.

Returns
The writer's name.

◆ HandlesObjectOffsetTransform()

virtual MaxUSDAPI bool MaxUsdPrimWriter::HandlesObjectOffsetTransform ( )
inlinevirtual

Whether or not we want to manually handle the object offset transform in the Write(). If we return true here, then the applyOffsetTransform argument of Write() can sometimes be set to true.

Returns
True if the prim writer intends to handle the object offset transform, false otherwise.

◆ RequiresInstancing()

virtual MaxUSDAPI maxUsd::InstancingRequirement MaxUsdPrimWriter::RequiresInstancing ( )
inlinevirtual

Returns the instancing requirement for this Prim Writer. Some Prim Writers may want to handle instancing themselves, or disable it entirely.

Returns
The instancing requirement. If default, instancing is handled automatically. Otherwise, it is left to the Prim writer to decide what to do.

◆ RequiresMaterialAssignment()

virtual MaxUSDAPI maxUsd::MaterialAssignRequirement MaxUsdPrimWriter::RequiresMaterialAssignment ( INode *  node)
inlinevirtual

Returns the material assignment requirement for this node. Some prim writers may not want the prims they produce to be assigned the source node's material automatically.

Parameters
nodeThe 3dsMax node
Returns
The material assignment requirement.

◆ RequiresXformPrim()

virtual MaxUSDAPI maxUsd::XformSplitRequirement MaxUsdPrimWriter::RequiresXformPrim ( INode *  node)
inlinevirtual

Returns the requirement to split the object from its transform in the scene.

  • ForOffsetObjects : This should be the case for most objects, this means we require an Xform if an object offset is applied to the object. Indeed, object offset transforms should not be inherited, so we need an Xform prim to encode the node's transform (the children of the node will export to children of this prim), and another for the object itself, which will be exported to a prim under that Xform. It will contain the object offset transform, and it will not have children.
  • Always :For cases where we always need to have a seperate prim for the node's transform. For example if we are exporting to a gprim, which, unless we explicitely allow it, should not be nested. This could also be the case if we need to add an inherent transform to the object's prim, part of the translation, and we never want that transform to be inherited.
  • Never : To be used if we know we never want to split the node's transform from its object. For example we could be baking the object offset transform into the geometry itself - in this scenario, we avoid the *need of an extra Xform entirely.
    Parameters
    nodeThe node to test for the xform split requirement.
    Returns
    The Xform split requirement for this object.

◆ Write()

virtual MaxUSDAPI bool MaxUsdPrimWriter::Write ( INode *  sourceNode,
UsdPrim &  targetPrim,
bool  applyOffsetTransform 
)
inlinevirtual

Responsible for writing the prim's attribute for the given context. This is where the translation from the 3dsMax node to the USD prim happens.

Parameters
sourceNodeThe node we are translating to USD.
targetPrimThe prim we are writing to.
applyOffsetTransformWhether or not the object offset transform should be applied onto the prim. Can only be true if HandlesObjectOffsetTransform() returned true, otherwise it will always be false.
Returns
True if the write operation was successful, false otherwise.

The documentation for this class was generated from the following file: