MStatus uninitializePlugin(MObject object) { MFnPlugin pluginFn; pluginFn.deregisterNode(MTypeId(0x80008)); return MS::kSuccess; }
MStatus initializePlugin( MObject obj ) { MStatus stat; MFnPlugin fnPlugin( obj, "Marco Giordano", "1.0", "Any"); stat =fnPlugin.registerNode("MG_dotProduct", MTypeId(0x832496),MG_dotProduct::creator, MG_dotProduct::initialize); if( stat != MS::kSuccess ) stat.perror( "could not register the CustomLocator node" ); return stat; }
#include "move_manipulator.h" #include "util.h" #include <limits> #include <maya/MFnDependencyNode.h> #include <maya/MFnDagNode.h> #include <maya/MFnManip3D.h> #include <maya/MGLFunctionTable.h> #include <maya/MHardwareRenderer.h> #include <maya/MAngle.h> #include <maya/MQuaternion.h> const MTypeId MannequinMoveManipulator::id = MTypeId(0xcafebee); MannequinMoveManipulator::MannequinMoveManipulator() {} void MannequinMoveManipulator::postConstructor() { addPointValue("translate", MPoint(0, 0, 0), _translateIndex); glFirstHandle(_glPickableItem); } MStatus MannequinMoveManipulator::connectToDependNode(const MObject &dependNode) { MStatus status; MFnDependencyNode nodeFn(dependNode, &status); if (!status) return MS::kFailure; MPlug translatePlug = nodeFn.findPlug("translate", &status);
std::ostream& operator <<(std::ostream& out, const UsdMayaJobExportArgs& exportArgs) { out << "compatibility: " << exportArgs.compatibility << std::endl << "defaultMeshScheme: " << exportArgs.defaultMeshScheme << std::endl << "eulerFilter: " << TfStringify(exportArgs.eulerFilter) << std::endl << "excludeInvisible: " << TfStringify(exportArgs.excludeInvisible) << std::endl << "exportCollectionBasedBindings: " << TfStringify(exportArgs.exportCollectionBasedBindings) << std::endl << "exportColorSets: " << TfStringify(exportArgs.exportColorSets) << std::endl << "exportDefaultCameras: " << TfStringify(exportArgs.exportDefaultCameras) << std::endl << "exportDisplayColor: " << TfStringify(exportArgs.exportDisplayColor) << std::endl << "exportInstances: " << TfStringify(exportArgs.exportInstances) << std::endl << "exportMaterialCollections: " << TfStringify(exportArgs.exportMaterialCollections) << std::endl << "exportMeshUVs: " << TfStringify(exportArgs.exportMeshUVs) << std::endl << "exportNurbsExplicitUV: " << TfStringify(exportArgs.exportNurbsExplicitUV) << std::endl << "exportRefsAsInstanceable: " << TfStringify(exportArgs.exportRefsAsInstanceable) << std::endl << "exportSkels: " << TfStringify(exportArgs.exportSkels) << std::endl << "exportSkin: " << TfStringify(exportArgs.exportSkin) << std::endl << "exportVisibility: " << TfStringify(exportArgs.exportVisibility) << std::endl << "materialCollectionsPath: " << exportArgs.materialCollectionsPath << std::endl << "materialsScopeName: " << exportArgs.materialsScopeName << std::endl << "mergeTransformAndShape: " << TfStringify(exportArgs.mergeTransformAndShape) << std::endl << "normalizeNurbs: " << TfStringify(exportArgs.normalizeNurbs) << std::endl << "parentScope: " << exportArgs.parentScope << std::endl << "renderLayerMode: " << exportArgs.renderLayerMode << std::endl << "rootKind: " << exportArgs.rootKind << std::endl << "shadingMode: " << exportArgs.shadingMode << std::endl << "stripNamespaces: " << TfStringify(exportArgs.stripNamespaces) << std::endl << "timeSamples: " << exportArgs.timeSamples.size() << " sample(s)" << std::endl << "usdModelRootOverridePath: " << exportArgs.usdModelRootOverridePath << std::endl; out << "melPerFrameCallback: " << exportArgs.melPerFrameCallback << std::endl << "melPostCallback: " << exportArgs.melPostCallback << std::endl << "pythonPerFrameCallback: " << exportArgs.pythonPerFrameCallback << std::endl << "pythonPostCallback: " << exportArgs.pythonPostCallback << std::endl; out << "dagPaths (" << exportArgs.dagPaths.size() << ")" << std::endl; for (const MDagPath& dagPath : exportArgs.dagPaths) { out << " " << dagPath.fullPathName().asChar() << std::endl; } out << "_filteredTypeIds (" << exportArgs.GetFilteredTypeIds().size() << ")" << std::endl; for (unsigned int id : exportArgs.GetFilteredTypeIds()) { out << " " << id << ": " << MNodeClass(MTypeId(id)).className() << std::endl; } out << "chaserNames (" << exportArgs.chaserNames.size() << ")" << std::endl; for (const std::string& chaserName : exportArgs.chaserNames) { out << " " << chaserName << std::endl; } out << "allChaserArgs (" << exportArgs.allChaserArgs.size() << ")" << std::endl; for (const auto& chaserIter : exportArgs.allChaserArgs) { // Chaser name. out << " " << chaserIter.first << std::endl; for (const auto& argIter : chaserIter.second) { out << " Arg Name: " << argIter.first << ", Value: " << argIter.second << std::endl; } } return out; }
/*! Compute function, gets the input surface, determines what type it is and calls the appropriate conversion function Encapsulates an cowpointer to the body into the naiadBodyData type and outputs it */ MStatus NBuddySurfaceToBodyNode::compute( const MPlug& plug, MDataBlock& data ) { MStatus status; if (plug == _outBody) { //Get the body name MDataHandle bodyNameHndl = data.inputValue( _bodyName, &status ); MString bodyName = bodyNameHndl.asString(); //Create the MFnPluginData for the naiadBody MFnPluginData dataFn; dataFn.create( MTypeId( naiadBodyData::id ), &status); NM_CheckMStatus( status, "Failed to create naiadBodyData in MFnPluginData"); //Get subdivision info from plugs so better approximations of meshes can be done int divisions = data.inputValue( _subDivide, &status ).asBool(); //Getting genericAttribute handle containing the surface and pick the correct conversion function MObject meshObj; MDataHandle inSurfaceHdl = data.inputValue( _inSurface, &status ); if (inSurfaceHdl.type() == MFnData::kNurbsSurface) { MFnNurbsSurface nurbsFn(inSurfaceHdl.asNurbsSurface()); // Create the data holder for the tesselated mesh MFnMeshData dataCreator; MObject newOutputData = dataCreator.create(&status); //Setup the tesselation parameters MTesselationParams tParams; tParams.setOutputType( MTesselationParams::kTriangles ); tParams.setFormatType( MTesselationParams::kGeneralFormat ); tParams.setUIsoparmType( MTesselationParams::kSpanEquiSpaced ); tParams.setVIsoparmType( MTesselationParams::kSpanEquiSpaced ); tParams.setUNumber( divisions+1 ); tParams.setVNumber( divisions+1 ); // Tesselate and get the returned mesh meshObj = nurbsFn.tesselate( tParams, newOutputData, &status ); NM_CheckMStatus( status, "NBuddySurfaceToBodyNode::compute Failed to tesselate nurbs surface to poly"); } else if (inSurfaceHdl.type() == MFnData::kMesh) { meshObj = inSurfaceHdl.asMesh(); if ( divisions > 0 ) { MFnMeshData dataCreator; MObject newOutputData = dataCreator.create(&status); MFnMesh meshFn(meshObj); MIntArray faceIds; for ( unsigned int i(0); i < meshFn.numPolygons(); ++i ) faceIds.append(i); meshFn.subdivideFaces( faceIds , divisions ); } } else if (inSurfaceHdl.type() == MFnData::kSubdSurface) { // Create the subd function set so we can tesselate MFnSubd subDfn(inSurfaceHdl.asSubdSurface()); // Create the data holder for the tesselated mesh MFnMeshData dataCreator; MObject newOutputData = dataCreator.create(&status); // Tesselate the subD surface meshObj = subDfn.tesselate(true, 1 , divisions , newOutputData, &status ); NM_CheckMStatus( status, "NBuddySurfaceToBodyNode::compute Failed to tesselate SubD surface to poly"); } else return status ; //Get the handle for the input transform MDataHandle inTransformHdl = data.inputValue( _inTransform, &status ); NM_CheckMStatus( status, "Failed to get inTransform handle"); MDataHandle useTransformHdl = data.inputValue( _useTransform, &status); NM_CheckMStatus( status, "Failed to get worldSpaceHdl "); bool useTransform = useTransformHdl.asBool(); //Get a new naiadBodyData naiadBodyData * newBodyData = (naiadBodyData*)dataFn.data( &status ); NM_CheckMStatus( status, "Failed to get naiadBodyData handle from MFnPluginData"); try { newBodyData->nBody = mayaMeshToNaiadBody( meshObj, std::string(bodyName.asChar()), useTransform, inTransformHdl.asMatrix() ); } catch(std::exception& ex) { NM_ExceptionPlugDisplayError("NBuddySurfaceToBodyNode::compute ", plug, ex ); } //Give the data to the output handle and set it clean MDataHandle bodyDataHnd = data.outputValue( _outBody, &status ); NM_CheckMStatus( status, "Failed to get outputData handle for outBody"); bodyDataHnd.set( newBodyData ); data.setClean( plug ); } return status; }