void cgfxGetFxIncludePath( const MString &fxFile, MStringArray &pathOptions ) { // Append the path of the cgfx file as a possible include search path // MString option; if (fxFile.length()) { MFileObject fobject; fobject.setRawFullName( fxFile ); option = MString("-I") + fobject.resolvedPath(); pathOptions.append( option ); } // Add in "standard" cgfx search for cgfx files as a possible include // search path // char * cgfxRoot = getenv("CGFX_ROOT"); if (cgfxRoot) { option = MString("-I") + MString(cgfxRoot); pathOptions.append( option ); option = MString("-I") + MString(cgfxRoot) + MString("/CgFX"); pathOptions.append( option ); } // Add in Maya's Cg directory char * mayaLocation = getenv("MAYA_LOCATION"); if (mayaLocation) { MString mayaCgLocation(MString(mayaLocation) + MString("/bin/Cg/")); option = MString("-I") + mayaCgLocation; pathOptions.append( option ); } }
// returns the list of files to archive. MStringArray AlembicNode::getFilesToArchive( bool /* shortName */, bool unresolvedName, bool /* markCouldBeImageSequence */) const { MStringArray files; MStatus status = MS::kSuccess; MPlug layerFilenamesPlug(thisMObject(), mAbcLayerFileNamesAttr); MFnStringArrayData fnSAD( layerFilenamesPlug.asMObject() ); MStringArray layerFilenames = fnSAD.array(); for( unsigned int i = 0; i < layerFilenames.length(); i++ ) { MString fileName = layerFilenames[i]; if (status == MS::kSuccess && fileName.length() > 0) { if(unresolvedName) { files.append(fileName); } else { //unresolvedName is false, resolve the path via MFileObject. MFileObject fileObject; fileObject.setRawFullName(fileName); files.append(fileObject.resolvedFullName()); } } } return files; }
virtual bool getSourceStreams(const MObject& object, MStringArray &sourceStreams) const { sourceStreams.append( "Position" ); sourceStreams.append( "Normal" ); return true; }
// returns the list of files to archive. MStringArray AlembicNode::getFilesToArchive( bool /* shortName */, bool unresolvedName, bool /* markCouldBeImageSequence */) const { MStringArray files; MStatus status = MS::kSuccess; MPlug fileNamePlug(thisMObject(), mAbcFileNameAttr); MString fileName = fileNamePlug.asString(MDGContext::fsNormal, &status); if (status == MS::kSuccess && fileName.length() > 0) { if(unresolvedName) { files.append(fileName); } else { //unresolvedName is false, resolve the path via MFileObject. MFileObject fileObject; fileObject.setRawFullName(fileName); files.append(fileObject.resolvedFullName()); } } return files; }
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; }
void CUniformParameterBuilder::logUnrecognisedSemantic(const char* pSemantic) { MStringArray args; args.append(pSemantic); args.append(mDesc.Name); mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kUnknowSemantic, args ); }
void CUniformParameterBuilder::logUnsupportedTypeWarning(const MStringResourceId& typeId) { MString typeStr = dx11ShaderStrings::getString( typeId ); MStringArray args; args.append(typeStr); args.append(mDesc.Name); mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kUnsupportedType, args ); }
void ParameterisedHolderModificationCmd::restoreClassParameterStates( const IECore::CompoundData *classes, IECore::Parameter *parameter, const std::string &parentParameterPath ) { std::string parameterPath = parentParameterPath; if( parentParameterPath.size() ) { parameterPath += "."; } parameterPath += parameter->name(); if( parameter->isInstanceOf( "ClassParameter" ) ) { const CompoundData *c = classes->member<const CompoundData>( parameterPath ); if( c ) { ClassParameterHandler::setClass( parameter, c->member<const IECore::StringData>( "className" )->readable().c_str(), c->member<const IECore::IntData>( "classVersion" )->readable(), c->member<const IECore::StringData>( "searchPathEnvVar" )->readable().c_str() ); } } else if( parameter->isInstanceOf( "ClassVectorParameter" ) ) { const CompoundData *c = classes->member<const CompoundData>( parameterPath ); if( c ) { IECore::ConstStringVectorDataPtr parameterNames = c->member<const IECore::StringVectorData>( "parameterNames" ); IECore::ConstStringVectorDataPtr classNames = c->member<const IECore::StringVectorData>( "classNames" ); IECore::ConstIntVectorDataPtr classVersions = c->member<const IECore::IntVectorData>( "classVersions" ); MStringArray mParameterNames; MStringArray mClassNames; MIntArray mClassVersions; int numClasses = parameterNames->readable().size(); for( int i=0; i<numClasses; i++ ) { mParameterNames.append( parameterNames->readable()[i].c_str() ); mClassNames.append( classNames->readable()[i].c_str() ); mClassVersions.append( classVersions->readable()[i] ); } ClassVectorParameterHandler::setClasses( parameter, mParameterNames, mClassNames, mClassVersions ); } } if( parameter->isInstanceOf( IECore::CompoundParameter::staticTypeId() ) ) { CompoundParameter *compoundParameter = static_cast<CompoundParameter *>( parameter ); const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters(); for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ ) { restoreClassParameterStates( classes, it->get(), parameterPath ); } } }
//read out the animation layers from the animReader //then create any missing layers and add them to the active selection bool atomAnimLayers::readAnimLayers(ifstream &readAnim, char *dataType,atomReader &reader) { if (strcmp(dataType, kAnimLayers) == 0) { dataType = reader.asWord(readAnim); if (strcmp(dataType, "{") == 0) { MStringArray layerNames; while((dataType = reader.asWord(readAnim))) { if(readAnim && ! readAnim.eof() && dataType && strcmp(dataType, "}") !=0) { MString name(dataType); layerNames.append(name); } else break; } if(layerNames.length() >0) { createMissingAnimLayers(layerNames); addAnimLayersToSelection(); } } return true; } return false; }
MString AppleseedRenderer::getTextureColorProfile(MFnDependencyNode& fileTextureNode) { MString colorProfileName; int profileId = 0; getEnum(MString("colorProfile"), fileTextureNode, profileId); logger.debug(MString("Color profile from fileNode: ") + profileId); MStringArray colorProfiles; colorProfiles.append("srgb"); //0 == none == default == sRGB colorProfiles.append("srgb"); //1 == undefined == default == sRGB colorProfiles.append("linear_rgb"); //2 == linear_rgb colorProfiles.append("srgb"); //3 == sRGB colorProfiles.append("linear_rgb"); //4 == linear_rec_709 colorProfiles.append("linear_rgb"); //5 == hdtv_rec_709 return colorProfiles[profileId]; }
//----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- MStatus CVsSkinnerCmd::DoLs() { MSelectionList tmpList; if ( m_undo.ArgDatabase().isFlagSet( kOptSelected ) ) { MSelectionList skinnerNodes; m_undo.ArgDatabase().getObjects( skinnerNodes ); GetSpecifiedSkinnerNodes( skinnerNodes, tmpList ); } else { MDagPath eDagPath; FindSkinnerNodesInHierarchy( eDagPath, tmpList ); } const bool longPath( m_undo.ArgDatabase().isFlagSet( kOptLong ) ); MStringArray result; MDagPath mDagPath; for ( MItSelectionList sIt( tmpList ); !sIt.isDone(); sIt.next() ) { if ( sIt.getDagPath( mDagPath ) ) { result.append( longPath ? mDagPath.fullPathName() : mDagPath.partialPathName() ); } } setResult( result ); return MS::kSuccess; }
void maTranslator::getSetAttrCmds(const MObject& node, MStringArray& cmds) { // // Get rid of any garbage already in the array. // cmds.clear(); // // Run through the node's attributes. // MFnDependencyNode nodeFn(node); unsigned int numAttrs = nodeFn.attributeCount(); unsigned int i; for (i = 0; i < numAttrs; i++) { // // Use the attribute ordering which Maya uses when doing I/O. // MObject attr = nodeFn.reorderedAttribute(i); MFnAttribute attrFn(attr); MStatus status; attrFn.parent(&status); bool isChild = (status != MS::kNotFound); // // We don't want attributes which are children of other attributes // because they will be processed when we process the parent. // // And we only want storable attributes which accept inputs. // if (!isChild && attrFn.isStorable() && attrFn.isWritable()) { // // Get a plug for the attribute. // MPlug plug(node, attr); // // Get setAttr commands for this attribute, and any of its // children, which have had their values changed by the scene. // MStringArray newCmds; plug.getSetAttrCmds(newCmds, MPlug::kChanged, false); unsigned int numCommands = newCmds.length(); unsigned int c; for (c = 0; c < numCommands; c++) { if (newCmds[c] != "") cmds.append(newCmds[c]); } } } }
MStatus loadPlugin::doIt(const MArgList &args) { MStatus stat=MStatus::kSuccess; MString getMayaLocation("getenv MAYA_LOCATION"); MString locationPath; MGlobal::executeCommand(getMayaLocation,locationPath); MStringArray extraDlls; extraDlls.append("libpng14d"); extraDlls.append("libtiff3"); extraDlls.append("libxml2"); extraDlls.append("yafaraycore"); extraDlls.append("yafarayqt"); extraDlls.append("yafarayplugin"); extraDlls.append("zlib"); MString pathAdded("/bin"); MString suffix(".dll"); for(unsigned int i=0; i<extraDlls.length();i++) { MString dll=locationPath+pathAdded+extraDlls[i]+suffix; cout<<"loading dll "<<extraDlls[i]<<".dll"; LoadLibrary(dll.asChar()); cout<<"........................succeeded!"<<endl; } MString yafPath("/bin/plug-ins/yafaray"); MString yafDll=locationPath+yafPath; yafrayInterface_t * yafLoad=renderScene::getyI(); yafLoad->loadPlugins(yafDll.asChar()); MGlobal::displayInfo("load yafaray components succeeded!"); return stat; }
MDoubleArray boingRbCmd::getBulletVectorAttribute(MString &name, MString &attr) { MVector vec; MDoubleArray result; shared_ptr<bSolverNode> b_solv = bSolverNode::get_bsolver_node(); MStringArray nodes; if (name == "*") { nodes = b_solv->get_all_keys(); } else { nodes.append(name); } //std::cout<<"nodes : "<<nodes<<std::endl; //std::cout<<"nodes.length() : "<<nodes.length()<<std::endl; for (int i=0; i<nodes.length(); i++) { std::cout<<"trying to get rb...."<<std::endl; rigid_body_t::pointer rb = b_solv->getdata(nodes[i])->m_rigid_body; std::cout<<"got rb : "<<b_solv->getdata(nodes[i])->name<<std::endl; //rigid_body_t::pointer rb = getPointerFromName(name); if (rb != 0) { float mass = rb->get_mass(); bool active = (mass>0.f); if(active) { if (attr=="velocity") { vec3f vel; rb->get_linear_velocity(vel); vec = MVector((double)vel[0], (double)vel[1], (double)vel[2]); } else if (attr=="position") { vec3f pos; quatf rot; rb->get_transform(pos, rot); vec = MVector((double)pos[0], (double)pos[1], (double)pos[2]); } else if (attr=="angularVelocity") { vec3f av; rb->get_angular_velocity(av); vec = MVector((double)av[0], (double)av[1], (double)av[2]); } /*else { boing *b = static_cast<boing*>( rb->impl()->body()->getUserPointer() ); MString vecStr = b->get_data(attr); MStringArray vecArray = parseArguments(vecStr, ","); vec = MVector(vecArray[0].asDouble(), vecArray[1].asDouble(), vecArray[2].asDouble()); }*/ } } for (int j=0; j<3; j++) { //std::cout<<"vec["<<j<<"] : "<<vec[j]<<std::endl; result.append(vec[j]); } } return result; }
MStatus initializePlugin( MObject obj ) { MFnPlugin plugin( obj, "Ivan Shiskin <*****@*****.**>", "1.0", "Any" ); MStringArray extensions; extensions.append( "512" ); extensions.append( "1024"); extensions.append( "2048"); MStatus s = plugin.registerImageFile( "MetroImage", metro_image::creator, extensions); if (!s) { s.perror("registerImageFile"); return s; } s = plugin.registerFileTranslator( "Metro Model Translator", "", metro_model_translator::creator ); if (!s) { s.perror("registerFileTranslator"); return s; } s = plugin.registerFileTranslator( "Metro Mesh Translator", "", metro_mesh_translator::creator ); if (!s) { s.perror("registerFileTranslator"); return s; } s = plugin.registerFileTranslator( "Metro Level Translator", "", metro_level_translator::creator ); if (!s) { s.perror("registerFileTranslator"); return s; } return s; }
// // An effect // cgfxEffect::cgfxEffect(const MString& fileName, const cgfxProfile* profile) : refcount(0), fEffect(NULL), fTechniques(NULL), fProfile(NULL) { MStringArray fileOptions; cgfxGetFxIncludePath( fileName, fileOptions ); fileOptions.append("-DMAYA_CGFX=1"); if (cgfxProfile::getTexCoordOrientation() == cgfxProfile::TEXCOORD_OPENGL) { fileOptions.append("-DMAYA_TEXCOORD_ORIENTATION_OPENGL=1"); } else { fileOptions.append("-DMAYA_TEXCOORD_ORIENTATION_DIRECTX=1"); } const char *opts[_CGFX_PLUGIN_MAX_COMPILER_ARGS_]; unsigned int numOpts = fileOptions.length(); if (numOpts) { numOpts = (numOpts > _CGFX_PLUGIN_MAX_COMPILER_ARGS_-1) ? _CGFX_PLUGIN_MAX_COMPILER_ARGS_-1 : numOpts; for (unsigned int i=0; i<numOpts; i++) opts[i] = fileOptions[i].asChar(); opts[numOpts] = NULL; } fEffect = cgCreateEffectFromFile(cgfxShaderNode::sCgContext, fileName.asChar(), opts); if (fEffect) { CGtechnique technique = cgGetFirstTechnique(fEffect); cgfxTechnique** nextTechnique = const_cast<cgfxTechnique**>(&fTechniques); while (technique) { *nextTechnique = new cgfxTechnique(technique, profile); nextTechnique = &(*nextTechnique)->fNext; technique = cgGetNextTechnique(technique); } fProfile = profile; } }
MObject getOtherSideNode(const MString& plugName, MObject& thisObject, MStringArray& otherSidePlugNames) { MStatus stat; MObject result = MObject::kNullObj; MFnDependencyNode depFn(thisObject, &stat); if (stat != MStatus::kSuccess) return result; MPlug plug = depFn.findPlug(plugName, &stat); if (stat != MStatus::kSuccess)return result; if (!plug.isConnected()) { int numChildConnects = plug.numConnectedChildren(); if (numChildConnects == 0) return result; else { for (int i = 0; i < numChildConnects; i++) { MPlug child = plug.child(i); MString otherSidePlugName; MObject childObj = getOtherSideNode(child.partialName(false), thisObject, otherSidePlugName); if (childObj != MObject::kNullObj) { otherSidePlugNames.append(otherSidePlugName); result = childObj; } else otherSidePlugNames.append(MString("")); } } } else { MPlugArray plugArray; plug.connectedTo(plugArray, 1, 0, &stat); if (stat != MStatus::kSuccess) return result; if (plugArray.length() == 0) return result; MPlug otherSidePlug = plugArray[0]; result = otherSidePlug.node(); otherSidePlugNames.append(otherSidePlug.name()); } return result; }
MStringArray cgfxProfile::getProfileList() { MStringArray result; cgfxProfile* profile = sProfileList; while (profile) { result.append(profile->fName); profile = profile->fNext; } return result; }
//--------------------------------------------------- void DagHelper::getPlugValue ( const MPlug& plug, MStringArray& output, MStatus* status ) { MObject str_obj; plug.getValue ( str_obj ); MFnStringArrayData f_astr ( str_obj, status ); unsigned int len = f_astr.length(); for ( unsigned int i = 0; i < len; ++i ) { const MString& val = f_astr[i]; output.append ( val ); } }
// DESCRIPTION: ////////////////////////////////////////////////////////////////// MStatus initializePlugin( MObject obj ) { MFnPlugin plugin( obj, PLUGIN_COMPANY, "8.0", "Any" ); MStringArray extensions; extensions.append( "moo"); CHECK_MSTATUS( plugin.registerImageFile( kImagePluginName, SimpleImageFile::creator, extensions)); return MS::kSuccess; }
MStringArray boingRbCmd::parseArguments(MString arg, MString token) { MStringArray jobArgsArray; MString stringBuffer; for (unsigned int charIdx = 0; charIdx < arg.numChars(); charIdx++) { MString ch = arg.substringW(charIdx, charIdx); //cout<<"ch = "<<ch<<endl; if (ch == token ) { if (stringBuffer.length() > 0) { jobArgsArray.append(stringBuffer); //cout<<"jobArgsArray = "<<jobArgsArray<<endl; stringBuffer.clear(); } } else { stringBuffer += ch; //cout<<"stringBuffer = "<<stringBuffer<<endl; } } jobArgsArray.append(stringBuffer); return jobArgsArray; }
// // Convert a DX space into a Maya space // MUniformParameter::DataSemantic CUniformParameterBuilder::convertSpace( MUniformParameter::DataSemantic defaultSpace) { MUniformParameter::DataSemantic space = MUniformParameter::kSemanticUnknown; LPCSTR ann; if( getAnnotation( dx11ShaderAnnotation::kSpace, ann) && ann) { if( !_stricmp( ann, dx11ShaderAnnotationValue::kObject)) space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticObjectPos : MUniformParameter::kSemanticObjectDir; else if( !_stricmp( ann, dx11ShaderAnnotationValue::kWorld)) space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticWorldPos : MUniformParameter::kSemanticWorldDir; else if( !_stricmp( ann, dx11ShaderAnnotationValue::kView)) space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticViewPos : MUniformParameter::kSemanticViewDir; else if( !_stricmp( ann, dx11ShaderAnnotationValue::kCamera)) space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticViewPos : MUniformParameter::kSemanticViewDir; else { MStringArray args; args.append(ann); args.append(mDesc.Name); mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kUnknowSpace, args ); } } return space; }
void Visitor::addShaderMethodBody( const MString ¤tNode, const MStringArray& inputVars, const MStringArray& outputVars) { CM_TRACE_FUNC("Visitor::addShaderMethodBody("<<currentNode<<","<<inputVars<<","<<outputVars<<")"); MString varString; { MStringArray vars; for(std::size_t i=0; i<inputVars.length(); ++i){ vars.append( renderman::getVariableName(inputVars[i]) ); } for(std::size_t i=0; i<outputVars.length(); ++i){ vars.append( renderman::getVariableName(outputVars[i]) ); } for(std::size_t index=0; index<vars.length(); ++index){ varString += (index == vars.length() - 1)?(vars[index]):(vars[index]+", "); } } // Add the current node method to the shader body shaderData[ SHADER_METHOD_BODY_I ] += " //" + currentNode +"\n"; shaderData[ SHADER_METHOD_BODY_I ] += " " + renderman::getShaderName(currentNode) +"("+varString+");\n"; // test the input and output of currentNode { MString inputVarsStr; MString outputVarsStr; connectMStringArray(inputVarsStr, inputVars); connectMStringArray(outputVarsStr, outputVars); shaderData[ SHADER_METHOD_BODY_I ] += "//input: " + inputVarsStr +"\n"; shaderData[ SHADER_METHOD_BODY_I ] += "//output:" + outputVarsStr +"\n\n"; } }
//----------------------------------------------------------------------------------------- LPCSTR CXRayObjectExport::getMaterialName(MDagPath & mdagPath, int cid, int objectIdx) { MStatus stat; int i, length; MIntArray * currentMaterials = new MIntArray(); MStringArray mArray; for ( i=0; i<numSets; i++ ) { if ( lookup(mdagPath,i,cid) ) { MFnSet fnSet( (*sets)[i] ); if ( MFnSet::kRenderableOnly == fnSet.restriction(&stat) ) { currentMaterials->append( i ); mArray.append( fnSet.name() ); } } } // Test for equivalent materials // bool materialsEqual = false; if ((lastMaterials != NULL) && (lastMaterials->length() == currentMaterials->length())){ materialsEqual = true; length = lastMaterials->length(); for (i=0; i<length; i++){ if ((*lastMaterials)[i]!=(*currentMaterials)[i]){ materialsEqual = false; break; } } } if (!materialsEqual){ if (lastMaterials!=NULL) xr_delete(lastMaterials); lastMaterials = currentMaterials; int mLength = mArray.length(); if (mLength==0) xrDebug::Fatal(DEBUG_INFO,"Object '%s' has polygon '%d' without material.",0,cid); if (mLength>1){ xrDebug::Fatal(DEBUG_INFO,"Object '%s' has polygon '%d' with more than one material.",0,cid); } }else{ xr_delete(currentMaterials); } return mArray[0].asChar(); }
//get attribute names for an animationlayer, like mute,weight, solo void atomAnimLayers::getRelevantAttributes(MStringArray &attributes) { MString attr("mute"); attributes.append(attr); attr = MString("lock"); attributes.append(attr); attr = MString("solo"); attributes.append(attr); attr = MString("override"); attributes.append(attr); attr = MString("passthrough"); attributes.append(attr); attr = MString("preferred"); attributes.append(attr); attr = MString("weight"); attributes.append(attr); attr = MString("rotationAccumulationMode"); attributes.append(attr); attr = MString("scaleAccumulationMode"); attributes.append(attr); }
void rigidBodyNode::addContactInfo(const MString& contactObjectName, const MVector& point) { MObject thisObject(thisMObject()); // contactCount m_contactCount++; MPlug plugContactCount(thisObject, rigidBodyNode::oa_contactCount); plugContactCount.setValue(m_contactCount); // contactName MPlug plugContactName(thisObject, rigidBodyNode::oa_contactName); if ( !plugContactName.isNull() ) { MObject strArrObject; plugContactName.getValue(strArrObject); MFnStringArrayData stringArrayData(strArrObject); MStringArray stringArray = stringArrayData.array(); stringArray.append(contactObjectName); MFnStringArrayData newStringArrayData; MObject newStrArrObject = newStringArrayData.create(stringArray); plugContactName.setValue(newStrArrObject); } // contactPosition MPlug plugContactPosition(thisObject, rigidBodyNode::oa_contactPosition); if ( !plugContactPosition.isNull() ) { MObject arrObject; plugContactPosition.getValue(arrObject); MFnVectorArrayData vectorArrayData(arrObject); MVectorArray vectorArray = vectorArrayData.array(); vectorArray.append(point); MFnVectorArrayData newVectorArrayData; MObject newArrObject = newVectorArrayData.create(vectorArray); plugContactPosition.setValue(newArrObject); } }
//MStringArray GlobalNodeHelper::getStringToArray(const MString& attrName ) //{ // MStatus status; // // MString strValue; // liquidGetPlugValue(m_GlobalNode, attrName.asChar(), strValue, status); // IfMErrorMsgWarn(status,"elvishray::GlobalNodeHelper::getStringArray("+attrName+")"); // // MStringArray value; // status = strValue.split('|', value); // IfMErrorMsgWarn(status,"elvishray::GlobalNodeHelper::getStringArray --> split["+strValue+"] error."); // // return value; //} MStringArray GlobalNodeHelper::getStringArray(const MString& attrName ) { MStatus status; MStringArray ret; unsigned int size = liquidGetPlugNumElements(m_GlobalNode, attrName.asChar(), &status); IfMErrorMsgWarn(status,"elvishray::GlobalNodeHelper::getStringArray("+attrName+"), liquidGetPlugNumElements()"); for(unsigned int i=0; i < size; ++i) { MString val; IfMErrorMsgWarn(liquidGetPlugElementValue(m_GlobalNode, i, attrName.asChar(), val, status), "elvishray::GlobalNodeHelper::getStringArray("+attrName+"), liquidGetPlugElementValue()"); ret.append(val); } return ret; }
bool XmlCacheFormat::readXmlTagValue( string tag, MStringArray& values ) { string endTag = XMLENDTAG(tag); bool status = true; values.clear(); // Yes this could be much much smarter if( findXmlStartTag(tag) ) { string token; fFile >> token; while ( !fFile.eof() && token != endTag ) { values.append( token.data() ); fFile >> token; } } else {
// Load the file textures for the cube maps. // MStatus hwRefractReflectShader_NV20::loadTextures(const MDrawRequest& request, M3dView& view) { // Get the cube map file names // MStringArray decalNames; MString decalName; // Find the cubemap textures by tracing through the connection from the color atttribute // ShadingConnection colorConnection(thisMObject(), request.multiPath().partialPathName(), "color"); // If the color attribute is ultimately connected to a environment, // find its filenames, otherwise use the default color texture. // bool gotAllEnvironmentMaps = TRUE; if (colorConnection.type() == ShadingConnection::TEXTURE && colorConnection.texture().hasFn(MFn::kEnvCube)) { // Get the filenames of the texture. MFnDependencyNode textureNode(colorConnection.texture()); MString attributeName; MString envNames[6] = { "top", "bottom", "left", "right", "front", "back" }; // Scan for connected file textures to the environment map node // for (int i=0; i<6; i++) { ShadingConnection conn(colorConnection.texture(), request.multiPath().partialPathName(), envNames[i]); if (conn.type() == ShadingConnection::TEXTURE && conn.texture().hasFn(MFn::kFileTexture)) { MFnDependencyNode envNode(conn.texture()); MPlug filenamePlug( conn.texture(), envNode.attribute(MString("fileTextureName")) ); filenamePlug.getValue(decalName); if (decalName.length() == 0) decalName = "internalDefaultTexture"; // Append next environment map name decalNames.append( decalName ); } // If any of the environment maps are not mapped put in a fake texture else { decalName = "internalDefaultTexture"; decalNames.append( decalName ); } } } else { // Put in a fake texture for each side decalName = "internalDefaultTexture"; for (int i=0; i<6; i++) { decalNames.append( decalName ); } } // Reload cube maps if the name of the textures // for any of the cube maps changes // bool reload = FALSE; for (int i=0; i<6; i++) { if (currentTextureNames[i] != decalNames[i]) { reload = TRUE; break; } } view.beginGL(); { if ( reload ) { MString ypTexName(decalNames[0]); // y+ == top MString ynTexName(decalNames[1]); // y- == bottom MString xpTexName(decalNames[2]); // x+ == left MString xnTexName(decalNames[3]); // x- == right MString zpTexName(decalNames[4]); // z+ == front MString znTexName(decalNames[5]); // z- == back MStatus stat; if (! (stat = theImage_XP.readFromFile(xpTexName)) ) return MS::kFailure; if (! (stat = theImage_XN.readFromFile(xnTexName)) ) return MS::kFailure; if (! (stat = theImage_YP.readFromFile(ypTexName)) ) return MS::kFailure; if (! (stat = theImage_YN.readFromFile(ynTexName)) ) return MS::kFailure; if (! (stat = theImage_ZP.readFromFile(zpTexName)) ) return MS::kFailure; if (! (stat = theImage_ZN.readFromFile(znTexName)) ) return MS::kFailure; // Only create texture names the first time if (fTextureName == -1) glGenTextures(1, &fTextureName); glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, fTextureName ); glEnable( GL_TEXTURE_CUBE_MAP_ARB ); // The cubeMap textures have to have the same size // unsigned int width, height; stat = theImage_XP.getSize( width, height ); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_XP.pixels() ); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_XN.pixels() ); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_YP.pixels() ); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_YN.pixels() ); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_ZP.pixels() ); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, theImage_ZN.pixels() ); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); for (i=0; i<6; i++) currentTextureNames[i] = decalNames[i]; } // stage 0 -- cubeMap texture for the refraction // glActiveTextureARB( GL_TEXTURE0_ARB ); glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, fTextureName ); glEnable( GL_TEXTURE_CUBE_MAP_ARB ); // stage 1 -- cubeMap texture for the reflection // glActiveTextureARB( GL_TEXTURE1_ARB ); glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, fTextureName ); glEnable( GL_TEXTURE_CUBE_MAP_ARB ); } view.endGL(); return MS::kSuccess; }
/** Create a RIB compatible representation of a Maya polygon mesh. */ liqRibMeshData::liqRibMeshData( MObject mesh ) : numFaces( 0 ), numPoints ( 0 ), numNormals ( 0 ), nverts(), verts(), vertexParam(NULL), normalParam(NULL) { CM_TRACE_FUNC("liqRibMeshData::liqRibMeshData("<<MFnDagNode(mesh).fullPathName().asChar()<<")"); unsigned int i; unsigned int j; areaLight = false; LIQDEBUGPRINTF( "-> creating mesh\n" ); MFnMesh fnMesh( mesh ); objDagPath = fnMesh.dagPath(); MStatus astatus; name = fnMesh.name(); areaLight =( liquidGetPlugValue( fnMesh, "areaIntensity", areaIntensity, astatus ) == MS::kSuccess )? true : false ; if ( areaLight ) { MDagPath meshDagPath; meshDagPath = fnMesh.dagPath(); MTransformationMatrix worldMatrix = meshDagPath.inclusiveMatrix(); MMatrix worldMatrixM = worldMatrix.asMatrix(); worldMatrixM.get( transformationMatrix ); } numPoints = fnMesh.numVertices(); numNormals = fnMesh.numNormals(); // UV sets ------------------- // //const unsigned numSTs( fnMesh.numUVs() ); const unsigned numUVSets( fnMesh.numUVSets() ); MString currentUVSetName; MStringArray extraUVSetNames; fnMesh.getCurrentUVSetName( currentUVSetName ); { MStringArray UVSetNames; fnMesh.getUVSetNames( UVSetNames ); for ( unsigned i( 0 ); i<numUVSets; i++ ) if ( UVSetNames[i] != currentUVSetName ) extraUVSetNames.append( UVSetNames[i] ); } numFaces = fnMesh.numPolygons(); const unsigned numFaceVertices( fnMesh.numFaceVertices() ); if ( numPoints < 1 ) { // MGlobal::displayInfo( MString( "fnMesh: " ) + fnMesh.name() ); // cerr << "Liquid : Could not export degenerate mesh '"<< fnMesh.fullPathName( &astatus ).asChar() << "'" << endl << flush; return; } unsigned face = 0; unsigned faceVertex = 0; unsigned count; unsigned vertex; unsigned normal; float S; float T; MPoint point; liqTokenPointer pointsPointerPair; liqTokenPointer normalsPointerPair; liqTokenPointer pFaceVertexSPointer; liqTokenPointer pFaceVertexTPointer; // Allocate memory and tokens numFaces = numFaces; nverts = shared_array< liqInt >( new liqInt[ numFaces ] ); verts = shared_array< liqInt >( new liqInt[ numFaceVertices ] ); pointsPointerPair.set( "P", rPoint, numPoints ); pointsPointerPair.setDetailType( rVertex ); if ( numNormals == numPoints ) { normalsPointerPair.set( "N", rNormal, numPoints ); normalsPointerPair.setDetailType( rVertex ); } else { normalsPointerPair.set( "N", rNormal, numFaceVertices ); normalsPointerPair.setDetailType( rFaceVarying ); } // uv std::vector<liqTokenPointer> UVSetsArray; UVSetsArray.reserve( 1 + extraUVSetNames.length() ); liqTokenPointer currentUVSetUPtr; liqTokenPointer currentUVSetVPtr; liqTokenPointer currentUVSetNamePtr; liqTokenPointer extraUVSetsUPtr; liqTokenPointer extraUVSetsVPtr; liqTokenPointer extraUVSetsNamePtr; if(liqglo.liqglo_outputMeshAsRMSArrays) { currentUVSetUPtr.set( "s", rFloat, numFaceVertices ); currentUVSetUPtr.setDetailType( rFaceVarying ); currentUVSetVPtr.set( "t", rFloat, numFaceVertices ); currentUVSetVPtr.setDetailType( rFaceVarying ); currentUVSetNamePtr.set( "currentUVSet", rString, 1 ); currentUVSetNamePtr.setDetailType( rConstant ); if( numUVSets > 1 ) { extraUVSetsUPtr.set( "u_uvSet", rFloat, numFaceVertices, numUVSets-1 ); extraUVSetsUPtr.setDetailType( rFaceVarying ); extraUVSetsVPtr.set( "v_uvSet", rFloat, numFaceVertices, numUVSets-1 ); extraUVSetsVPtr.setDetailType( rFaceVarying ); extraUVSetsNamePtr.set( "extraUVSets", rString, numUVSets-1 ); extraUVSetsNamePtr.setDetailType( rConstant ); } } else { if ( numUVSets > 0 ) { liqTokenPointer pFaceVertexPointerPair; pFaceVertexPointerPair.set( "st", rFloat, numFaceVertices, 2 ); pFaceVertexPointerPair.setDetailType( rFaceVarying ); UVSetsArray.push_back( pFaceVertexPointerPair ); for ( unsigned j( 0 ); j<extraUVSetNames.length(); j++) { liqTokenPointer pFaceVertexPointerPair; pFaceVertexPointerPair.set( extraUVSetNames[j].asChar(), rFloat, numFaceVertices, 2 ); pFaceVertexPointerPair.setDetailType( rFaceVarying ); UVSetsArray.push_back( pFaceVertexPointerPair ); } if( liqglo.liqglo_outputMeshUVs ) { // Match MTOR, which also outputs face-varying STs as well for some reason - Paul // not anymore - Philippe pFaceVertexSPointer.set( "u", rFloat, numFaceVertices ); pFaceVertexSPointer.setDetailType( rFaceVarying ); pFaceVertexTPointer.set( "v", rFloat, numFaceVertices ); pFaceVertexTPointer.setDetailType( rFaceVarying ); } } } vertexParam = pointsPointerPair.getTokenFloatArray(); normalParam = normalsPointerPair.getTokenFloatArray(); // Read the mesh from Maya MFloatVectorArray normals; fnMesh.getNormals( normals ); for ( MItMeshPolygon polyIt ( mesh ); polyIt.isDone() == false; polyIt.next() ) { count = polyIt.polygonVertexCount(); nverts[face] = count; for( i=0; i<count; i++ ) // boucle sur les vertex de la face { vertex = polyIt.vertexIndex( i ); verts[faceVertex] = vertex; point = polyIt.point( i, MSpace::kObject ); pointsPointerPair.setTokenFloat( vertex, point.x, point.y, point.z ); normal = polyIt.normalIndex( i ); if( numNormals == numPoints ) normalsPointerPair.setTokenFloat( vertex, normals[normal].x, normals[normal].y, normals[normal].z ); else normalsPointerPair.setTokenFloat( faceVertex, normals[normal].x, normals[normal].y, normals[normal].z ); if( liqglo.liqglo_outputMeshAsRMSArrays ) { for( j=0; j<numUVSets; j++ ) { if(j==0) { MString uvSetName = currentUVSetName; // set uvSet name currentUVSetNamePtr.setTokenString( 0, currentUVSetName.asChar() ); // set uv values fnMesh.getPolygonUV( face, i, S, T, &uvSetName ); currentUVSetUPtr.setTokenFloat( faceVertex, S ); currentUVSetVPtr.setTokenFloat( faceVertex, 1-T ); } else { MString uvSetName = extraUVSetNames[j-1]; // set uvSet name extraUVSetsNamePtr.setTokenString( j-1, extraUVSetNames[j-1].asChar() ); // set uv values fnMesh.getPolygonUV( face, i, S, T, &uvSetName ); extraUVSetsUPtr.setTokenFloat( (numFaceVertices*(j-1)) + faceVertex, S ); extraUVSetsVPtr.setTokenFloat( (numFaceVertices*(j-1)) + faceVertex, 1-T ); } } } else { if ( numUVSets ) { for( j=0; j<numUVSets; j++ ) { MString uvSetName; if(j==0) { uvSetName = currentUVSetName; } else { uvSetName = extraUVSetNames[j-1]; } fnMesh.getPolygonUV( face, i, S, T, &uvSetName ); UVSetsArray[j].setTokenFloat( faceVertex, 0, S ); UVSetsArray[j].setTokenFloat( faceVertex, 1, 1-T ); //printf("V%d %s : %f %f => %f %f \n", i, uvSetName.asChar(), S, T, S, 1-T); if( liqglo.liqglo_outputMeshUVs && j==0) { // Match MTOR, which always outputs face-varying STs as well for some reason - Paul pFaceVertexSPointer.setTokenFloat( faceVertex, S ); pFaceVertexTPointer.setTokenFloat( faceVertex, 1-T ); } } } } // printf( "[%d] faceVertex = %d vertex = %d\n", i, faceVertex, vertex ); ++faceVertex; } ++face; } // Add tokens to array and clean up after tokenPointerArray.push_back( pointsPointerPair ); tokenPointerArray.push_back( normalsPointerPair ); if(liqglo.liqglo_outputMeshAsRMSArrays) { tokenPointerArray.push_back( currentUVSetNamePtr ); tokenPointerArray.push_back( currentUVSetUPtr ); tokenPointerArray.push_back( currentUVSetVPtr ); if( numUVSets > 1 ) { tokenPointerArray.push_back( extraUVSetsNamePtr ); tokenPointerArray.push_back( extraUVSetsUPtr ); tokenPointerArray.push_back( extraUVSetsVPtr ); } } else { if( UVSetsArray.size() ) tokenPointerArray.insert( tokenPointerArray.end(), UVSetsArray.begin(), UVSetsArray.end() ); if( liqglo.liqglo_outputMeshUVs ) { tokenPointerArray.push_back( pFaceVertexSPointer ); tokenPointerArray.push_back( pFaceVertexTPointer ); } } addAdditionalSurfaceParameters( mesh ); }