void AbcWriteJob::setup(double iFrame, MayaTransformWriterPtr iParent, GetMembersMap& gmMap) { MStatus status; // short-circuit if selection flag is on but this node isn't actively // selected if (mArgs.useSelectionList && !mSList.hasItem(mCurDag)) return; MObject ob = mCurDag.node(); // skip all intermediate nodes (and their children) if (util::isIntermediate(ob)) { return; } // skip nodes that aren't renderable (and their children) if (mArgs.excludeInvisible && !util::isRenderable(ob)) { return; } // look for riCurves flag for flattening all curve objects to a curve group MFnDependencyNode fnDepNode(ob, &status); MPlug riCurvesPlug = fnDepNode.findPlug("riCurves", &status); bool riCurvesVal = riCurvesPlug.asBool(); bool writeOutAsGroup = false; if (riCurvesVal) { writeOutAsGroup = checkCurveGrp(); if (writeOutAsGroup == false) { MString msg = "Curves have different degrees or close "; msg += "states, not writing out as curve group"; MGlobal::displayWarning(msg); } } if ( status == MS::kSuccess && riCurvesVal && writeOutAsGroup) { MayaNurbsCurveWriterPtr nurbsCurve; if (iParent == NULL) { Alembic::Abc::OObject obj = mRoot.getTop(); nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( mCurDag, obj, mShapeTimeIndex, true, mArgs)); } else { Alembic::Abc::OObject obj = iParent->getObject(); nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( mCurDag, obj, mShapeTimeIndex, true, mArgs)); } if (nurbsCurve->isAnimated() && mShapeTimeIndex != 0) { mCurveList.push_back(nurbsCurve); mStats.mCurveAnimNum++; mStats.mCurveAnimCurves += nurbsCurve->getNumCurves(); mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); } else { mStats.mCurveStaticNum++; mStats.mCurveStaticCurves += nurbsCurve->getNumCurves(); mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); } AttributesWriterPtr attrs = nurbsCurve->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else if (ob.hasFn(MFn::kTransform)) { MFnTransform fnTrans(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize transform node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } MayaTransformWriterPtr trans; // parented to the root case if (iParent == NULL) { Alembic::Abc::OObject obj = mRoot.getTop(); trans = MayaTransformWriterPtr(new MayaTransformWriter( obj, mCurDag, mTransTimeIndex, mArgs)); } else { trans = MayaTransformWriterPtr(new MayaTransformWriter( *iParent, mCurDag, mTransTimeIndex, mArgs)); } if (trans->isAnimated() && mTransTimeIndex != 0) { mTransList.push_back(trans); mStats.mTransAnimNum++; } else mStats.mTransStaticNum++; AttributesWriterPtr attrs = trans->getAttrs(); if (mTransTimeIndex != 0 && attrs->isAnimated()) mTransAttrList.push_back(attrs); // loop through the children, making sure to push and pop them // from the MDagPath unsigned int numChild = mCurDag.childCount(); for (unsigned int i = 0; i < numChild; ++i) { if (mCurDag.push(mCurDag.child(i)) == MS::kSuccess) { setup(iFrame, trans, gmMap); mCurDag.pop(); } } } else if (ob.hasFn(MFn::kLocator)) { MFnDependencyNode fnLocator(ob, & status); if (status != MS::kSuccess) { MString msg = "Initialize locator node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaLocatorWriterPtr locator(new MayaLocatorWriter( mCurDag, obj, mShapeTimeIndex, mArgs)); if (locator->isAnimated() && mShapeTimeIndex != 0) { mLocatorList.push_back(locator); mStats.mLocatorAnimNum++; } else { mStats.mLocatorStaticNum++; } AttributesWriterPtr attrs = locator->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += fnLocator.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else if (ob.hasFn(MFn::kParticle)) { MFnParticleSystem mFnParticle(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize particle system "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaPointPrimitiveWriterPtr particle(new MayaPointPrimitiveWriter( iFrame, mCurDag, obj, mShapeTimeIndex, mArgs)); if (particle->isAnimated() && mShapeTimeIndex != 0) { mPointList.push_back(particle); mStats.mPointAnimNum++; mStats.mPointAnimCVs += particle->getNumCVs(); } else { mStats.mPointStaticNum++; mStats.mPointStaticCVs += particle->getNumCVs(); } AttributesWriterPtr attrs = particle->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += mFnParticle.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else if (ob.hasFn(MFn::kMesh)) { MFnMesh fnMesh(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize mesh node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaMeshWriterPtr mesh(new MayaMeshWriter(mCurDag, obj, mShapeTimeIndex, mArgs, gmMap)); if (mesh->isAnimated() && mShapeTimeIndex != 0) { mMeshList.push_back(mesh); if (mesh->isSubD()) { mStats.mSubDAnimNum++; mStats.mSubDAnimCVs += mesh->getNumCVs(); mStats.mSubDAnimFaces += mesh->getNumFaces(); } else { mStats.mPolyAnimNum++; mStats.mPolyAnimCVs += mesh->getNumCVs(); mStats.mPolyAnimFaces += mesh->getNumFaces(); } } else { if (mesh->isSubD()) { mStats.mSubDStaticNum++; mStats.mSubDStaticCVs += mesh->getNumCVs(); mStats.mSubDStaticFaces += mesh->getNumFaces(); } else { mStats.mPolyStaticNum++; mStats.mPolyStaticCVs += mesh->getNumCVs(); mStats.mPolyStaticFaces += mesh->getNumFaces(); } } AttributesWriterPtr attrs = mesh->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += fnMesh.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else if (ob.hasFn(MFn::kCamera)) { MFnCamera fnCamera(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize camera node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaCameraWriterPtr camera(new MayaCameraWriter( mCurDag, obj, mShapeTimeIndex, mArgs)); if (camera->isAnimated() && mShapeTimeIndex != 0) { mCameraList.push_back(camera); mStats.mCameraAnimNum++; } else mStats.mCameraStaticNum++; AttributesWriterPtr attrs = camera->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += fnCamera.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else if (ob.hasFn(MFn::kNurbsSurface)) { MFnNurbsSurface fnNurbsSurface(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize nurbs surface "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaNurbsSurfaceWriterPtr nurbsSurface(new MayaNurbsSurfaceWriter( mCurDag, obj, mShapeTimeIndex, mArgs)); if (nurbsSurface->isAnimated() && mShapeTimeIndex != 0) { mNurbsList.push_back(nurbsSurface); mStats.mNurbsAnimNum++; mStats.mNurbsAnimCVs += nurbsSurface->getNumCVs(); } else { mStats.mNurbsStaticNum++; mStats.mNurbsStaticCVs += nurbsSurface->getNumCVs(); } AttributesWriterPtr attrs = nurbsSurface->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += fnNurbsSurface.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else if (ob.hasFn(MFn::kNurbsCurve)) { MFnNurbsCurve fnNurbsCurve(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize curve node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } if (iParent != NULL) { Alembic::Abc::OObject obj = iParent->getObject(); MayaNurbsCurveWriterPtr nurbsCurve(new MayaNurbsCurveWriter( mCurDag, obj, mShapeTimeIndex, false, mArgs)); if (nurbsCurve->isAnimated() && mShapeTimeIndex != 0) { mCurveList.push_back(nurbsCurve); mStats.mCurveAnimNum++; mStats.mCurveAnimCurves++; mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); } else { mStats.mCurveStaticNum++; mStats.mCurveStaticCurves++; mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); } AttributesWriterPtr attrs = nurbsCurve->getAttrs(); if (mShapeTimeIndex != 0 && attrs->isAnimated()) mShapeAttrList.push_back(attrs); } else { MString err = "Can't translate "; err += fnNurbsCurve.name() + " since it doesn't have a parent."; MGlobal::displayError(err); } } else { MString warn = mCurDag.fullPathName() + " is an unsupported type of "; warn += ob.apiTypeStr(); MGlobal::displayWarning(warn); } }
void AbcWriteJob::setup(double iFrame, MayaTransformWriterPtr iParent, util::GetMembersMap& gmMap) { MStatus status; // short-circuit if selection flag is on but this node isn't actively // selected if (mArgs.useSelectionList && !mSList.hasItem(mCurDag)) return; MObject ob = mCurDag.node(); MFnDependencyNode fnDepNode(ob, &status); bool bSolvedState = fnDepNode.typeName() == "bulletRigidCollection"; // skip all intermediate nodes (and their children) if (util::isIntermediate(ob)) { if (!bSolvedState) { return; } } // skip nodes that aren't renderable (and their children) if (mArgs.excludeInvisible && !util::isRenderable(ob)) { return; } if ( bSolvedState ) { // the motionstates are held on the initialstate node at the moment if (status != MS::kSuccess) { MString msg = "Initialize transform collection node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } MayaTransformCollectionWriterPtr transCol; // transformcollections always parented to the root case Alembic::Abc::OObject obj = mRoot.getTop(); transCol = MayaTransformCollectionWriterPtr(new MayaTransformCollectionWriter( obj, mCurDag, mTransTimeIndex, mArgs)); mTransColList.push_back(transCol); mStats.mTransColNum++; AttributesWriterPtr attrs = transCol->getAttrs(); if (attrs) { if (mTransTimeIndex != 0 && attrs->isAnimated()) mTransColAttrList.push_back(attrs); } } else if (ob.hasFn(MFn::kTransform)) { MFnTransform fnTrans(ob, &status); if (status != MS::kSuccess) { MString msg = "Initialize transform node "; msg += mCurDag.fullPathName(); msg += " failed, skipping."; MGlobal::displayWarning(msg); return; } MayaTransformWriterPtr trans; // parented to the root case if (iParent == NULL) { Alembic::Abc::OObject obj = mRoot.getTop(); trans = MayaTransformWriterPtr(new MayaTransformWriter( obj, mCurDag, mTransTimeIndex, mArgs)); } else { trans = MayaTransformWriterPtr(new MayaTransformWriter( *iParent, mCurDag, mTransTimeIndex, mArgs)); } if (trans->isAnimated() && mTransTimeIndex != 0) { mTransList.push_back(trans); mStats.mTransAnimNum++; } else mStats.mTransStaticNum++; AttributesWriterPtr attrs = trans->getAttrs(); if (mTransTimeIndex != 0 && attrs->isAnimated()) mTransAttrList.push_back(attrs); // loop through the children, making sure to push and pop them // from the MDagPath unsigned int numChild = mCurDag.childCount(); for (unsigned int i = 0; i < numChild; ++i) { mCurDag.push(mCurDag.child(i)); setup(iFrame, trans, gmMap); mCurDag.pop(); } } else { MString warn = mCurDag.fullPathName() + " is an unsupported type of "; warn += ob.apiTypeStr(); MGlobal::displayWarning(warn); } }