/* override */ MStatus offset::accessoryNodeSetup(MDagModifier& cmd) // // Description: // This method is called when the deformer is created by the // "deformer" command. You can add to the cmds in the MDagModifier // cmd in order to hook up any additional nodes that your node needs // to operate. // // In this example, we create a locator and attach its matrix attribute // to the matrix input on the offset node. The locator is used to // set the direction and scale of the random field. // // Description: // This method is optional. // { MStatus result; // hook up the accessory node // MObject objLoc = cmd.createNode(MString("locator"), MObject::kNullObj, &result); if (MS::kSuccess == result) { MFnDependencyNode fnLoc(objLoc); MString attrName; attrName.set("matrix"); MObject attrMat = fnLoc.attribute(attrName); result = cmd.connect(objLoc,attrMat,this->thisMObject(),offset::offsetMatrix); } return result; }
MStatus ClassParameterHandler::storeClass( IECore::ConstParameterPtr parameter, MPlug &plug ) { IECorePython::ScopedGILLock gilLock; try { boost::python::object pythonParameter( IECore::constPointerCast<IECore::Parameter>( parameter ) ); boost::python::object classInfo = pythonParameter.attr( "getClass" )( true ); std::string className = boost::python::extract<std::string>( classInfo[1] ); int classVersion = boost::python::extract<int>( classInfo[2] ); std::string searchPathEnvVar = boost::python::extract<std::string>( classInfo[3] ); MString storedClassName; int storedClassVersion; MString storedSearchPathEnvVar; currentClass( plug, storedClassName, storedClassVersion, storedSearchPathEnvVar ); // only set the plug values if the new value is genuinely different, as otherwise // we end up generating unwanted reference edits. if ( storedClassName != className.c_str() || storedClassVersion != classVersion || storedSearchPathEnvVar != searchPathEnvVar.c_str() ) { MStringArray updatedClassInfo; updatedClassInfo.append( className.c_str() ); MString classVersionStr; classVersionStr.set( classVersion, 0 ); updatedClassInfo.append( classVersionStr ); updatedClassInfo.append( searchPathEnvVar.c_str() ); MObject attribute = plug.attribute(); MFnTypedAttribute fnTAttr( attribute ); if ( fnTAttr.attrType() == MFnData::kStringArray ) { MObject data = MFnStringArrayData().create( updatedClassInfo ); plug.setValue( data ); } else { // compatibility for the deprecated compound plug behaviour. keeping this code // so we can still read old scenes. creation of these plugs has been removed. /// \todo: find all such notes and remove the unnecessary code for Cortex 9. plug.child( 0 ).setString( className.c_str() ); plug.child( 1 ).setInt( classVersion ); plug.child( 2 ).setString( searchPathEnvVar.c_str() ); } } } catch( boost::python::error_already_set ) { PyErr_Print(); return MS::kFailure; } catch( const std::exception &e ) { MGlobal::displayError( MString( "ClassParameterHandler::setClass : " ) + e.what() ); return MS::kFailure; } return MS::kSuccess; }
MString vixo_hairCacheExport::getFileName(MString cacheFileName,int frame) { MString frameStr; frameStr.set(frame); if(frameStr.length()==1) frameStr="000"+frameStr; else if(frameStr.length()==2) frameStr="00"+frameStr; else if(frameStr.length()==3) frameStr="0"+frameStr; MString result=cacheFileName+"."+frameStr+".hcc"; return result; }
// Override setup and cleanup for this override // MStatus ViewRenderOverride::setup(const MString & destination) { MHWRender::MRenderer *theRenderer = MHWRender::MRenderer::theRenderer(); unsigned int width, height; theRenderer->outputTargetSize(width, height); MString panelName; panelName.set(destination.asChar()); for (int i = 0; i < renderOperations.size(); i++) { PluginTestOperationBase* base = dynamic_cast<PluginTestOperationBase*>(renderOperations[i]); base->panelName = panelName; } return MStatus::kSuccess; }
/* static */ void animUnitNames::setToShortName(const MAngle::Unit& unit, MString& name) // // Description: // Sets the string with the short text name of the angle unit. // { switch(unit) { case MAngle::kDegrees: name.set(kDegString); break; case MAngle::kRadians: name.set(kRadString); break; case MAngle::kAngMinutes: name.set(kMinString); break; case MAngle::kAngSeconds: name.set(kSecString); break; default: name.set(kUnknownAngularString); break; } }
/* static */ void animUnitNames::setToShortName(const MDistance::Unit& unit, MString& name) // // Description: // Sets the string with the short text name of the distance unit. // { switch(unit) { case MDistance::kInches: name.set(kInString); break; case MDistance::kFeet: name.set(kFtString); break; case MDistance::kYards: name.set(kYdString); break; case MDistance::kMiles: name.set(kMiString); break; case MDistance::kMillimeters: name.set(kMmString); break; case MDistance::kCentimeters: name.set(kCmString); break; case MDistance::kKilometers: name.set(kKmString); break; case MDistance::kMeters: name.set(kMString); break; default: name.set(kUnknownLinearString); break; } }
MString AlembicObject::GetUniqueName(const MString& in_Name) { Abc::OObject parent = GetParentObject(); bool unique = false; MString name = in_Name; unsigned int index = 0; while (!unique) { unique = true; for (size_t i = 0; i < parent.getNumChildren(); i++) { MString childName = parent.getChildHeader(i).getName().c_str(); if (childName == name) { index++; MString indexString; indexString.set((double)index); name = in_Name + indexString; unique = false; break; } } } return name; }
// An LEP file is an ascii whose first line contains the string <LEP>. // The read does not support comments, and assumes that the each // subsequent line of the file contains a valid MEL command that can // be executed via the "executeCommand" method of the MGlobal class. // MStatus LepTranslator::reader ( const MFileObject& file, const MString& options, MPxFileTranslator::FileAccessMode mode) { const MString fname = file.fullName(); MStatus rval(MS::kSuccess); const int maxLineSize = 1024; char buf[maxLineSize]; ifstream inputfile(fname.asChar(), ios::in); if (!inputfile) { // open failed cerr << fname << ": could not be opened for reading\n"; return MS::kFailure; } if (!inputfile.getline (buf, maxLineSize)) { cerr << "file " << fname << " contained no lines ... aborting\n"; return MS::kFailure; } if (0 != strncmp(buf, magic.asChar(), magic.length())) { cerr << "first line of file " << fname; cerr << " did not contain " << magic.asChar() << " ... aborting\n"; return MS::kFailure; } while (inputfile.getline (buf, maxLineSize)) { MString cmdString; cmdString.set(buf); if (!MGlobal::executeCommand(cmdString)) rval = MS::kFailure; } inputfile.close(); return rval; }
MStatus vixo_hairCacheExport::doIt(const MArgList& args) { MString vixoHairNode; int startFrame,endFrame; unsigned index; index=args.flagIndex("vhn","vixoHairNode"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,vixoHairNode); } index=args.flagIndex("sf","startFrame"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,startFrame); } index=args.flagIndex("ef","endFrame"); if(MArgList::kInvalidArgIndex!=index) { args.get(index+1,endFrame); } //get hairCacheFileName MSelectionList slist; MGlobal::getSelectionListByName(vixoHairNode,slist); MDagPath vixoHairNodeDag; slist.getDagPath(0,vixoHairNodeDag); vixoHairNodeDag.extendToShape(); MFnDagNode fnVixoHair(vixoHairNodeDag); MPlug plugCacheFileName=fnVixoHair.findPlug("hairCacheFileName"); MString cacheFileName=plugCacheFileName.asString(); //~get hairCacheFileName //get staticMesh MPlug plugStaticMesh=fnVixoHair.findPlug("staticInMesh"); MObject staticMeshObj=MFnMeshData(plugStaticMesh.asMObject()).object(); //~get staticMesh //build out dataBase MFnMesh fnStaticMesh(staticMeshObj); map<int,set<outInVertexRelationInfo>> outVertexDataBase; map<int,vector<outVIDCtrlInfo>> outVertexControlData; for(int i=0;i<fnStaticMesh.numVertices();i++) { set<outInVertexRelationInfo> temp; temp.clear(); outVertexDataBase.insert(pair<int,set<outInVertexRelationInfo>>(i,temp)); } //build out dataBase //get inCurveVID map<int,int> plugMapVID; map<int,int> VIDMapPlug; map<int,inVertexBasicInfo> inVIDMapInVertexDataBase; MPlug plugAllInCurve=fnVixoHair.findPlug("inCtrlCurveData"); MIntArray existIndex; plugAllInCurve.getExistingArrayAttributeIndices(existIndex); for(int i=0;i<existIndex.length();i++) { MPlugArray arr; plugAllInCurve.elementByLogicalIndex(existIndex[i]).connectedTo(arr,true,false); MFnDependencyNode fnHairSystem(arr[0].node()); MPlug inputHairs=fnHairSystem.findPlug("inputHair"); arr.clear(); inputHairs.elementByLogicalIndex(existIndex[i]).connectedTo(arr,true,false); MFnDependencyNode fnFolli(arr[0].node()); int vid=fnFolli.findPlug("vertexID").asInt(); plugMapVID.insert(pair<int,int>(existIndex[i],vid)); VIDMapPlug.insert(pair<int,int>(vid,existIndex[i])); initBasicStepInfo(vid,staticMeshObj,inVIDMapInVertexDataBase); } //~get inCurveVID //build in out relation map<int,inVertexBasicInfo>::iterator inDBIter; for(inDBIter=inVIDMapInVertexDataBase.begin();inDBIter!=inVIDMapInVertexDataBase.end();inDBIter++) { buileRelationBetweenInOut(inDBIter->first,inVIDMapInVertexDataBase,outVertexDataBase); } map<int,set<outInVertexRelationInfo>>::iterator outDBIter; for(outDBIter=outVertexDataBase.begin();outDBIter!=outVertexDataBase.end();outDBIter++) { sortControlOrder(outDBIter->first,outVertexDataBase,outVertexControlData); } //~build in out relation for(int i=startFrame;i<=endFrame;i++) { MString currentTime; currentTime.set(i); MGlobal::executeCommand("currentTime "+currentTime); MGlobal::executeCommand("dgeval "+vixoHairNode+".hiddenOutput"); //get dynamic mesh MPlug plugDynamicMesh=fnVixoHair.findPlug("dynamicInMesh"); MObject dynamicMeshObj=MFnMeshData(plugDynamicMesh.asMObject()).object(); //~get dynamic mesh //export cache //faceid triid vid position normal tangent vector<forExportHairCache> exportData; exportBasicData(dynamicMeshObj,exportData); //curve tangent //get in curve infos map<int,MVectorArray> inCurveShape; getInCurveInfo(plugMapVID,vixoHairNode,inCurveShape); //~get in curve infos vector<vec3> outCurveCacheData; vec3 init; init.x=0; init.y=0; init.z=0; outCurveCacheData.resize(fnStaticMesh.numVertices()*inCurveShape.begin()->second.length(),init); buildCache(inCurveShape.begin()->second.length(),dynamicMeshObj,outCurveCacheData,inCurveShape,outVertexControlData); //~export cache //write to file MString fileName=getFileName(cacheFileName,i); fstream fout(fileName.asChar(),ios_base::out|ios_base::binary); int triNumvertexNum[3]; triNumvertexNum[0]=exportData.size(); triNumvertexNum[1]=fnStaticMesh.numVertices(); triNumvertexNum[2]=inCurveShape.begin()->second.length(); fout.write((char*)triNumvertexNum,sizeof(int)*3); fout.write((char*)&exportData[0],sizeof(forExportHairCache)*exportData.size()); fout.write((char*)&outCurveCacheData[0],sizeof(vec3)*outCurveCacheData.size()); fout.flush(); fout.close(); /* MString fileNameDebug=fileName+".dbg"; fout.open(fileNameDebug.asChar(),ios_base::out); for(int i=0;i<outCurveCacheData.size();i++) { fout<<outCurveCacheData[i].x<<" "<<outCurveCacheData[i].y<<" "<<outCurveCacheData[i].z<<endl; } fout.flush(); fout.close(); */ //~write to file } return MS::kSuccess; }
void MGuiEditText::sendVariable(void) { if(getVariablePointer()) { switch(getVariableType()) { case M_VAR_BOOL: { bool * value = (bool *)getVariablePointer(); int i; sscanf(getText(), "%d", &i); if(i == 1) *value = true; else if(i == 0) *value = false; } break; case M_VAR_INT: { int * value = (int *)getVariablePointer(); int i; sscanf(getText(), "%d", &i); if(i == (*value)) return; *value = i; } break; case M_VAR_UINT: { unsigned int * value = (unsigned int *)getVariablePointer(); int i; sscanf(getText(), "%d", &i); if(i < 0) i = 0; if((unsigned int)i == (*value)) return; *value = (unsigned int)i; } break; case M_VAR_FLOAT: { float * value = (float *)getVariablePointer(); float f; sscanf(getText(), "%f", &f); if(f == (*value)) return; *value = f; } break; case M_VAR_STRING: { MString * value = (MString *)getVariablePointer(); value->set(getText()); } break; } unsigned int tSize = m_text.size(); if(getCharId() > tSize) setCharId(tSize); } // send on change gui event if(m_pointerEvent) { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_SEND_VARIABLE; m_pointerEvent(this, &guiEvent); } }
// Write method of the GE2.0 translator / file exporter MStatus ge2Translator::writer ( const MFileObject & fileObject, const MString & options, MPxFileTranslator::FileAccessMode mode) { char LTmpStr[MAXPATHLEN]; unsigned int i, LN; // const MString fname = fileObject.fullName (); MString extension; MString baseFileName; // Lets strip off the known extension of .grp if it is there. extension.set (".grp"); int extLocation = fileObject.name ().rindex ('.'); if ( (extLocation != -1) && // no '.' in name (extLocation != 0) && // name was ".grp" -- that's ok?? (fileObject.name ().substring (extLocation, fileObject.name ().length () - 1) == extension) ) { baseFileName = fileObject.name ().substring (0, extLocation - 1); } else { baseFileName = fileObject.name (); extension.clear (); } geWrapper.setBaseFileName( baseFileName ); geWrapper.setPathName( fileObject.fullName() ); geWrapper.pluginVersion = version; // Set the directory at the Dt level strncpy( LTmpStr, geWrapper.getPathName().asChar(), MAXPATHLEN ); LN = (int)strlen( LTmpStr ); if ( LTmpStr[LN - 1] == '/' ) LTmpStr[LN - 1] = '\0'; DtSetDirectory( LTmpStr ); // in an ideal world, everything in setDefaults() should be overridden // with the option parsing. If the mel script doesn't get run for whatever // reason, or neglects to return some values, hopefully setDefaults will // enable the export to go through anyway geWrapper.setDefaults(); // Turn off this pesky warning on NT - performance warning // for int -> bool conversion. #ifdef WIN32 #pragma warning ( disable : 4800 ) #endif // Lets now do all of the option processing if ( options.length () > 0 ) { //Start parsing. MStringArray optionList; MStringArray theOption; options.split(';', optionList); //break out all the options. for ( i = 0; i < optionList.length (); ++i ) { theOption.clear (); optionList[i].split( '=', theOption ); if ( theOption.length () > 1 ) { if ( theOption[0] == MString( "enableAnim" ) ) { geWrapper.enableAnim = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animStart" ) ) { geWrapper.frameStart = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animEnd" ) ) { geWrapper.frameEnd = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animStep" ) ) { geWrapper.frameStep = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animVertices" ) ) { geWrapper.animVertices = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animDisplacement" ) ) { if ( theOption[1].asInt() == 1 ) geWrapper.vertexDisplacement = ge2Wrapper::kVDRelative; else geWrapper.vertexDisplacement = ge2Wrapper::kVDAbsolute; } else if ( theOption[0] == MString( "animTransforms" ) ) { geWrapper.animTransforms = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animShaders" ) ) { geWrapper.animShaders = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animLights" ) ) { geWrapper.animLights = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "animCamera" ) ) { geWrapper.animCamera = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "keyCurves" ) ) { geWrapper.keyCurves = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "keySample" ) ) { geWrapper.keySample = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "sampRate" ) ) { geWrapper.sampleRate = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "sampTol" ) ) { geWrapper.sampleTolerance = (float) ( theOption[1].asFloat() ); } else if ( theOption[0] == MString( "useGL" ) ) { geWrapper.useDomainGL = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "usePSX" ) ) { geWrapper.useDomainPSX = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "useN64" ) ) { geWrapper.useDomainN64 = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "useCustom" ) ) { geWrapper.useDomainCustom = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "hrcType" ) ) { geWrapper.hrcMode = static_cast <ge2Wrapper::GEHrcMode> ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportSel" ) ) { geWrapper.selType = static_cast <ge2Wrapper::GESelType> ( theOption[1].asInt() ); if ( (mode == MPxFileTranslator::kExportActiveAccessMode) && (geWrapper.selType == ge2Wrapper::kSelAll) ) { geWrapper.selType = ge2Wrapper::kSelActive; } } else if ( theOption[0] == MString( "exportLights" ) ) { geWrapper.outputLights = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportCamera" ) ) { geWrapper.outputCamera = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportJoints" ) ) { geWrapper.outputJoints = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportNormals" ) ) { geWrapper.outputNormals = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "opposite" ) ) { geWrapper.oppositeNormals = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportGeometry" ) ) { geWrapper.outputGeometry = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "reverse" ) ) { geWrapper.reverseWinding = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "exportTextures" ) ) { geWrapper.outputTextures = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "tesselation" ) ) { if ( theOption[1].asInt() == 2 ) DtExt_setTesselate( kTESSQUAD ); else DtExt_setTesselate( kTESSTRI ); } else if ( theOption[0] == MString( "texsample" ) ) { geWrapper.sampleTextures = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "texevaluate" ) ) { geWrapper.evalTextures = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "texOriginal" ) ) { geWrapper.useOriginalFileTextures = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "Xtexres" ) ) { geWrapper.xTexRes = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "Ytexres" ) ) { geWrapper.yTexRes = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "MaxXtexres" ) ) { geWrapper.xMaxTexRes = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "MaxYtexres" ) ) { geWrapper.yMaxTexRes = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "texType" ) ) { geWrapper.texType = theOption[1]; } else if ( theOption[0] == MString( "precision" ) ) { geWrapper.precision = (int) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "format" ) ) { geWrapper.useTabs = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "comments" ) ) { geWrapper.writeComments = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "verboseGeom" ) ) { geWrapper.verboseGeom = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "verboseLgt" ) ) { geWrapper.verboseLgt = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "verboseCam" ) ) { geWrapper.verboseCam = (bool) ( theOption[1].asInt() ); } else if ( theOption[0] == MString( "script" ) ) { geWrapper.userScript = theOption[1]; } else if ( theOption[0] == MString( "scriptAppend" ) ) { geWrapper.scriptAppendFileName = (int) ( theOption[1].asInt() ); } } } } #ifdef WIN32 #pragma warning ( default : 4800 ) #endif geWrapper.initScene(); // do some initialization geWrapper.writeScene(); // write it to the appropriate files geWrapper.killScene(); // clean-up return MS::kSuccess; }
/* static */ void animUnitNames::setToLongName(const MTime::Unit &unit, MString &name) // // Description: // Sets the string with the long text name of the time unit. // { switch(unit) { case MTime::kHours: name.set(kHourTString); break; case MTime::kMinutes: name.set(kMinTString); break; case MTime::kSeconds: name.set(kSecTString); break; case MTime::kMilliseconds: name.set(kMillisecTString); break; case MTime::kGames: name.set(kGameTString); break; case MTime::kFilm: name.set(kFileTString); break; case MTime::kPALFrame: name.set(kPalTString); break; case MTime::kNTSCFrame: name.set(kNtscTString); break; case MTime::kShowScan: name.set(kShowTString); break; case MTime::kPALField: name.set(kPalFTString); break; case MTime::kNTSCField: name.set(kNtscFTString); break; default: name.set(kUnknownTimeString); break; } }
MStatus rtgTranslator::writer ( const MFileObject & fileObject, const MString & options, MPxFileTranslator::FileAccessMode mode) { char LTmpStr[MAXPATHLEN]; unsigned int i; int LN; const MString fname = fileObject.fullName (); MString extension; MString baseFileName; int TimeSlider = 0; int AnimEnabled = 0; // Lets strip off the known extension of .rtg if it is there. extension.set (".rtg"); int extLocation = fileObject.name ().rindex ('.'); if (extLocation > 0 && fileObject.name ().substring (extLocation, fileObject.name ().length () - 1) == extension) { baseFileName = fileObject.name ().substring (0, extLocation - 1); } else { baseFileName = fileObject.name (); extension.clear (); } DtExt_SceneInit( (char *)baseFileName.asChar() ); // Lets now do all of the option processing if (options.length () > 0) { //Start parsing. MStringArray optionList; MStringArray theOption; options.split (';', optionList); //break out all the options. for ( i = 0; i < optionList.length (); ++i) { theOption.clear (); optionList[i].split ('=', theOption); if (theOption.length () > 1) { if (theOption[0] == MString ("v18compatible")) { rtg_v18_compatible = (int) (theOption[1].asInt() ); } else if (theOption[0] == MString ("timeslider")) { TimeSlider = (int) (theOption[1].asInt ()); } else if (theOption[0] == MString ("animEnabled")) { AnimEnabled = (int) (theOption[1].asInt ()); } else if (theOption[0] == MString ("animStart")) { DtFrameSetStart( (int) (theOption[1].asInt ()) ); } else if (theOption[0] == MString ("animEnd")) { DtFrameSetEnd( (int) (theOption[1].asInt ()) ); } else if (theOption[0] == MString ("animStep")) { DtFrameSetBy( (int) (theOption[1].asInt ()) ); } else if (theOption[0] == MString ("hrcType")) { switch ( theOption[1].asInt () - 1) { case VRHRC_FLAT: DtExt_setOutputTransforms (kTRANSFORMMINIMAL); DtExt_setParents (0); break; case VRHRC_WORLD: DtExt_setOutputTransforms (kTRANSFORMNONE); DtExt_setParents (0); break; case VRHRC_FULL: default: DtExt_setOutputTransforms (kTRANSFORMALL); DtExt_setParents (1); break; } } else if (theOption[0] == MString ("joints")) { // Allow user to specify if the hierarchy should include // NULL geometry nodes - usually joints DtExt_setJointHierarchy( theOption[1].asInt() ); } else if (theOption[0] == MString ("exportSel")) { switch ( theOption[1].asInt () - 1) { case VRSEL_ALL: DtExt_setWalkMode (ALL_Nodes); break; case VRSEL_ACTIVE: DtExt_setWalkMode (ACTIVE_Nodes); break; case VRSEL_PICKED: DtExt_setWalkMode (PICKED_Nodes); break; } } else if (theOption[0] == MString ("texsample")) { // Allow user to specify if the textures should be sampled // with the Texture Placement options DtExt_setSoftTextures ( theOption[1].asInt() ); } else if (theOption[0] == MString ("texevaluate")) { // Allow the user to specify if the tex should be eval with // convertSolidTx command or read in if is a file texture. DtExt_setInlineTextures( theOption[1].asInt() ); } else if (theOption[0] == MString ("texoriginal")) { // Allow the user to specify if the tex should be eval at all. DtExt_setOriginalTexture( theOption[1].asInt() ); } else if (theOption[0] == MString ("Xtexres")) { // Set the X size of the texture swatches to use DtExt_setXTextureRes ( theOption[1].asInt () ); } else if (theOption[0] == MString ("Ytexres")) { // Set the Y size of the texture swatches to use DtExt_setYTextureRes ( theOption[1].asInt () ); } else if (theOption[0] == MString ("MaxXtexres")) { // Set the Max X size of the texture swatches to use DtExt_setMaxXTextureRes( theOption[1].asInt () ); } else if (theOption[0] == MString ("MaxYtexres")) { // Set the Max Y size of the texture swatches to use DtExt_setMaxYTextureRes( theOption[1].asInt () ); } else if (theOption[0] == MString ("precision")) { //VR_Precision = theOption[1].asInt (); } else if (theOption[0] == MString ("verbose")) { // DtExt_setDebug ( theOption[1].asInt () ); } else if (theOption[0] == MString ("debug")) { int levelG = DtExt_Debug(); if ( (int) (theOption[1].asInt () ) ) levelG |= DEBUG_GEOMAT; else levelG &= ~DEBUG_GEOMAT; DtExt_setDebug( levelG ); } else if (theOption[0] == MString ("debugC")) { int levelC = DtExt_Debug(); if ( (int) (theOption[1].asInt () ) ) levelC |= DEBUG_CAMERA; else levelC &= ~DEBUG_CAMERA; DtExt_setDebug( levelC ); } else if (theOption[0] == MString ("debugL")) { int levelL = DtExt_Debug(); if ( (int) (theOption[1].asInt () ) ) levelL |= DEBUG_LIGHT; else levelL &= ~DEBUG_LIGHT; DtExt_setDebug( levelL ); } else if (theOption[0] == MString ("reversed")) { DtExt_setWinding( theOption[1].asInt() ); } else if (theOption[0] == MString ("tesselation")) { if ( theOption[1].asInt() == 2 ) { DtExt_setTesselate( kTESSQUAD ); } else { DtExt_setTesselate( kTESSTRI ); } // // Now come the translator specific options // } else if (theOption[0] == MString ("imageformat")) { rtg_output_image_format = theOption[1].asInt(); } else if (theOption[0] == MString ("fileformat")) { rtg_output_file_format = theOption[1].asInt(); } else if (theOption[0] == MString ("vnormals")) { rtg_output_vert_norms = theOption[1].asInt(); } else if (theOption[0] == MString ("vcolors")) { rtg_output_vert_colors = theOption[1].asInt(); } else if (theOption[0] == MString ("tcoords")) { rtg_output_tex_coords = theOption[1].asInt(); } else if (theOption[0] == MString ("pnormals")) { rtg_output_poly_norms = theOption[1].asInt(); } else if (theOption[0] == MString ("idxcnt")) { rtg_show_index_counters = theOption[1].asInt(); } else if (theOption[0] == MString ("anglesdeg")) { rtg_output_degrees = theOption[1].asInt(); } else if (theOption[0] == MString ("materials")) { rtg_output_materials = theOption[1].asInt(); } else if (theOption[0] == MString ("multitexture")) { DtExt_setMultiTexture( theOption[1].asInt() ); } else if (theOption[0] == MString ("mdecomp")) { rtg_output_decomp = theOption[1].asInt(); } else if (theOption[0] == MString ("pivoth")) { rtg_output_pivots = theOption[1].asInt(); } else if (theOption[0] == MString ("transforms")) { rtg_output_transforms = theOption[1].asInt(); } else if (theOption[0] == MString ("ltransforms")) { rtg_output_local = theOption[1].asInt(); } else if (theOption[0] == MString ("animation")) { rtg_output_animation = theOption[1].asInt(); } else if (theOption[0] == MString ("allnodes")) { rtg_output_all_nodes = theOption[1].asInt(); } else if (theOption[0] == MString ("script")) { scriptToRun = theOption[1]; } else if (theOption[0] == MString ("scriptAppend")) { scriptAppend = (int)(theOption[1].asInt() ); } } } } // Lets see how we entered this plug-in, either with the export all // or export selection flag set. if ( mode == MPxFileTranslator::kExportActiveAccessMode ) { DtExt_setWalkMode ( ACTIVE_Nodes ); } // Lets check the TimeSlider control now: if ( TimeSlider ) { MTime start( MAnimControl::minTime().value(), MTime::uiUnit() ); DtFrameSetStart( (int) start.value() ); MTime end( MAnimControl::maxTime().value(), MTime::uiUnit() ); DtFrameSetEnd( (int) end.value() ); } // Now see if the animation is really enabled. // Else we will set the end frame to the beginning frame automatically if ( !AnimEnabled ) { DtFrameSetEnd( DtFrameGetStart() ); } // Find out where the file is supposed to end up. MDt_GetPathName ((char *) (fname.asChar ()), LTmpStr, MAXPATHLEN); LN = (int)strlen (LTmpStr); if (LTmpStr[LN - 1] == '/') LTmpStr[LN - 1] = '\0'; DtSetDirectory (LTmpStr); // Now lets setup some paths to do basic texture file searching // for those textures with relative paths MStringArray wSpacePaths; MStringArray rPaths; MString usePath; MString separator; MGlobal::executeCommand( "workspace -q -rd", wSpacePaths ); MGlobal::executeCommand( "workspace -q -rtl", rPaths ); if ( DtExt_getTextureSearchPath() ) separator.set( "|" ); else separator.set( "" ); for (i = 0; i < wSpacePaths.length (); ++i) { for ( unsigned int j = 0; j < rPaths.length(); j++ ) { usePath = usePath + separator + wSpacePaths[i] + MString( "/" ) + rPaths[j]; separator.set( "|" ); if ( rPaths[j] == MString( "sourceImages" ) ) usePath = usePath + separator + wSpacePaths[i] + MString( "/" ) + MString( "sourceimages" ); } } DtExt_addTextureSearchPath( (char *)usePath.asChar() ); // Now we can setup the database from the wire file geometry. // This is where all the Maya data are retrieved, cached, and processed. // // Say that we want to have camera info DtExt_setOutputCameras( 1 ); //Now we can setup the database from the wire file geometry DtExt_dbInit(); DtFrameSet( DtFrameGetStart() ); // Now do the export rtgExport(); // Now lets see if the user wants something else to be done if ( 0 < scriptToRun.length() ) { if ( scriptAppend ) { scriptToRun += MString( " " ) + MString( LTmpStr ); } system( scriptToRun.asChar() ); } // Clean house. // DtExt_CleanUp(); return MS::kSuccess; }
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 }
void HairToolContext::getClassName(MString& name) const{ name.set("overcoatHairTool"); }
void SGToolContext::getClassName(MString& name) const { name.set("SGMToolMod01Context"); }
MStatus stringFormat::compute (const MPlug& plug, MDataBlock& data) { MStatus status; // Check that the requested recompute is one of the output values // if (plug == attrOutput) { // Read the input values // MDataHandle inputData = data.inputValue (attrFormat, &status); CHECK_MSTATUS( status ); MString format = inputData.asString(); // Get input data handle, use outputArrayValue since we do not // want to evaluate all inputs, only the ones related to the // requested multiIndex. This is for efficiency reasons. // MArrayDataHandle vals = data.outputArrayValue(attrValues, &status); CHECK_MSTATUS( status ); int indx = 0; int param; char letter; while ((indx = findNextMatch(format, indx, param, letter)) > 0) { double val = 0.; status = vals.jumpToElement(param); if (status == MStatus::kSuccess) { MDataHandle thisVal = vals.inputValue( &status ); if (status == MStatus::kSuccess) { val = thisVal.asDouble(); } } MString replace; bool valid = false; switch (letter) { case 'd': // Integer val = floor(val+.5); // No break here case 'f': // Float replace.set(val); valid = true; break; case 't': // Timecode { const char * sign = ""; if (val<0) { sign = "-"; val = -val; } int valInt = (int)(val+.5); int sec = valInt / 24; int frame = valInt - sec * 24; int min = sec / 60; sec -= min * 60; int hour = min / 60; min -= hour * 60; char buffer[90]; if (hour>0) sprintf(buffer, "%s%d:%02d:%02d.%02d", sign, hour, min, sec, frame); else sprintf(buffer, "%s%02d:%02d.%02d", sign, min, sec, frame); replace = buffer; } valid = true; break; } if (valid) { format = format.substring(0, indx-2) + replace + format.substring(indx+2, format.length()-1); indx += replace.length() - 3; } } // Store the result // MDataHandle output = data.outputValue(attrOutput, &status ); CHECK_MSTATUS( status ); output.set( format ); } else { return MS::kUnknownParameter; } return MS::kSuccess; }
void grabUVContext::getClassName( MString & name ) const { name.set("grabUV"); }