//- This function is responsible to make the connection (association) //- between manipulators and the affected attributes. When a node in a scene //- is selected and user click on “show manipulator tool”, //- this function is called with the selected node. //- Arguments: //- dependNode - the node which is selected MStatus arrowLocatorManip::connectToDependNode(const MObject &dependNode) { MStatus status = MStatus::kSuccess; //- Find the "windDirection" plug on the selected node, which is the custom //- locator node. MFnDependencyNode fnDepNode(dependNode); MPlug rotationPlug = fnDepNode.findPlug(MString("windDirection"),&status); //- Connect the "windDirection" plug with the base disc manip MFnDiscManip fnDisc(fDiscManip,&status); status = fnDisc.connectToAnglePlug(rotationPlug); //- Set up affecting relationship using conversion callback function //- We are using addPlugToManipConversionCallback so that whenever //- the custom locator moves, the dis manip moves with it. MFnDagNode fnDagNode(dependNode); fnDagNode.getPath(fNodePath); unsigned int centerPointIndex = fnDisc.centerIndex(&status); addPlugToManipConversionCallback(centerPointIndex,(plugToManipConversionCallback)&arrowLocatorManip::centerPointCallback); //- The following two functions are mandatory inside your //- connectToDependNode() function status = finishAddingManips(); status = MPxManipContainer::connectToDependNode(dependNode); return status; }
MayaNurbsCurveWriter::MayaNurbsCurveWriter(MDagPath & iDag, Alembic::Abc::OObject & iParent, Alembic::Util::uint32_t iTimeIndex, bool iIsCurveGrp, const JobArgs & iArgs) : mIsAnimated(false), mRootDagPath(iDag), mIsCurveGrp(iIsCurveGrp) { MStatus stat; MFnDependencyNode fnDepNode(iDag.node(), &stat); MString name = fnDepNode.name(); if (mIsCurveGrp) { collectNurbsCurves(mRootDagPath, iArgs.excludeInvisible, mNurbsCurves, mIsAnimated); // if no curves were found bail early if (mNurbsCurves.length() == 0) return; } else { MObject curve = iDag.node(); if (iTimeIndex != 0 && util::isAnimated(curve)) mIsAnimated = true; } name = util::stripNamespaces(name, iArgs.stripNamespace); Alembic::AbcGeom::OCurves obj(iParent, name.asChar(), iTimeIndex); mSchema = obj.getSchema(); Alembic::Abc::OCompoundProperty cp; Alembic::Abc::OCompoundProperty up; if (AttributesWriter::hasAnyAttr(fnDepNode, iArgs)) { cp = mSchema.getArbGeomParams(); up = mSchema.getUserProperties(); } mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, fnDepNode, iTimeIndex, iArgs)); write(); }
// virtual bool MayaNurbsCurveWriter::writeNurbsCurveAttrs(const UsdTimeCode &usdTime, UsdGeomNurbsCurves &primSchema) { MStatus status = MS::kSuccess; // Write parent class attrs writeTransformAttrs(usdTime, primSchema); // Return if usdTime does not match if shape is animated if (usdTime.IsDefault() == isShapeAnimated() ) { // skip shape as the usdTime does not match if shape isAnimated value return true; } MFnDependencyNode fnDepNode(getDagPath().node(), &status); MString name = fnDepNode.name(); MFnNurbsCurve curveFn( getDagPath(), &status ); if (!status) { MGlobal::displayError("MFnNurbsCurve() failed for MayaNurbsCurveWriter"); return false; } // Get curve attrs ====== unsigned int numCurves = 1; // Assuming only 1 curve for now VtArray<int> curveOrder(numCurves); VtArray<int> curveVertexCounts(numCurves); VtArray<float> curveWidths(numCurves); VtArray<GfVec2d> ranges(numCurves); curveOrder[0] = curveFn.degree()+1; curveVertexCounts[0] = curveFn.numCVs(); TF_AXIOM(curveOrder[0] <= curveVertexCounts[0] ); curveWidths[0] = 1.0; // TODO: Retrieve from custom attr double mayaKnotDomainMin; double mayaKnotDomainMax; status = curveFn.getKnotDomain(mayaKnotDomainMin, mayaKnotDomainMax); TF_AXIOM(status == MS::kSuccess); ranges[0][0] = mayaKnotDomainMin; ranges[0][1] = mayaKnotDomainMax; MPointArray mayaCurveCVs; status = curveFn.getCVs(mayaCurveCVs, MSpace::kObject); TF_AXIOM(status == MS::kSuccess); VtArray<GfVec3f> points(mayaCurveCVs.length()); // all CVs batched together for (unsigned int i=0; i < mayaCurveCVs.length(); i++) { points[i].Set(mayaCurveCVs[i].x, mayaCurveCVs[i].y, mayaCurveCVs[i].z); } MDoubleArray mayaCurveKnots; status = curveFn.getKnots(mayaCurveKnots); TF_AXIOM(status == MS::kSuccess); VtArray<double> curveKnots(mayaCurveKnots.length()); // all knots batched together for (unsigned int i=0; i < mayaCurveKnots.length(); i++) { curveKnots[i] = mayaCurveKnots[i]; } // Gprim VtArray<GfVec3f> extent(2); UsdGeomCurves::ComputeExtent(points, curveWidths, &extent); primSchema.CreateExtentAttr().Set(extent, usdTime); // Curve primSchema.GetOrderAttr().Set(curveOrder); // not animatable primSchema.GetCurveVertexCountsAttr().Set(curveVertexCounts); // not animatable primSchema.GetWidthsAttr().Set(curveWidths); // not animatable primSchema.GetKnotsAttr().Set(curveKnots); // not animatable primSchema.GetRangesAttr().Set(ranges); // not animatable primSchema.GetPointsAttr().Set(points, usdTime); // CVs // TODO: Handle periodic and non-periodic cases return true; }
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); } }
MayaMeshWriter::MayaMeshWriter(MDagPath & iDag, Alembic::Abc::OObject & iParent, Alembic::Util::uint32_t iTimeIndex, const JobArgs & iArgs, GetMembersMap& gmMap) : mNoNormals(iArgs.noNormals), mWriteUVs(iArgs.writeUVs), mWriteColorSets(iArgs.writeColorSets), mWriteUVSets(iArgs.writeUVSets), mIsGeometryAnimated(false), mDagPath(iDag) { MStatus status = MS::kSuccess; MFnMesh lMesh( mDagPath, &status ); if ( !status ) { MGlobal::displayError( "MFnMesh() failed for MayaMeshWriter" ); } // intermediate objects aren't translated MObject surface = iDag.node(); if (iTimeIndex != 0 && util::isAnimated(surface)) { mIsGeometryAnimated = true; } else { iTimeIndex = 0; } std::vector<float> uvs; std::vector<Alembic::Util::uint32_t> indices; std::string uvSetName; MString name = lMesh.name(); name = util::stripNamespaces(name, iArgs.stripNamespace); // check to see if this poly has been tagged as a SubD MPlug plug = lMesh.findPlug("SubDivisionMesh"); if ( !plug.isNull() && plug.asBool() ) { Alembic::AbcGeom::OSubD obj(iParent, name.asChar(), iTimeIndex); mSubDSchema = obj.getSchema(); Alembic::AbcGeom::OV2fGeomParam::Sample uvSamp; if (mWriteUVs || mWriteUVSets) { getUVs(uvs, indices, uvSetName); if (!uvs.empty()) { if (!uvSetName.empty()) { mSubDSchema.setUVSourceName(uvSetName); } uvSamp.setScope( Alembic::AbcGeom::kFacevaryingScope ); uvSamp.setVals(Alembic::AbcGeom::V2fArraySample( (const Imath::V2f *) &uvs.front(), uvs.size() / 2)); if (!indices.empty()) { uvSamp.setIndices(Alembic::Abc::UInt32ArraySample( &indices.front(), indices.size())); } } } Alembic::Abc::OCompoundProperty cp; Alembic::Abc::OCompoundProperty up; if (AttributesWriter::hasAnyAttr(lMesh, iArgs)) { cp = mSubDSchema.getArbGeomParams(); up = mSubDSchema.getUserProperties(); } mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, lMesh, iTimeIndex, iArgs)); writeSubD(uvSamp); } else { Alembic::AbcGeom::OPolyMesh obj(iParent, name.asChar(), iTimeIndex); mPolySchema = obj.getSchema(); Alembic::AbcGeom::OV2fGeomParam::Sample uvSamp; if (mWriteUVs || mWriteUVSets) { getUVs(uvs, indices, uvSetName); if (!uvs.empty()) { if (!uvSetName.empty()) { mPolySchema.setUVSourceName(uvSetName); } uvSamp.setScope( Alembic::AbcGeom::kFacevaryingScope ); uvSamp.setVals(Alembic::AbcGeom::V2fArraySample( (const Imath::V2f *) &uvs.front(), uvs.size() / 2)); if (!indices.empty()) { uvSamp.setIndices(Alembic::Abc::UInt32ArraySample( &indices.front(), indices.size())); } } } Alembic::Abc::OCompoundProperty cp; Alembic::Abc::OCompoundProperty up; if (AttributesWriter::hasAnyAttr(lMesh, iArgs)) { cp = mPolySchema.getArbGeomParams(); up = mPolySchema.getUserProperties(); } // set the rest of the props and write to the writer node mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, lMesh, iTimeIndex, iArgs)); writePoly(uvSamp); } if (mWriteColorSets) { MStringArray colorSetNames; lMesh.getColorSetNames(colorSetNames); if (colorSetNames.length() > 0) { // Create the color sets compound prop Alembic::Abc::OCompoundProperty arbParams; if (mPolySchema.valid()) { arbParams = mPolySchema.getArbGeomParams(); } else { arbParams = mSubDSchema.getArbGeomParams(); } std::string currentColorSet = lMesh.currentColorSetName().asChar(); for (unsigned int i=0; i < colorSetNames.length(); ++i) { // Create an array property for each color set std::string colorSetPropName = colorSetNames[i].asChar(); Alembic::AbcCoreAbstract::MetaData md; if (currentColorSet == colorSetPropName) { md.set("mayaColorSet", "1"); } else { md.set("mayaColorSet", "0"); } if (lMesh.getColorRepresentation(colorSetNames[i]) == MFnMesh::kRGB) { Alembic::AbcGeom::OC3fGeomParam colorProp(arbParams, colorSetPropName, true, Alembic::AbcGeom::kFacevaryingScope, 1, iTimeIndex, md); mRGBParams.push_back(colorProp); } else { Alembic::AbcGeom::OC4fGeomParam colorProp(arbParams, colorSetPropName, true, Alembic::AbcGeom::kFacevaryingScope, 1, iTimeIndex, md); mRGBAParams.push_back(colorProp); } } writeColor(); } } if (mWriteUVSets) { MStringArray uvSetNames; lMesh.getUVSetNames(uvSetNames); unsigned int uvSetNamesLen = uvSetNames.length(); if (uvSetNamesLen > 1) { // Create the uv sets compound prop Alembic::Abc::OCompoundProperty arbParams; if (mPolySchema.valid()) { arbParams = mPolySchema.getArbGeomParams(); } else { arbParams = mSubDSchema.getArbGeomParams(); } MString currentUV = lMesh.currentUVSetName(); for (unsigned int i = 0; i < uvSetNamesLen; ++i) { // Create an array property for each uv set MString uvSetPropName = uvSetNames[i]; // the current UV set gets mapped to the primary UVs if (currentUV == uvSetPropName) { continue; } if (uvSetPropName.length() > 0 && lMesh.numUVs(uvSetPropName) > 0) { mUVparams.push_back(Alembic::AbcGeom::OV2fGeomParam( arbParams, uvSetPropName.asChar(), true, Alembic::AbcGeom::kFacevaryingScope, 1, iTimeIndex)); } } writeUVSets(); } } // write out facesets if(!iArgs.writeFaceSets) return; // get the connected shading engines MObjectArray connSGObjs (getOutConnectedSG(mDagPath)); const unsigned int sgCount = connSGObjs.length(); for (unsigned int i = 0; i < sgCount; ++i) { MObject connSGObj, compObj; connSGObj = connSGObjs[i]; MFnDependencyNode fnDepNode(connSGObj); MString connSgObjName = fnDepNode.name(); // retrive the component MObject status = getSetComponents(mDagPath, connSGObj, gmMap, compObj); if (status != MS::kSuccess) { // for some reason the shading group doesn't represent a face set continue; } // retrieve the face indices MIntArray indices; MFnSingleIndexedComponent compFn; compFn.setObject(compObj); compFn.getElements(indices); const unsigned int numData = indices.length(); // encountered the whole object mapping. skip it. if (numData == 0) continue; std::vector<Alembic::Util::int32_t> faceIndices(numData); for (unsigned int j = 0; j < numData; ++j) { faceIndices[j] = indices[j]; } connSgObjName = util::stripNamespaces(connSgObjName, iArgs.stripNamespace); Alembic::AbcGeom::OFaceSet faceSet; std::string faceSetName(connSgObjName.asChar()); MPlug abcFacesetNamePlug = fnDepNode.findPlug("AbcFacesetName", true); if (!abcFacesetNamePlug.isNull()) { faceSetName = abcFacesetNamePlug.asString().asChar(); } if (mPolySchema.valid()) { if (mPolySchema.hasFaceSet(faceSetName)) { faceSet = mPolySchema.getFaceSet(faceSetName); } else { faceSet = mPolySchema.createFaceSet(faceSetName); } } else { if (mSubDSchema.hasFaceSet(faceSetName)) { faceSet = mSubDSchema.getFaceSet(faceSetName); } else { faceSet = mSubDSchema.createFaceSet(faceSetName); } } Alembic::AbcGeom::OFaceSetSchema::Sample samp; samp.setFaces(Alembic::Abc::Int32ArraySample(faceIndices)); Alembic::AbcGeom::OFaceSetSchema faceSetSchema = faceSet.getSchema(); faceSetSchema.set(samp); faceSetSchema.setFaceExclusivity(Alembic::AbcGeom::kFaceSetExclusive); MFnDependencyNode iNode(connSGObj); Alembic::Abc::OCompoundProperty cp; Alembic::Abc::OCompoundProperty up; if (AttributesWriter::hasAnyAttr(iNode, iArgs)) { cp = faceSetSchema.getArbGeomParams(); up = faceSetSchema.getUserProperties(); } AttributesWriter attrWriter(cp, up, faceSet, iNode, iTimeIndex, iArgs); attrWriter.write(); } }
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); } }