bool IsTemplated(MFnDagNode& node) { MStatus status; MFnDependencyNode depFn(node.object()); bool isTemplate = false; getBool(MString("template"), depFn, isTemplate); if (isTemplate) return true; int intTempl = 0; getInt(MString("overrideDisplayType"), depFn, intTempl); if (intTempl == 1) return true; return false; }
void exportCurve(MFnDagNode & theDagNode, WorldBuilderBase & theParentTransform, SceneBuilder & theSceneBuilder) { MAKE_SCOPE_TIMER(CurveExporter_exportCurve); if (theDagNode.isIntermediateObject()) { return; } string myCurveName = string(theDagNode.name().asChar()); DB(AC_TRACE << "Exporting curve: " << myCurveName << endl); MFnNurbsCurve myMCurve(theDagNode.object()); DB( cerr << "Number of cvs: " << myMCurve.numCVs() << endl; cerr << "Number of spans: " << myMCurve.numSpans() << endl; cerr << "Number of knots: " << myMCurve.numKnots() << endl; cerr << "Degree: " << myMCurve.degree() << endl; cerr << "Length: " << myMCurve.length() << endl; for (double d = 0.0; d <= 1.0; d += 0.1) { MPoint myPoint; myMCurve.getPointAtParam(d, myPoint); cerr << "Point at param " << d << ": " << myPoint.x << ", " << myPoint.y << ", " << myPoint.z << endl; } int myCvCount = myMCurve.numCVs(); for (int i = 0; i < myCvCount; ++i) { MPoint myPoint; myMCurve.getCV(i, myPoint); cerr << "CV " << i << ": " << myPoint.x << ", " << myPoint.y << ", " << myPoint.z << endl; } int myKnotCount = myMCurve.numKnots(); for (int i = 0; i < myKnotCount; ++i) { double knotParam; knotParam = myMCurve.knot(i); MPoint myPoint; myMCurve.getPointAtParam(knotParam, myPoint); cerr << "Point at knot# " << i << ": " << myPoint.x << ", " << myPoint.y << ", " << myPoint.z << endl; } )
bool IsVisible(MFnDagNode& node) { MStatus stat; if (node.isIntermediateObject()) return false; bool visibility = true; MFnDependencyNode depFn(node.object(), &stat); if (!stat) MGlobal::displayInfo("Problem getting dep from " + node.name()); if (!getBool(MString("visibility"), depFn, visibility)) MGlobal::displayInfo("Problem getting visibility attr from " + node.name()); if (!visibility) return false; getBool(MString("overrideVisibility"), depFn, visibility); if (!visibility) return false; return true; }
// -------------------------------------- void ReferenceManager::processReference ( const MObject& referenceNode ) { MStatus status; MFnDependencyNode referenceNodeFn ( referenceNode, &status ); if (status != MStatus::kSuccess) return; #if MAYA_API_VERSION >= 600 MString referenceNodeName = MFnDependencyNode( referenceNode ).name(); Reference* reference = new Reference(); reference->referenceNode = referenceNode; mReferences.push_back ( reference ); // Get the paths of the root transforms included in this reference MObjectArray subReferences; getRootObjects ( referenceNode, reference->paths, subReferences ); uint pathCount = reference->paths.length(); // Process the sub-references first uint subReferenceCount = subReferences.length(); for (uint i = 0; i < subReferenceCount; ++i) { MObject& subReference = subReferences[i]; if ( subReference != MObject::kNullObj ) processReference ( subReference ); } // Retrieve the reference node's filename MString command = MString("reference -rfn \"") + referenceNodeFn.name() + MString("\" -q -filename;"); MString filename; status = MGlobal::executeCommand ( command, filename ); if (status != MStatus::kSuccess || filename.length() == 0) return; // Strip the filename of the multiple file token int stripIndex = filename.index('{'); if (stripIndex != -1) filename = filename.substring(0, stripIndex - 1); // Avoid transform look-ups on COLLADA references. int extLocation = filename.rindex('.'); if (extLocation > 0) { MString ext = filename.substring(extLocation + 1, filename.length() - 1).toLowerCase(); if (ext == "dae" || ext == "xml") return; } // Check for already existing file information // Otherwise create a new file information sheet with current node names for ( ReferenceFileList::iterator it = mFiles.begin(); it != mFiles.end(); ++it ) { if ((*it)->filename == filename) { reference->file = (*it); break; } } if ( reference->file == NULL ) reference->file = processReferenceFile(filename); // Get the list of the root transform's first child's unreferenced parents. // This is a list of the imported nodes! for (uint j = 0; j < pathCount; ++j) { MDagPath path = reference->paths[j]; if (path.childCount() > 0) { path.push ( path.child(0) ); MFnDagNode childNode ( path ); if (!childNode.object().hasFn(MFn::kTransform)) continue; uint parentCount = childNode.parentCount(); for (uint k = 0; k < parentCount; ++k) { MFnDagNode parentNode(childNode.parent(k)); if (parentNode.object() == MObject::kNullObj || parentNode.isFromReferencedFile()) continue; MDagPath parentPath = MDagPath::getAPathTo(parentNode.object()); if (parentPath.length() > 0) { ReferenceRootList::iterator it = reference->reroots.insert( reference->reroots.end(), ReferenceRoot() ); (*it).index = j; (*it).reroot = parentPath; } } } } #endif }