void MeshGitCmd::manualResolveConflict(MString resolution, MString nodeName) { MStatus status; if(nodeName == NULL || nodeName =="") return; //Get Node Object MSelectionList nodeList; status = nodeList.add(nodeName); MObject nodeObject; status = nodeList.getDependNode(0, nodeObject); reportError(status); //Create Node Fn MeshGitFn mgFn; status = mgFn.setObject(nodeObject); reportError(status); //Resolve conflict with resolution int rc = resolution.asInt(); mgFn.manualResolveConflict(rc); reportError(status); }
void OutputHelper::addRSLVariable(const MString& inputQualifier, MString rslType, const MString& rslName, const MString& mayaName, const MString& mayaNode) { MString cmd; // If the user specified that the type was an array of floats // (eg "float2"), extract the size and set the type to float. int rslTypeSize = 1; MString matchedStr; IfMErrorWarn(MGlobal::executeCommand("match(\"float[0-9]+$\",\""+rslType+"\")", matchedStr)); if(matchedStr != "") { IfMErrorWarn(MGlobal::executeCommand("match(\"[0-9]+$\",\""+rslType+"\")", matchedStr)); rslTypeSize = matchedStr.asInt(); rslType = "float"; } // Create the plug's name, and check for convertible connections. MString plug(mayaNode+"."+mayaName); int connected = liquidmaya::ShaderMgr::getSingletonPtr()->convertibleConnection(plug.asChar()); // If there are no convertible connections, then we have to // write out the variable into the shader's body. if( connected == 0 ) { //rslTypeSize(int) --> rslTypeSizeStr(string) MString rslTypeSizeStr; rslTypeSizeStr.set(rslTypeSize); // Write out the description of the variable. rslShaderBody += (" "+inputQualifier + " " + rslType + " " + rslName); rslShaderBody += ( rslTypeSize != 1 )? ( "[" + rslTypeSizeStr + "] = " ) :( " = " + rslType + " " ); // Write out the value of the variable. if( rslType=="color" ||rslType=="point" ||rslType=="normal" ||rslType=="vector") { MDoubleArray val; val.setLength(3); IfMErrorWarn(MGlobal::executeCommand("getAttr \""+plug+"\"", val)); //val(double) --> valStr(string) MStringArray valStr; valStr.setLength(3); valStr[0].set(val[0]); valStr[1].set(val[1]); valStr[2].set(val[2]); rslShaderBody +="("+valStr[0]+","+valStr[1]+","+valStr[2]+")"; }else if(rslType=="string"){ MString val; IfMErrorWarn(MGlobal::executeCommand("getAttr \""+plug+"\"", val)); rslShaderBody +="\""+val+"\""; }else if(rslType=="float"){ if(rslTypeSize == 1){ double val; IfMErrorWarn(MGlobal::executeCommand("getAttr \""+plug+"\"", val)); //val(double) --> valStr(string) MString valStr; valStr.set(val); rslShaderBody += valStr; }else{ rslShaderBody += "{ "; MDoubleArray val; val.setLength(rslTypeSize); IfMErrorWarn(MGlobal::executeCommand("getAttr \""+plug+"\"", val)); for(int i=0; i<rslTypeSize; ++i){ if( i != 0 ){ rslShaderBody += ", "; } //val[i](double) --> valStr(string) MString valStr; valStr.set(val[i]); rslShaderBody += valStr; } rslShaderBody += " }"; } } rslShaderBody += ";\n"; }//if( $connected == 0 ) // Otherwise, we have a convertible connection, so we'll be // adding the variable to the block's header. else{ rslShaderHeader += " "; // Note if it's connected as an output. if(connected == 2){ rslShaderHeader += "output "; } // Write out the description. rslShaderHeader += ( rslType + " " + rslName ); if( rslTypeSize != 1 ) { rslShaderHeader += "[]"; } rslShaderHeader += ";\n"; // if(connected == 1) { MStringArray srcPlug; IfMErrorWarn(MGlobal::executeCommand("listConnections -source true -plugs true \""+plug+"\"", srcPlug)); assert(srcPlug.length()==1); rslShaderBody +="//"+plug+" <-- "+srcPlug[0]+"\n"; } }//else }
MStatus MayaRenderGlobalsNode::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus stat = MStatus::kSuccess; filtertype = eAttr.create("filtertype", "filtertype", 0, &stat); CHECK_MSTATUS(addAttribute( filtertype )); imageFormat = eAttr.create("imageFormat", "imageFormat", 0, &stat); CHECK_MSTATUS(addAttribute( imageFormat )); sceneScale = nAttr.create("sceneScale", "sceneScale", MFnNumericData::kFloat, 1.0f); CHECK_MSTATUS(addAttribute( sceneScale )); useSunLightConnection = nAttr.create("useSunLightConnection", "useSunLightConnection", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( useSunLightConnection )); exportSceneFile = nAttr.create("exportSceneFile", "exportSceneFile", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( exportSceneFile )); exportSceneFileName = tAttr.create("exportSceneFileName", "exportSceneFileName", MFnNumericData::kString); tAttr.setUsedAsFilename(true); CHECK_MSTATUS(addAttribute( exportSceneFileName )); // sampling adaptive minSamples = nAttr.create("minSamples", "minSamples", MFnNumericData::kInt, 1); CHECK_MSTATUS(addAttribute( minSamples )); maxSamples = nAttr.create("maxSamples", "maxSamples", MFnNumericData::kInt, 16); CHECK_MSTATUS(addAttribute( maxSamples )); // sampling raster based samplesX = nAttr.create("samplesX", "samplesX", MFnNumericData::kInt, 3); CHECK_MSTATUS(addAttribute( samplesX )); samplesY = nAttr.create("samplesY", "samplesY", MFnNumericData::kInt, 3); CHECK_MSTATUS(addAttribute( samplesY )); doMotionBlur = nAttr.create("doMotionBlur", "doMotionBlur", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( doMotionBlur )); motionBlurRange = nAttr.create("motionBlurRange", "motionBlurRange", MFnNumericData::kFloat, 0.4); CHECK_MSTATUS(addAttribute( motionBlurRange )); motionBlurType = eAttr.create("motionBlurType", "motionBlurType", 0, &stat); stat = eAttr.addField( "Center", 0 ); stat = eAttr.addField( "FrameStart", 1 ); stat = eAttr.addField( "FrameEnd", 2 ); CHECK_MSTATUS(addAttribute( motionBlurType )); doDof = nAttr.create("doDof", "doDof", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( doDof )); xftimesamples = nAttr.create("xftimesamples", "xftimesamples", MFnNumericData::kInt, 2); CHECK_MSTATUS(addAttribute(xftimesamples)); geotimesamples = nAttr.create("geotimesamples", "geotimesamples", MFnNumericData::kInt, 2); CHECK_MSTATUS(addAttribute(geotimesamples)); MString numCpu = getenv("NUMBER_OF_PROCESSORS"); int numberOfProcessors = numCpu.asInt(); threads = nAttr.create("threads", "threads", MFnNumericData::kInt, numberOfProcessors); nAttr.setMin(1); CHECK_MSTATUS(addAttribute( threads )); translatorVerbosity = eAttr.create("translatorVerbosity", "translatorVerbosity", 2, &stat); stat = eAttr.addField( "Info", 0 ); stat = eAttr.addField( "Error", 1 ); stat = eAttr.addField( "Warning", 2 ); stat = eAttr.addField( "Progress", 3 ); stat = eAttr.addField( "Debug", 4 ); stat = eAttr.addField( "None", 5 ); CHECK_MSTATUS(addAttribute( translatorVerbosity )); rendererVerbosity = nAttr.create("rendererVerbosity", "rendererVerbosity", MFnNumericData::kInt, 2); CHECK_MSTATUS(addAttribute( rendererVerbosity )); detectShapeDeform = nAttr.create("detectShapeDeform", "detectShapeDeform", MFnNumericData::kBoolean, true); CHECK_MSTATUS(addAttribute( detectShapeDeform )); filtersize = nAttr.create("filtersize", "filtersize", MFnNumericData::kInt, 3); CHECK_MSTATUS(addAttribute( filtersize )); tilesize = nAttr.create("tilesize", "tilesize", MFnNumericData::kInt, 64); CHECK_MSTATUS(addAttribute( tilesize )); basePath = tAttr.create("basePath", "basePath", MFnNumericData::kString); CHECK_MSTATUS(addAttribute( basePath )); imagePath = tAttr.create("imagePath", "imagePath", MFnNumericData::kString); CHECK_MSTATUS(addAttribute( imagePath )); imageName = tAttr.create("imageName", "imageName", MFnNumericData::kString); CHECK_MSTATUS(addAttribute( imageName )); gamma = nAttr.create("gamma", "gamma", MFnNumericData::kFloat, 1.0f); CHECK_MSTATUS(addAttribute( gamma )); maxTraceDepth = nAttr.create("maxTraceDepth", "maxTraceDepth", MFnNumericData::kInt, 4); CHECK_MSTATUS(addAttribute( maxTraceDepth )); sunLightConnection = mAttr.create("sunLightConnection", "sunLightConnection"); CHECK_MSTATUS(addAttribute( sunLightConnection )); adaptiveSampling = nAttr.create("adaptiveSampling", "adaptiveSampling", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( adaptiveSampling )); optimizedTexturePath = tAttr.create("optimizedTexturePath", "optimizedTexturePath", MFnNumericData::kString); tAttr.setUsedAsFilename(true); CHECK_MSTATUS(addAttribute( optimizedTexturePath )); useOptimizedTextures = nAttr.create("useOptimizedTextures", "useOptimizedTextures", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( useOptimizedTextures )); exrDataTypeHalf = nAttr.create("exrDataTypeHalf", "exrDataTypeHalf", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute(exrDataTypeHalf)); exrMergeChannels = nAttr.create("exrMergeChannels", "exrMergeChannels", MFnNumericData::kBoolean, true); CHECK_MSTATUS(addAttribute(exrMergeChannels)); return MStatus::kSuccess; }