void Exporter::createSceneGraph(MFnDagNode& path, int parentIndex) { Node output; std::vector<std::string> pathparts; output.name = path.fullPathName().asChar(); splitStringToVector(output.name, pathparts, "|"); output.name = pathparts[pathparts.size() - 1]; if (!strcmp(output.name.c_str(), "persp")) return; else if (!strcmp(output.name.c_str(), "top")) return; else if (!strcmp(output.name.c_str(), "side")) return; else if (!strcmp(output.name.c_str(), "front")) return; output.parent = parentIndex; output.transform = path.transformationMatrix().matrix; scene_.sceneGraph.push_back(output); int children = path.childCount(); int parent = scene_.sceneGraph.size() - 1; for (int i = 0; i < children; i++) { cout << path.child(i).apiTypeStr() << endl; if (!strcmp(path.child(i).apiTypeStr(), "kMesh")){ scene_.sceneGraph[parent].type = 1; MFnMesh mesh(path.child(i)); MDagPath dag_path; MItDag dag_iter(MItDag::kBreadthFirst, MFn::kMesh); int y = 0; while (!dag_iter.isDone()) { if (dag_iter.getPath(dag_path)) { MFnDagNode dag_node = dag_path.node(); if (!dag_node.isIntermediateObject()) { if (!strcmp(mesh.partialPathName().asChar(), dag_node.partialPathName().asChar())) scene_.sceneGraph[parent].mesh = y; y++; } } dag_iter.next(); } } // else if (!strcmp(path.child(i).apiTypeStr(), "kCamera")); kan l�gga till fler typer h�r else createSceneGraph(MFnDagNode(path.child(i)), parent); } }
//--------------------------------------------------- void DagHelper::setArrayPlugSize ( MPlug& plug, uint size ) { if ( plug.node().isNull() ) return; #if MAYA_API_VERSION >= 800 MStatus status = plug.setNumElements ( size ); CHECK_STAT ( status ); #else MObject node = plug.node(); MString plugPath = plug.info(); if ( node.hasFn ( MFn::kDagNode ) ) { MFnDagNode dagFn ( node ); int dot = plugPath.index ( '.' ); plugPath = dagFn.fullPathName() + plugPath.substring ( dot, plugPath.length() ); } MString command = MString ( "setAttr -s " ) + size + " \"" + plugPath + "\";"; MGlobal::executeCommand ( command ); #endif // MAYA 8.00+ }