本文整理汇总了C++中MDagPath类的典型用法代码示例。如果您正苦于以下问题:C++ MDagPath类的具体用法?C++ MDagPath怎么用?C++ MDagPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MDagPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CM_TRACE_FUNC
void liqRibSubdivisionData::addExtraTags( MObject &dstNode, float extraTagValue, SBD_EXTRA_TAG extraTag )
{
CM_TRACE_FUNC("liqRibSubdivisionData::addExtraTags("<<MFnDependencyNode(dstNode).name()<<","<<extraTagValue<<","<<extraTag<<")");
if( TAG_BOUNDARY == extraTag )
{
v_tags.push_back( "interpolateboundary" );
v_nargs.push_back( 1 ); // 0 intargs
v_nargs.push_back( 0 ); // 0 floatargs
v_intargs.push_back( (int)extraTagValue );
return;
}
if( TAG_FACEVARYINGBOUNDARY == extraTag )
{
v_tags.push_back( "facevaryinginterpolateboundary" );
v_nargs.push_back( 1 ); // 1 intargs
v_nargs.push_back( 0 ); // 0 floatargs
v_intargs.push_back( (int)extraTagValue );
}
MStatus status = MS::kSuccess;
MFnSet elemSet( dstNode, &status ); // dstNode is maya components set
if( status == MS::kSuccess )
{
MSelectionList members;
status = elemSet.getMembers( members, true ); // get flatten members list
if( status == MS::kSuccess )
{
for ( unsigned i( 0 ) ; i < members.length() ; i++ )
{
MObject component;
MDagPath dagPath;
members.getDagPath ( i, dagPath, component );
// since the crease set could contain more that one mesh
// we only want the current one - Alf
if( dagPath.fullPathName() != longName )
continue;
switch ( extraTag )
{
case TAG_CREASE:
if( !component.isNull() && component.hasFn( MFn::kMeshEdgeComponent ) )
{
MItMeshEdge edgeIter( dagPath, component );
for( ; !edgeIter.isDone(); edgeIter.next() )
{
v_tags.push_back( "crease" );
v_nargs.push_back( 2 ); // 2 intargs
v_nargs.push_back( 1 ); // 1 floatargs
v_intargs.push_back( edgeIter.index( 0 ) );
v_intargs.push_back( edgeIter.index( 1 ) );
v_floatargs.push_back( extraTagValue ); // 1 floatargs
}
}
break;
case TAG_CORNER:
if( !component.isNull() && component.hasFn( MFn::kMeshVertComponent ) )
{
MItMeshVertex vertexIter( dagPath, component );
for( ; !vertexIter.isDone(); vertexIter.next() )
{
v_tags.push_back( "corner" );
v_nargs.push_back( 1 ); // 1 intargs
v_nargs.push_back( 1 ); // 1 floatargs
v_intargs.push_back( vertexIter.index() );
v_floatargs.push_back( extraTagValue ); // 1 floatargs
}
}
break;
case TAG_HOLE:
if( !component.isNull() && component.hasFn( MFn::kMeshPolygonComponent ) )
{
MItMeshPolygon faceIter( dagPath, component );
for( ; !faceIter.isDone(); faceIter.next() )
{
v_tags.push_back( "hole" );
v_nargs.push_back( 1 ); // 1 intargs
v_nargs.push_back( 0 ); // 0 floatargs
v_intargs.push_back( faceIter.index() );
}
}
break;
case TAG_STITCH:
if( !component.isNull() && component.hasFn( MFn::kMeshVertComponent ) )
{
MItMeshVertex vertexIter( dagPath, component );
v_tags.push_back( "stitch" );
v_nargs.push_back( vertexIter.count() + 1 ); // vertex count in chain + 1 integer identifier
v_nargs.push_back( 0 ); // 0 floatargs
v_intargs.push_back( ( int ) extraTagValue );
for( ; !vertexIter.isDone(); vertexIter.next() )
{
v_intargs.push_back( vertexIter.index() );
}
}
//.........这里部分代码省略.........
示例2: argData
MStatus AbcImport::doIt(const MArgList & args)
{
MStatus status;
MArgParser argData(syntax(), args, &status);
MString filename("");
MString connectRootNodes("");
MString filterString("");
MString excludeFilterString("");
MObject reparentObj = MObject::kNullObj;
bool swap = false;
bool createIfNotFound = false;
bool removeIfNoUpdate = false;
bool debugOn = false;
if (argData.isFlagSet("help"))
{
MGlobal::displayInfo(usage);
return status;
}
if (argData.isFlagSet("debug"))
debugOn = true;
if (argData.isFlagSet("reparent"))
{
MString parent("");
MDagPath reparentDagPath;
status = argData.getFlagArgument("reparent", 0, parent);
if (status == MS::kSuccess
&& getDagPathByName(parent, reparentDagPath) == MS::kSuccess)
{
reparentObj = reparentDagPath.node();
}
else
{
MString theWarning = parent;
theWarning += MString(" is not a valid DagPath");
printWarning(theWarning);
}
}
if (!argData.isFlagSet("connect") && argData.isFlagSet("mode"))
{
MString modeStr;
argData.getFlagArgument("mode", 0, modeStr);
if (modeStr == "replace")
deleteCurrentSelection();
else if (modeStr == "open")
{
MFileIO fileIo;
fileIo.newFile(true);
}
}
else if (argData.isFlagSet("connect"))
{
swap = true;
argData.getFlagArgument("connect", 0, connectRootNodes);
if (argData.isFlagSet("createIfNotFound"))
{
createIfNotFound = true;
}
if (argData.isFlagSet("removeIfNoUpdate"))
removeIfNoUpdate = true;
}
if (argData.isFlagSet("filterObjects"))
{
argData.getFlagArgument("filterObjects", 0, filterString);
}
if (argData.isFlagSet("excludeFilterObjects"))
{
argData.getFlagArgument("excludeFilterObjects", 0, excludeFilterString);
}
// if the flag isn't specified we'll only do stuff marked with the Maya
// meta data
bool recreateColorSets = false;
if (argData.isFlagSet("recreateAllColorSets"))
{
recreateColorSets = true;
}
status = argData.getCommandArgument(0, filename);
MString abcNodeName;
if (status == MS::kSuccess)
{
{
MString fileRule, expandName;
MString alembicFileRule = "alembicCache";
MString alembicFilePath = "cache/alembic";
MString queryFileRuleCmd;
//.........这里部分代码省略.........
示例3: dagNodeFn
void maTranslator::writeDagNodes(fstream& f)
{
fParentingRequired.clear();
MItDag dagIter;
dagIter.traverseUnderWorld(true);
MDagPath worldPath;
dagIter.getPath(worldPath);
//
// We step over the world node before starting the loop, because it
// doesn't get written out.
//
for (dagIter.next(); !dagIter.isDone(); dagIter.next())
{
MDagPath path;
dagIter.getPath(path);
//
// If the node has already been written, then all of its descendants
// must have been written, or at least checked, as well, so prune
// this branch of the tree from the iteration.
//
MFnDagNode dagNodeFn(path);
if (dagNodeFn.isFlagSet(fCreateFlag))
{
dagIter.prune();
continue;
}
//
// If this is a default node, it will be written out later, so skip
// it.
//
if (dagNodeFn.isDefaultNode()) continue;
//
// If this node is not writable, and is not a shared node, then mark
// it as having been written, and skip it.
//
if (!dagNodeFn.canBeWritten() && !dagNodeFn.isShared())
{
dagNodeFn.setFlag(fCreateFlag, true);
continue;
}
unsigned int numParents = dagNodeFn.parentCount();
if (dagNodeFn.isFromReferencedFile())
{
//
// We don't issue 'creatNode' commands for nodes from referenced
// files, but if the node has any parents which are not from
// referenced files, other than the world, then make a note that
// we'll need to issue extra 'parent' commands for it later on.
//
unsigned int i;
for (i = 0; i < numParents; i++)
{
MObject altParent = dagNodeFn.parent(i);
MFnDagNode altParentFn(altParent);
if (!altParentFn.isFromReferencedFile()
&& (altParentFn.object() != worldPath.node()))
{
fParentingRequired.append(path);
break;
}
}
}
else
{
//
// Find the node's parent.
//
MDagPath parentPath = worldPath;
if (path.length() > 1)
{
//
// Get the parent's path.
//
parentPath = path;
parentPath.pop();
//
// If the parent is in the underworld, then find the closest
// ancestor which is not.
//
if (parentPath.pathCount() > 1)
{
//
// The first segment of the path contains whatever
// portion of the path exists in the world. So the closest
// worldly ancestor is simply the one at the end of that
//.........这里部分代码省略.........
示例4: dagPathToColladaSid
String DocumentExporter::dagPathToColladaSid(const MDagPath & dagPath)
{
return mayaNameToColladaName(dagPath.partialPathName());
}
示例5: r
std::string HesperisIO::H5PathNameTo(const MDagPath & path)
{
std::string r(path.fullPathName().asChar());
H5PathName(r);
return r;
}
示例6: currTransform
MFnMesh* GDExporter::GetSelectedMesh(void)
{
MSelectionList currSelection;
MGlobal::getActiveSelectionList(currSelection);
unsigned int selectionCount = currSelection.length();
MFnMesh* exportingMesh = 0;
for(unsigned int selectionIndex = 0; selectionIndex < selectionCount; ++selectionIndex )
{
MDagPath currPath;
currSelection.getDagPath(selectionIndex, currPath);
if( currPath.apiType() != MFn::kTransform )
continue;
MFnTransform currTransform(currPath);
unsigned int childCount = currTransform.childCount();
for(unsigned int childIndex = 0; childIndex < childCount; ++childIndex)
{
MObject childObject = currTransform.child(childIndex);
if( childObject.apiType() == MFn::kMesh )
{
MFnDagNode dagNode;
dagNode.setObject(childObject);
MDagPath childPath;
dagNode.getPath(childPath);
MFnMesh* pChildMesh = new MFnMesh(childPath);
if( pChildMesh->isIntermediateObject() )
continue;
bool bExportMesh = true;
if( pChildMesh->isInstanced(false) )
if( childPath.instanceNumber() != 0 )
bExportMesh = false;
if( bExportMesh )
{
if( exportingMesh != 0 )
{
delete exportingMesh;
delete pChildMesh;
MGlobal::displayError(MString("GDExporter - More than one mesh object selected."));
return 0;
}
exportingMesh = pChildMesh;
}
}
}
}
if( exportingMesh == 0 )
{
MGlobal::displayError(MString("GDExporter - No mesh objects currently selected."));
return 0;
}
return exportingMesh;
}
示例7: draw
void liqBoundingBoxLocator::draw( M3dView & view,
const MDagPath & path,
M3dView::DisplayStyle style,
M3dView::DisplayStatus status )
{
MFnDagNode dagFn( thisMObject() );
MFnDagNode transFn( dagFn.parent( 0 ) );
MStatus stat;
bool drawBox( 0 );
MPlug plug = dagFn.findPlug( "drawBox", stat );
if ( stat == MS::kSuccess ) plug.getValue( drawBox );
if ( !drawBox ) return;
MDoubleArray bb( 6 );
MGlobal::executeCommand( MString( "exactWorldBoundingBox " ) + transFn.fullPathName(), bb );
pts = shared_array< MPoint >( new MPoint[ 8 ] );
pts[0].x = bb[0];
pts[0].y = bb[4];
pts[0].z = bb[2];
pts[1].x = bb[0];
pts[1].y = bb[4];
pts[1].z = bb[5];
pts[2].x = bb[3];
pts[2].y = bb[4];
pts[2].z = bb[5];
pts[3].x = bb[3];
pts[3].y = bb[4];
pts[3].z = bb[2];
pts[4].x = bb[0];
pts[4].y = bb[1];
pts[4].z = bb[2];
pts[5].x = bb[0];
pts[5].y = bb[1];
pts[5].z = bb[5];
pts[6].x = bb[3];
pts[6].y = bb[1];
pts[6].z = bb[5];
pts[7].x = bb[3];
pts[7].y = bb[1];
pts[7].z = bb[2];
MMatrix m( path.inclusiveMatrix() );
for( unsigned i( 0 ); i < 8; i++ )
pts[i] *= m.inverse();
// draw box
view.beginGL();
view.setDrawColor( MColor( .57f, 0, .57f ) );
glPushAttrib( GL_CURRENT_BIT );
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z );
glVertex3f( (float)pts[1].x, (float)pts[1].y, (float)pts[1].z );
glVertex3f( (float)pts[2].x, (float)pts[2].y, (float)pts[2].z );
glVertex3f( (float)pts[3].x, (float)pts[3].y, (float)pts[3].z );
glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z );
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z );
glVertex3f( (float)pts[5].x, (float)pts[5].y, (float)pts[5].z );
glVertex3f( (float)pts[6].x, (float)pts[6].y, (float)pts[6].z );
glVertex3f( (float)pts[7].x, (float)pts[7].y, (float)pts[7].z );
glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z );
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[0].x, (float)pts[0].y, (float)pts[0].z );
glVertex3f( (float)pts[4].x, (float)pts[4].y, (float)pts[4].z );
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[1].x, (float)pts[1].y, (float)pts[1].z );
glVertex3f( (float)pts[5].x, (float)pts[5].y, (float)pts[5].z );
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[2].x, (float)pts[2].y, (float)pts[2].z );
glVertex3f( (float)pts[6].x, (float)pts[6].y, (float)pts[6].z );
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3f( (float)pts[3].x, (float)pts[3].y, (float)pts[3].z );
glVertex3f( (float)pts[7].x, (float)pts[7].y, (float)pts[7].z );
glEnd();
view.endGL();
}
示例8: ImportControllers
void NifAnimationImporter::ImportControllers( NiAVObjectRef niAVObj, MDagPath & path ) {
list<NiTimeControllerRef> controllers = niAVObj->GetControllers();
//Iterate over the controllers, reacting properly to each type
for ( list<NiTimeControllerRef>::iterator it = controllers.begin(); it != controllers.end(); ++it ) {
if ( (*it)->IsDerivedType( NiKeyframeController::TYPE ) ) {
//--NiKeyframeController--//
NiKeyframeControllerRef niKeyCont = DynamicCast<NiKeyframeController>(*it);
NiKeyframeDataRef niKeyData = niKeyCont->GetData();
MFnTransform transFn( path.node() );
MFnAnimCurve traXFn;
MFnAnimCurve traYFn;
MFnAnimCurve traZFn;
MObject traXcurve = traXFn.create( transFn.findPlug("translateX") );
MObject traYcurve = traYFn.create( transFn.findPlug("translateY") );
MObject traZcurve = traZFn.create( transFn.findPlug("translateZ") );
MTimeArray traTimes;
MDoubleArray traXValues;
MDoubleArray traYValues;
MDoubleArray traZValues;
vector<Key<Vector3> > tra_keys = niKeyData->GetTranslateKeys();
for ( size_t i = 0; i < tra_keys.size(); ++i) {
traTimes.append( MTime( tra_keys[i].time, MTime::kSeconds ) );
traXValues.append( tra_keys[i].data.x );
traYValues.append( tra_keys[i].data.y );
traZValues.append( tra_keys[i].data.z );
//traXFn.addKeyframe( tra_keys[i].time * 24.0, tra_keys[i].data.x );
//traYFn.addKeyframe( tra_keys[i].time * 24.0, tra_keys[i].data.y );
//traZFn.addKeyframe( tra_keys[i].time * 24.0, tra_keys[i].data.z );
}
traXFn.addKeys( &traTimes, &traXValues );
traYFn.addKeys( &traTimes, &traYValues );
traZFn.addKeys( &traTimes, &traZValues );
KeyType kt = niKeyData->GetRotateType();
if ( kt != XYZ_ROTATION_KEY ) {
vector<Key<Quaternion> > rot_keys = niKeyData->GetQuatRotateKeys();
MFnAnimCurve rotXFn;
MFnAnimCurve rotYFn;
MFnAnimCurve rotZFn;
MObject rotXcurve = rotXFn.create( transFn.findPlug("rotateX") );
//rotXFn.findPlug("rotationInterpolation").setValue(3);
MObject rotYcurve = rotYFn.create( transFn.findPlug("rotateY") );
//rotYFn.findPlug("rotationInterpolation").setValue(3);
MObject rotZcurve = rotZFn.create( transFn.findPlug("rotateZ") );
//rotZFn.findPlug("rotationInterpolation").setValue(3);
MTimeArray rotTimes;
MDoubleArray rotXValues;
MDoubleArray rotYValues;
MDoubleArray rotZValues;
MEulerRotation mPrevRot;
for( size_t i = 0; i < rot_keys.size(); ++i ) {
Quaternion niQuat = rot_keys[i].data;
MQuaternion mQuat( niQuat.x, niQuat.y, niQuat.z, niQuat.w );
MEulerRotation mRot = mQuat.asEulerRotation();
MEulerRotation mAlt;
mAlt[0] = PI + mRot[0];
mAlt[1] = PI - mRot[1];
mAlt[2] = PI + mRot[2];
for ( size_t j = 0; j < 3; ++j ) {
double prev_diff = abs(mRot[j] - mPrevRot[j]);
//Try adding and subtracting multiples of 2 pi radians to get
//closer to the previous angle
while (true) {
double new_angle = mRot[j] - (PI * 2);
double diff = abs( new_angle - mPrevRot[j] );
if ( diff < prev_diff ) {
mRot[j] = new_angle;
prev_diff = diff;
} else {
break;
}
}
while (true) {
double new_angle = mRot[j] + (PI * 2);
double diff = abs( new_angle - mPrevRot[j] );
if ( diff < prev_diff ) {
mRot[j] = new_angle;
prev_diff = diff;
} else {
break;
}
}
}
//.........这里部分代码省略.........
示例9: insert
/**
* Insert a new node into the hash table.
*/
int liqRibHT::insert( MDagPath &path, double /*lframe*/, int sample,
ObjectType objType,
int CountID,
MMatrix *matrix,
const MString instanceStr,
int particleId )
{
CM_TRACE_FUNC("liqRibClipPlaneData::insert("<<path.fullPathName()<<",lframe,"
<<sample<<","<<objType<<","<<CountID<<",matrix,"<<instanceStr<<","<<particleId<<")");
LIQDEBUGPRINTF( "-> inserting node into hash table\n" );
MFnDagNode fnDagNode( path );
MStatus returnStatus;
objTypeVec.push_back( objType );
MString nodeName = fnDagNode.fullPathName( &returnStatus );
if ( objType == MRT_RibGen )
nodeName += "RIBGEN";
const char* name( nodeName.asChar() );
ulong hc = hash( name ,CountID );
RibHashVec.push_back( nodeName );
LIQDEBUGPRINTF( "-> hashed node name: %s", name );
LIQDEBUGPRINTF( " ID: %u\n", hc );
liqRibNodePtr node;
/*node = find( path.node(), objType );*/
node = find( nodeName, path, objType );
liqRibNodePtr newNode;
liqRibNodePtr instance;
// If "node" is non-null then there's already a hash table entry at
// this point
//
liqRibNodePtr tail;
if( node )
{
while( node )
{
tail = node;
// Break if we've already dealt with this DAG path
// (and instance string - by default this is "", which
// will match for most objects - allowing us to deal
// with particle-instancing).
//
if ( path == node->path() &&
instanceStr == node->getInstanceStr() )
{
break;
}
if ( path.node() == node->path().node() )
{
// We have found another instance of the object we are object
// looking for
instance = node;
}
node = node->next;
}
if ( ( !node ) && ( instance ) )
{
// We have not found a node with a matching path, but we have found
// one with a matching object, so we need to insert a new instance
newNode = liqRibNodePtr( new liqRibNode( instance, instanceStr ) );
}
}
if( !newNode )
{
// We have to make a new node
if ( !node)
{
node = liqRibNodePtr( new liqRibNode( liqRibNodePtr(), instanceStr) );
if ( tail )
{
assert( !tail->next );
tail->next = node;
RibNodeMap.insert( RNMAP::value_type( hc, node ) );
}
else
RibNodeMap.insert( RNMAP::value_type( hc, node ) );
}
}
else
{
assert( !node );
// Append new instance node onto tail of linked list
node = newNode;
if( tail )
{
assert( !tail->next );
tail->next = node;
RibNodeMap.insert( RNMAP::value_type( hc, node ) );
}
//.........这里部分代码省略.........
示例10: ESS_PROFILE_SCOPE
//.........这里部分代码省略.........
{
MStringArray strFrames;
valuePair[1].split(',', strFrames);
for(unsigned int i=0;i<strFrames.length();i++)
{
double frame = strFrames[i].asDouble();
frames.append(frame);
}
}
else if (lowerValue == "attrprefixes") {
splitListArg(valuePair[1], prefixFilters);
}
else if (lowerValue == "attrs") {
splitListArg(valuePair[1], attributes);
}
else if (lowerValue == "userattrprefixes") {
splitListArg(valuePair[1], userPrefixFilters);
}
else if (lowerValue == "userattrs") {
splitListArg(valuePair[1], userAttributes);
}
else {
MGlobal::displayWarning(
"[ExocortexAlembic] Skipping invalid token: " + tokens[j]);
continue;
}
}
// now check the object strings
for (unsigned int k = 0; k < objectStrings.length(); k++) {
MSelectionList sl;
MString objectString = objectStrings[k];
sl.add(objectString);
MDagPath dag;
for (unsigned int l = 0; l < sl.length(); l++) {
sl.getDagPath(l, dag);
MObject objRef = dag.node();
if (objRef.isNull()) {
MGlobal::displayWarning("[ExocortexAlembic] Skipping object '" +
objectStrings[k] + "', not found.");
break;
}
// get all parents
MObjectArray parents;
// check if this is a camera
bool isCamera = false;
for (unsigned int m = 0; m < dag.childCount(); ++m) {
MFnDagNode child(dag.child(m));
MFn::Type ctype = child.object().apiType();
if (ctype == MFn::kCamera) {
isCamera = true;
break;
}
}
if (dag.node().apiType() == MFn::kTransform && !isCamera &&
!globalspace && !withouthierarchy) {
MDagPath ppath = dag;
while (!ppath.node().isNull() && ppath.length() > 0 &&
ppath.isValid()) {
parents.append(ppath.node());
if (ppath.pop() != MStatus::kSuccess) {
break;
}
示例11: cmdArgs
//.........这里部分代码省略.........
if ( argData.isFlagSet("-stopIpr", &stat))
{
Logging::debug(MString("-stopIpr"));
EventQueue::Event e;
e.type = EventQueue::Event::IPRSTOP;
theRenderEventQueue()->push(e);
return MS::kSuccess;
}
if ( argData.isFlagSet("-pauseIpr", &stat))
{
Logging::debug(MString("-pauseIpr"));
Logging::debug(MString("-stopIpr"));
EventQueue::Event e;
e.type = EventQueue::Event::IPRPAUSE;
theRenderEventQueue()->push(e);
return MS::kSuccess;
}
if (argData.isFlagSet("-usrDataString", &stat))
{
Logging::debug(MString("-usrDataString"));
argData.getFlagArgument("-usrDataString", 0, cmdArgs->userDataString);
}
if (argData.isFlagSet("-usrDataInt", &stat))
{
Logging::debug(MString("-usrDataInt"));
argData.getFlagArgument("-usrDataInt", 0, cmdArgs->userDataInt);
}
if (argData.isFlagSet("-usrDataFloat", &stat))
{
Logging::debug(MString("-usrDataFloat"));
argData.getFlagArgument("-usrDataFloat", 0, cmdArgs->userDataFloat);
}
if (argData.isFlagSet("-usrEvent", &stat))
{
Logging::debug(MString("-usrEvent"));
argData.getFlagArgument("-usrEvent", 0, cmdArgs->userEvent);
EventQueue::Event e;
e.cmdArgsData = std::move(cmdArgs);
e.type = EventQueue::Event::USER;
theRenderEventQueue()->push(e);
return MS::kSuccess;
}
// I have to request useRenderRegion here because as soon the command is finished, what happens immediatly after the command is
// put into the queue, the value is set back to false.
MObject drg = objectFromName("defaultRenderGlobals");
MFnDependencyNode drgfn(drg);
cmdArgs->useRenderRegion = drgfn.findPlug("useRenderRegion").asBool();
cmdArgs->renderType = MayaTo::MayaToWorld::WorldRenderType::UIRENDER;
if (MGlobal::mayaState() == MGlobal::kBatch)
cmdArgs->renderType = MayaTo::MayaToWorld::WorldRenderType::BATCHRENDER;
if ( argData.isFlagSet("-startIpr", &stat))
{
Logging::debug(MString("-startIpr"));
cmdArgs->renderType = MayaTo::MayaToWorld::WorldRenderType::IPRRENDER;
}
if (argData.isFlagSet("-width", &stat))
{
argData.getFlagArgument("-width", 0, cmdArgs->width);
Logging::debug(MString("width: ") + cmdArgs->width);
}
if (argData.isFlagSet("-height", &stat))
{
argData.getFlagArgument("-height", 0, cmdArgs->height);
Logging::debug(MString("height: ") + cmdArgs->height);
}
if ( argData.isFlagSet("-camera", &stat))
{
MDagPath camera;
MSelectionList selectionList;
argData.getFlagArgument("-camera", 0, selectionList);
stat = selectionList.getDagPath(0, camera);
camera.extendToShape();
Logging::debug(MString("camera: ") + camera.fullPathName());
cmdArgs->cameraDagPath = camera;
}
EventQueue::Event e;
e.cmdArgsData = std::move(cmdArgs);
e.type = EventQueue::Event::INITRENDER;
theRenderEventQueue()->push(e);
//
if (MGlobal::mayaState() == MGlobal::kBatch)
{
RenderQueueWorker::startRenderQueueWorker();
}
return MStatus::kSuccess;
}
示例12: handleGroup
MStatus CIKSolverNode::doSimpleSolver()
{
MStatus stat;
// Get the handle and create a function set for it
//
MIkHandleGroup* handle_group = handleGroup();
if (NULL == handle_group) {
return MS::kFailure;
}
MObject handle = handle_group->handle(0);
MDagPath handlePath = MDagPath::getAPathTo(handle);
MFnIkHandle fnHandle(handlePath, &stat);
// End-Effector
MDagPath endEffectorPath;
fnHandle.getEffector(endEffectorPath);
MFnIkEffector fnEffector(endEffectorPath);
MPoint effectorPos = fnEffector.rotatePivot(MSpace::kWorld);
unsigned int numJoints = endEffectorPath.length();
std::vector<MDagPath> jointsDagPaths; jointsDagPaths.reserve(numJoints);
while (endEffectorPath.length() > 1)
{
endEffectorPath.pop();
jointsDagPaths.push_back( endEffectorPath );
}
std::reverse(jointsDagPaths.begin(), jointsDagPaths.end());
static bool builtLocalSkeleton = false;
if (builtLocalSkeleton == false)
{
for (int jointIdx = 0; jointIdx < jointsDagPaths.size(); ++jointIdx)
{
MFnIkJoint curJoint(jointsDagPaths[jointIdx]);
m_localJointsPos.push_back( curJoint.getTranslation(MSpace::kWorld) );
}
m_localJointsPos.push_back(effectorPos );
builtLocalSkeleton = true;
}
MPoint startJointPos = MFnIkJoint(jointsDagPaths.front()).getTranslation(MSpace::kWorld);
MVector startToEndEff = m_localJointsPos.back() - m_localJointsPos.front();
double curveLength = (getPosition(1.0) - getPosition(0.0)).length();
double chainLength = startToEndEff.length(); // in local space.
double stretchFactor = curveLength / chainLength;
double uVal = 0.0f;
MVector jointPosL = m_localJointsPos[0];
for (int jointIdx = 0; jointIdx < jointsDagPaths.size(); ++jointIdx)
{
MFnIkJoint curJoint(jointsDagPaths[jointIdx]);
MVector curJointPosL = m_localJointsPos[jointIdx];
double dist = stretchFactor * (curJointPosL - jointPosL).length();
uVal = uVal + dist / curveLength;
MVector curCurveJointPos = getPosition(uVal);
curJoint.setTranslation(curCurveJointPos, MSpace::kWorld);
jointPosL = curJointPosL;
}
MVector effectorCurvePos = getPosition(1.0);
MVector curCurveJointPos = getPosition(uVal);
MVector effectorVec = (effectorCurvePos - curCurveJointPos).normal();
double endJointAngle[3];
MVector effectorVecXY = MVector(effectorVec(0), effectorVec(1), 0.0);
endJointAngle[2] = effectorVecXY.angle(MVector(1, 0, 0));
if ((MVector(1, 0, 0) ^ effectorVecXY) * MVector(0, 0, 1) < 0.0) { endJointAngle[2] = -endJointAngle[2]; }
MVector effectorVecXZ = MVector(effectorVec(0), 0.0, effectorVec(2));
endJointAngle[1] = effectorVecXZ.angle(MVector(1, 0, 0));
if ((MVector(1, 0, 0) ^ effectorVecXZ) * MVector(0, 1, 0) < 0.0) { endJointAngle[1] = -endJointAngle[1]; }
endJointAngle[0] = 0.0;
MFnIkJoint curJoint(jointsDagPaths.back()); curJoint.setRotation(endJointAngle, curJoint.rotationOrder());
return MS::kSuccess;
}
示例13: getObjectShadingGroups
bool getObjectShadingGroups(const MDagPath& shapeObjectDP, MObject& shadingGroup)
{
// if obj is a light, simply return the mobject
if (shapeObjectDP.hasFn(MFn::kLight))
shadingGroup = shapeObjectDP.node();
if (shapeObjectDP.hasFn(MFn::kMesh))
{
// Find the Shading Engines Connected to the SourceNode
MFnMesh fnMesh(shapeObjectDP.node());
// A ShadingGroup will have a MFnSet
MObjectArray sets, comps;
fnMesh.getConnectedSetsAndMembers(shapeObjectDP.instanceNumber(), sets, comps, true);
// Each set is a Shading Group. Loop through them
for (unsigned int i = 0; i < sets.length(); ++i)
{
shadingGroup = sets[i];
return true;
}
}
if (shapeObjectDP.hasFn(MFn::kNurbsSurface)||shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
{
MObject instObjGroupsAttr;
if (shapeObjectDP.hasFn(MFn::kNurbsSurface))
{
MFnNurbsSurface fnNurbs(shapeObjectDP.node());
instObjGroupsAttr = fnNurbs.attribute("instObjGroups");
}
if (shapeObjectDP.hasFn(MFn::kParticle)||shapeObjectDP.hasFn(MFn::kNParticle))
{
MFnParticleSystem fnPart(shapeObjectDP.node());
instObjGroupsAttr = fnPart.attribute("instObjGroups");
}
MPlug instPlug(shapeObjectDP.node(), instObjGroupsAttr);
// Get the instance that our node is referring to;
// In other words get the Plug for instObjGroups[intanceNumber];
MPlug instPlugElem = instPlug.elementByLogicalIndex(shapeObjectDP.instanceNumber());
// Find the ShadingGroup plugs that we are connected to as Source
MPlugArray SGPlugArray;
instPlugElem.connectedTo(SGPlugArray, false, true);
// Loop through each ShadingGroup Plug
for (unsigned int i=0; i < SGPlugArray.length(); ++i)
{
shadingGroup = SGPlugArray[i].node();
return true;
}
}
return false;
}
示例14: edge
MStatus meshOp::doIt( const MArgList& argList )
//
// Description:
// implements the MEL meshOp command.
//
// Arguments:
// argList - the argument list that was passes to the command from MEL
//
// Return Value:
// MS::kSuccess - command succeeded
// MS::kFailure - command failed (returning this value will cause the
// MEL script that is being run to terminate unless the
// error is caught using a "catch" statement.
//
{
MStatus status;
bool badArgument = false;
// Only one parameter is expected to be passed to this command: the mesh
// operation type. Get it, validate it or stop prematurely
//
if (argList.length() == 1)
{
int operationTypeArgument = argList.asInt(0);
if (operationTypeArgument < 0
|| operationTypeArgument > kMeshOperationCount - 1)
{
badArgument = true;
}
else
{
fOperation = (MeshOperation)operationTypeArgument;
}
}
else badArgument = true;
if (badArgument)
{
cerr << "Expecting one parameter: the operation type." << endl;
cerr << "Valid types are: " << endl;
cerr << " 0 - Subdivide edge(s)." << endl;
cerr << " 1 - Subdivide face(s)." << endl;
cerr << " 2 - Extrude edge(s)." << endl;
cerr << " 3 - Extrude face(s)." << endl;
cerr << " 4 - Collapse edge(s)." << endl;
cerr << " 5 - Collapse face(s)." << endl;
cerr << " 6 - Duplicate face(s)." << endl;
cerr << " 7 - Extract face(s)." << endl;
cerr << " 8 - Split face(s)." << endl;
cerr << " 8 - Chamfer vertex(s)." << endl;
displayError(" Expecting one parameter: the operation type.");
return MS::kFailure;
}
// Each mesh operation only supports one type of components
//
MFn::Type componentType = meshOpFty::getExpectedComponentType(fOperation);
// Parse the selection list for selected components of the right type.
// To simplify things, we only take the first object that we find with
// selected components and operate on that object alone.
//
// All other objects are ignored and return warning messages indicating
// this limitation.
//
MSelectionList selList;
MGlobal::getActiveSelectionList( selList );
MItSelectionList selListIter( selList );
selListIter.setFilter( MFn::kMesh );
// The meshOperation node only accepts a component list input, so we build
// a component list using MFnComponentListData.
//
// MIntArrays could also be passed into the node to represent the ids,
// but are less storage efficient than component lists, since consecutive
// components are bundled into a single entry in component lists.
//
MFnComponentListData compListFn;
compListFn.create();
bool found = false;
bool foundMultiple = false;
for( ; !selListIter.isDone(); selListIter.next() )
{
MDagPath dagPath;
MObject component;
selListIter.getDagPath( dagPath, component );
// Check for selected components of the right type
//
if( component.apiType() == componentType )
{
if( !found )
{
// The variable 'component' holds all selected components
// on the selected object, thus only a single call to
// MFnComponentListData::add() is needed to store the selected
// components for a given object.
//
compListFn.add( component );
//.........这里部分代码省略.........
示例15: displayError
MStatus closestPointOnCurveCommand::redoIt()
{
// DOUBLE-CHECK TO MAKE SURE THERE'S A SPECIFIED OBJECT TO EVALUATE ON:
if (sList.length() == 0)
{
MStatus stat;
MString msg = MStringResource::getString(kNoValidObject, stat);
displayError(msg);
return MStatus::kFailure;
}
// RETRIEVE THE SPECIFIED OBJECT AS A DAGPATH:
MDagPath curveDagPath;
sList.getDagPath(0, curveDagPath);
// CHECK FOR INVALID NODE-TYPE INPUT WHEN SPECIFIED/SELECTED NODE IS *NOT* A "CURVE" NOR "CURVE TRANSFORM":
if (!curveDagPath.node().hasFn(MFn::kNurbsCurve) && !(curveDagPath.node().hasFn(MFn::kTransform) && curveDagPath.hasFn(MFn::kNurbsCurve)))
{
MStatus stat;
MString msg;
// Use format to place variable string into message
MString msgFmt = MStringResource::getString(kInvalidType, stat);
MStringArray selectionStrings;
sList.getSelectionStrings(0, selectionStrings);
msg.format(msgFmt, selectionStrings[0]);
displayError(msg);
return MStatus::kFailure;
}
// WHEN COMMAND *NOT* IN "QUERY MODE" (I.E. "CREATION MODE"), CREATE AND CONNECT A "closestPointOnCurve" NODE AND RETURN ITS NODE NAME:
if (!queryFlagSet)
{
// CREATE THE NODE:
MFnDependencyNode depNodeFn;
if (closestPointOnCurveNodeName == "")
depNodeFn.create("closestPointOnCurve");
else
depNodeFn.create("closestPointOnCurve", closestPointOnCurveNodeName);
closestPointOnCurveNodeName = depNodeFn.name();
// SET THE ".inPosition" ATTRIBUTE, IF SPECIFIED IN THE COMMAND:
if (inPositionFlagSet)
{
MPlug inPositionXPlug = depNodeFn.findPlug("inPositionX");
inPositionXPlug.setValue(inPosition.x);
MPlug inPositionYPlug = depNodeFn.findPlug("inPositionY");
inPositionYPlug.setValue(inPosition.y);
MPlug inPositionZPlug = depNodeFn.findPlug("inPositionZ");
inPositionZPlug.setValue(inPosition.z);
}
// MAKE SOME ADJUSTMENTS WHEN THE SPECIFIED NODE IS A "TRANSFORM" OF A CURVE SHAPE:
unsigned instanceNumber=0;
if (curveDagPath.node().hasFn(MFn::kTransform))
{
// EXTEND THE DAGPATH TO ITS CURVE "SHAPE" NODE:
curveDagPath.extendToShape();
// TRANSFORMS ARE *NOT* NECESSARILY THE "FIRST" INSTANCE TRANSFORM OF A CURVE SHAPE:
//.........这里部分代码省略.........