AL_USDMaya  0.16.6
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AL::usdmaya::fileio::translators::TranslatorAbstract Class Referenceabstract

The base class interface of all translator plugins. The absolute minimum a translator plugin must implement are the following 3 methods: More...

#include <TranslatorBase.h>

Inheritance diagram for AL::usdmaya::fileio::translators::TranslatorAbstract:
AL::usdmaya::fileio::translators::TranslatorBase AL::usdmaya::fileio::translators::TranslatorTestPlugin

Public Types

typedef TranslatorAbstract This
 this type
 
typedef TfRefPtr< ThisRefPtr
 the type of a reference this type
 
typedef TfWeakPtr< ThisPtr
 weak pointer to this type
 

Public Member Functions

virtual ~TranslatorAbstract ()
 dtor
 
virtual TfType getTranslatedType () const =0
 Override to specify the schema type of the prim that this translator plugin is responsible for. More...
 
virtual bool needsTransformParent () const
 if the custom node type you are importing requires a parent transform (e.g. you are importing a shape node), then this method should return true. If however you do not need a parent transform (e.g. you are importing a texture!), then you can return false here. More...
 
virtual MStatus initialize ()
 Override this to do a one time initialization of your translator. Primarily this is to allow you to extract some MObject attribute handles from an MNodeClass, to avoid the need for calling findPlug at runtime (and the inherent cost of the strcmps/hash lookup that entails) More...
 
virtual MStatus import (const UsdPrim &prim, MObject &parent)
 Override this method to import a prim into your scene. More...
 
virtual MStatus postImport (const UsdPrim &prim)
 If your node needs to set up any relationships after import (for example, adding the node to a set, or making attribute connections), then all of that work should be performed here. More...
 
virtual MStatus preTearDown (UsdPrim &prim)
 This method will be called prior to the tear down process taking place. This is the last chance you have to do any serialisation whilst all of the existing nodes are available to query. More...
 
virtual MStatus tearDown (const SdfPath &path)
 If your plugin creates any nodes within Maya, then this method should be overridden to remove those nodes. This forms a central role within the variant switching system. More...
 
virtual bool supportsUpdate () const
 override this method and return true if the translator supports update More...
 
virtual MStatus update (const UsdPrim &prim)
 Optionally override this method to copy the attribute values from the prim onto the Maya nodes you have created. More...
 

Detailed Description

The base class interface of all translator plugins. The absolute minimum a translator plugin must implement are the following 3 methods:

  • initialize : Each translator has an opportunity to initialize itself. This should be used to perform any internal initialization (for example, using an MNodeClass to extract MObjects for the attributes you intend to translate, rather than using MFnDependencyNode::findPlug())
  • import : This should be used to create all node(s) that your translator will generate.
  • tearDown : If a variant switch occurs that removes/replaces your node type, your translator will be asked to remove the nodes it created from the scene. In this method, delete any nodes you created.

This will enable your plug-in to work correctly with variant switching. In addition, you may wish to overload the following methods:

  • needsTransformParent : If the maya node you will be creating is a DAG shape or custom transform, then by default this method returns true, which will provide you with a transform node under which you can parent your DAG shape.
  • postImport : The order in which the usd prims are imported into the scene is undefined, so if you wish to make any connections between Maya nodes, then that should be done here (i.e. when you are sure that all nodes will exist within the scene).
  • preTearDown : Prior to being notified of a tear down notification (as a result of a variant switch) if your plugin needs to save some state (e.g. layout or animation tweaks), then that data should be serialised in the preTearDown event. This method should not delete any nodes or make changes to the Maya scene. It is your last chance to inspect and serialise data prior to any nodes being deleted as a result of the tearDown.
  • update : If a variant switch occurs that leaves a prim intact (but may have changed some attribute values), then you can override this method to simply copy the attributes values from the prim onto the existing maya nodes. This is often faster than destroying and recreating the nodes. If you implement this method, you must override supportsUpdate to return true.

Do not inherit from this class directly - use the TranslatorBase instead.

Member Function Documentation

virtual TfType AL::usdmaya::fileio::translators::TranslatorAbstract::getTranslatedType ( ) const
pure virtual

Override to specify the schema type of the prim that this translator plugin is responsible for.

Returns
the custom schema type associated with this prim

Implemented in AL::usdmaya::fileio::translators::TranslatorBase.

virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::import ( const UsdPrim &  prim,
MObject &  parent 
)
inlinevirtual

Override this method to import a prim into your scene.

Parameters
primthe usd prim to be imported into maya
parenta handle to an MObject that represents an AL_usd_Transform node. You should parent your DAG objects under this node. If the prim you are importing is NOT a DAG object (e.g. surface shader, etc), then you can ignore this parameter.
Returns
MS::kSuccess if all ok

Reimplemented in AL::usdmaya::fileio::translators::TranslatorTestPlugin.

virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::initialize ( )
inlinevirtual

Override this to do a one time initialization of your translator. Primarily this is to allow you to extract some MObject attribute handles from an MNodeClass, to avoid the need for calling findPlug at runtime (and the inherent cost of the strcmps/hash lookup that entails)

Returns
MS::kSuccess if all ok

Reimplemented in AL::usdmaya::fileio::translators::TranslatorTestPlugin.

virtual bool AL::usdmaya::fileio::translators::TranslatorAbstract::needsTransformParent ( ) const
inlinevirtual

if the custom node type you are importing requires a parent transform (e.g. you are importing a shape node), then this method should return true. If however you do not need a parent transform (e.g. you are importing a texture!), then you can return false here.

Returns
true if this type of node requires a transform as a parent node (i.e. this is a DAG node), false if the node if a dependency node
virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::postImport ( const UsdPrim &  prim)
inlinevirtual

If your node needs to set up any relationships after import (for example, adding the node to a set, or making attribute connections), then all of that work should be performed here.

Parameters
primthe prim we are importing.
Returns
MS::kSuccess if all ok

Reimplemented in AL::usdmaya::fileio::translators::TranslatorTestPlugin.

virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::preTearDown ( UsdPrim &  prim)
inlinevirtual

This method will be called prior to the tear down process taking place. This is the last chance you have to do any serialisation whilst all of the existing nodes are available to query.

Parameters
primthe prim that may be modified or deleted as a result of a variant switch
Returns
MS::kSuccess if all ok

Reimplemented in AL::usdmaya::fileio::translators::TranslatorTestPlugin.

virtual bool AL::usdmaya::fileio::translators::TranslatorAbstract::supportsUpdate ( ) const
inlinevirtual

override this method and return true if the translator supports update

Returns
true if you plugin supports update, false otherwise.
virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::tearDown ( const SdfPath &  path)
inlinevirtual

If your plugin creates any nodes within Maya, then this method should be overridden to remove those nodes. This forms a central role within the variant switching system.

Parameters
paththe path to the prim that should be removed. CRASH_ALERT : It is vitally important that you do not attempt to access the prim from the current usd stage. It is entirely possible that a variant switch has removed the prim from the stage, so any attempts to access the UsdPrim via this path, is more than likely to crash Maya.
Returns
MS::kSuccess if all ok

Reimplemented in AL::usdmaya::fileio::translators::TranslatorTestPlugin.

virtual MStatus AL::usdmaya::fileio::translators::TranslatorAbstract::update ( const UsdPrim &  prim)
inlinevirtual

Optionally override this method to copy the attribute values from the prim onto the Maya nodes you have created.

Parameters
primthe prim
Returns
MS::kSuccess if all ok

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