2 #include "AL/usdmaya/Common.h"
3 #include "maya/MPxData.h"
4 #include "maya/MGlobal.h"
5 #include "maya/MObject.h"
6 #include "maya/MObjectHandle.h"
7 #include "maya/MObjectArray.h"
8 #include "maya/MDGModifier.h"
9 #include "pxr/base/tf/refPtr.h"
10 #include "pxr/usd/usd/prim.h"
13 #include <unordered_map>
19 namespace translators {
21 typedef std::vector<MObjectHandle> MObjectHandleArray;
39 {
return TfCreateRefPtr(
new This(proxyShape)); }
44 {
return m_proxyShape; }
63 bool getTransform(
const SdfPath& path, MObjectHandle&
object);
74 bool getMObject(
const UsdPrim& prim, MObjectHandle&
object, MTypeId type)
75 {
return getMObject(prim.GetPath(), object, type); }
86 bool getMObject(
const SdfPath& path, MObjectHandle&
object, MTypeId type);
97 bool getMObject(
const UsdPrim& prim, MObjectHandle&
object, MFn::Type type)
98 {
return getMObject(prim.GetPath(), object, type); }
109 bool getMObject(
const SdfPath& path, MObjectHandle&
object, MFn::Type type);
115 bool getMObjects(
const UsdPrim& prim, MObjectHandleArray& returned)
122 bool getMObjects(
const SdfPath& path, MObjectHandleArray& returned);
128 void insertItem(
const UsdPrim& prim, MObjectHandle
object);
149 const auto it = m_primMapping.find(path.GetString());
150 if(it != m_primMapping.end())
152 return it->second.m_type;
162 void registerItem(
const UsdPrim& prim, MObjectHandle
object);
175 : m_proxyShape(proxyShape), m_primMapping()
183 MObjectHandle m_object;
184 MObjectHandleArray m_createdNodes;
189 std::unordered_map<std::string, PrimLookup> m_primMapping;
192 typedef TfRefPtr<TranslatorContext> TranslatorContextPtr;
This class provides a context to store mappings between UsdPrims, and the Maya nodes that represent t...
Definition: TranslatorContext.h:28
TfRefPtr< This > RefPtr
pointer to this type
Definition: TranslatorContext.h:33
A custom proxy shape node that attaches itself to a USD file, and then renders it. The stage is held internally as a member variable, and it will be composed based on a change to the "filePath" attribute.
Definition: ProxyShape.h:33
void deserialise(const MString &string)
deserialises the string back into the translator context
UsdStageRefPtr getUsdStage() const
return the usd stage associated with this context
TranslatorContext This
this type
Definition: TranslatorContext.h:32
bool getMObjects(const UsdPrim &prim, MObjectHandleArray &returned)
returns all of the maya nodes that were created by the specific prim
Definition: TranslatorContext.h:115
void removeItems(const UsdPrim &prim)
during a variant switch, if we lose a prim, then it's path will be passed into this method...
Definition: TranslatorContext.h:133
const nodes::ProxyShape * getProxyShape() const
return the proxy shape associated with this context
Definition: TranslatorContext.h:43
bool getTransform(const UsdPrim &prim, MObjectHandle &object)
given a USD prim, this will see whether a maya node exists for it. If it does, that will be returned ...
Definition: TranslatorContext.h:55
bool getMObject(const UsdPrim &prim, MObjectHandle &object, MTypeId type)
given a USD prim, this will see whether a maya node exists for it. If it does, that will be returned ...
Definition: TranslatorContext.h:74
void insertItem(const UsdPrim &prim, MObjectHandle object)
If within your custom translator plug-in you need to create any maya nodes, associate that maya node ...
static RefPtr create(nodes::ProxyShape *proxyShape)
construct a new context for the specified proxy shape node
Definition: TranslatorContext.h:38
MString serialise() const
serialises the content of the translator context to a text string.
bool getMObject(const UsdPrim &prim, MObjectHandle &object, MFn::Type type)
given a USD prim, this will see whether a maya node exists for it. If it does, that will be returned ...
Definition: TranslatorContext.h:97
void registerItem(const UsdPrim &prim, MObjectHandle object)
Internal method. If within your custom translator plug-in you need to create any maya nodes...
TfToken getTypeForPath(SdfPath path) const
given a path to a prim, return the prim type we are aware of at that path
Definition: TranslatorContext.h:147