From 1ecbf58179da208a23ce01cc0fe525288e0c2294 Mon Sep 17 00:00:00 2001 From: Eoin Murphy Date: Fri, 10 Jan 2020 17:09:39 +1100 Subject: [PATCH 1/4] File Import now tries to create maya nodes which have al_usdmaya_transformType, or falls back to standard transforms if that fails (#1013) --- .../AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp | 7 ++++++- .../fileio/translators/DagNodeTranslator.cpp | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp index 3d37302429..a133c984f9 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp @@ -75,8 +75,13 @@ NodeFactory::~NodeFactory() //---------------------------------------------------------------------------------------------------------------------- MObject NodeFactory::createNode(const UsdPrim& from, const char* const nodeType, MObject parent, bool parentUnmerged) { + TF_DEBUG(ALUSDMAYA_TRANSLATORS).Msg(" NodeFactory::createNode: %s of type %s\n", from.GetPrimPath().GetText(), nodeType); std::unordered_map::iterator it = m_builders.find(nodeType); - if(it == m_builders.end()) return MObject::kNullObj; + if(it == m_builders.end()) + { + //If we can't find a specific translator, use the DagNodeTranslator + it = m_builders.find("dagNode"); + } MObject obj = it->second->createNode(from, parent, nodeType, *m_params); setupNode(from, obj, parent, parentUnmerged); return obj; diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp index 18c4536976..a166ff29af 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp @@ -67,11 +67,19 @@ void DagNodeTranslator::initialiseDefaultShadingGroup(MObject& target) //---------------------------------------------------------------------------------------------------------------------- MObject DagNodeTranslator::createNode(const UsdPrim& from, MObject parent, const char* nodeType, const ImporterParams& params) { + const char* const xformError = "DagNodeTranslator::createNode error creating node"; + MStatus status; MFnDagNode fn; - MObject to = fn.create(nodeType); - MStatus status = copyAttributes(from, to, params); - AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "Dag node translator: unable t/o get attributes"); + MObject to = fn.create(nodeType, parent, &status); + if (status!= MS::kSuccess) { + std::cerr << "DagNodeTranslator::createNode unable to create node of type " << nodeType << ". Create transform instead" << std::endl; + to = fn.create("transform", parent, &status); + } + AL_MAYA_CHECK_ERROR2(status, xformError); + + status = copyAttributes(from, to, params); + AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "DagNodeTranslator::createNode unable to get attributes"); return to; } From 37171e28040a2e9b7e32315106e3005897132ae9 Mon Sep 17 00:00:00 2001 From: eoinm Date: Fri, 31 Jan 2020 16:49:04 +1100 Subject: [PATCH 2/4] fix bug with shadow m_prim in derived class --- .../AL_USDMaya/AL/usdmaya/nodes/BasicTransformationMatrix.h | 5 +++-- .../lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/BasicTransformationMatrix.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/BasicTransformationMatrix.h index 6aef37828f..a204cf1952 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/BasicTransformationMatrix.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/BasicTransformationMatrix.h @@ -84,9 +84,10 @@ class BasicTransformationMatrix AL_USDMAYA_PUBLIC static MPxTransformationMatrix* creator(); -private: - +protected: UsdPrim m_prim; + +private: UsdGeomScope m_scope; MObjectHandle m_transformNode; diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.h index 63632b6ffe..271bc4ea31 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.h @@ -46,7 +46,6 @@ class TransformationMatrix friend class Transform; - UsdPrim m_prim; UsdGeomXformable m_xform; UsdTimeCode m_time; std::vector m_xformops; From 137266f4c84e700f908cdda8fd48e4d45fce5093 Mon Sep 17 00:00:00 2001 From: eoinm Date: Fri, 31 Jan 2020 17:17:41 +1100 Subject: [PATCH 3/4] fix constructor --- .../lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp index 2c4771c016..82c26e8185 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/TransformationMatrix.cpp @@ -46,7 +46,6 @@ MPxTransformationMatrix* TransformationMatrix::creator() //---------------------------------------------------------------------------------------------------------------------- TransformationMatrix::TransformationMatrix() : BasicTransformationMatrix(), - m_prim(), m_xform(), m_time(UsdTimeCode::Default()), m_scaleTweak(0, 0, 0), @@ -75,8 +74,7 @@ TransformationMatrix::TransformationMatrix() //---------------------------------------------------------------------------------------------------------------------- TransformationMatrix::TransformationMatrix(const UsdPrim& prim) - : BasicTransformationMatrix(), - m_prim(prim), + : BasicTransformationMatrix(prim), m_xform(prim), m_time(UsdTimeCode::Default()), m_scaleTweak(0, 0, 0), From 5b9f537e30c2a68a2bee970bf8dad317032c01fd Mon Sep 17 00:00:00 2001 From: eoinm Date: Tue, 4 Feb 2020 17:41:15 +1100 Subject: [PATCH 4/4] make DagNodeTranslator error messages a bit more consistent --- plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h | 2 +- .../fileio/translators/DagNodeTranslator.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h b/plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h index 09eaafa8be..646095cca7 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h @@ -21,7 +21,7 @@ #define stringify(a) #a #define AL_USDMAYA_VERSION_MAJOR 0 -#define AL_USDMAYA_VERSION_MINOR 36 +#define AL_USDMAYA_VERSION_MINOR 39 #define AL_USDMAYA_VERSION_PATCH 0 #define AL_USDMAYA_VERSION_STR xstr(AL_USDMAYA_VERSION_MAJOR) "." \ diff --git a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp index a166ff29af..6b366262b3 100644 --- a/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp +++ b/plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/translators/DagNodeTranslator.cpp @@ -41,7 +41,7 @@ MObject DagNodeTranslator::m_initialShadingGroup = MObject::kNullObj; //---------------------------------------------------------------------------------------------------------------------- MStatus DagNodeTranslator::registerType() { - const char* const errorString = "Unable to extract attribute for DagNodeTranslator"; + const char* const errorString = "DagNodeTranslator::Unable to extract attribute for DagNodeTranslator"; MNodeClass fn("transform"); MStatus status; @@ -67,19 +67,20 @@ void DagNodeTranslator::initialiseDefaultShadingGroup(MObject& target) //---------------------------------------------------------------------------------------------------------------------- MObject DagNodeTranslator::createNode(const UsdPrim& from, MObject parent, const char* nodeType, const ImporterParams& params) { - const char* const xformError = "DagNodeTranslator::createNode error creating node"; + std::string xformError = std::string("DagNodeTranslator::createNode error creating node of type ") + nodeType + + ". Create transform instead"; MStatus status; MFnDagNode fn; MObject to = fn.create(nodeType, parent, &status); + AL_MAYA_CHECK_ERROR2(status, xformError.c_str()); if (status!= MS::kSuccess) { - std::cerr << "DagNodeTranslator::createNode unable to create node of type " << nodeType << ". Create transform instead" << std::endl; to = fn.create("transform", parent, &status); } - AL_MAYA_CHECK_ERROR2(status, xformError); + AL_MAYA_CHECK_ERROR2(status, "DagNodeTranslator::createNode error creating node of type transform"); status = copyAttributes(from, to, params); - AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "DagNodeTranslator::createNode unable to get attributes"); + AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "DagNodeTranslator::createNode unable to copy attributes"); return to; } @@ -98,7 +99,7 @@ MStatus DagNodeTranslator::applyDefaultMaterialOnShape(MObject shape) { MStatus status; MFnSet fn(m_initialShadingGroup, &status); - AL_MAYA_CHECK_ERROR(status, "Unable to attach MfnSet to initialShadingGroup"); + AL_MAYA_CHECK_ERROR(status, "DagNodeTranslator::Unable to attach MfnSet to initialShadingGroup"); return fn.addMember(shape); }