本文整理汇总了C++中MDagPath::extendToShape方法的典型用法代码示例。如果您正苦于以下问题:C++ MDagPath::extendToShape方法的具体用法?C++ MDagPath::extendToShape怎么用?C++ MDagPath::extendToShape使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDagPath
的用法示例。
在下文中一共展示了MDagPath::extendToShape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testResults
MStatus exampleCameraSetViewCmd::testResults(MPx3dModelView &view)
{
MObject cstObj = MObject::kNullObj;
MStatus stat = view.getCameraSet(cstObj);
if (stat != MS::kSuccess)
return stat;
cout << "fCameraList.length() = " << fCameraList.length() << endl;
cout << "fCameraList = " << fCameraList << endl;
MFnCameraSet cstFn(cstObj);
unsigned int numLayers = cstFn.getNumLayers();
cout << "view.cameraSet.numLayers = " << numLayers << endl;
cout << "Cameras:" << endl;
for (unsigned int i=0; i<numLayers; i++)
{
MDagPath camPath;
cstFn.getLayerCamera(i, camPath);
camPath.extendToShape();
cout << " " << camPath.fullPathName() << endl;
}
return MS::kSuccess;
}
示例2: cacheMeshData
MStatus polyModifierCmd::cacheMeshData()
{
MStatus status = MS::kSuccess;
MFnDependencyNode depNodeFn;
MFnDagNode dagNodeFn;
MObject meshNode = fDagPath.node();
MObject dupMeshNode;
MPlug dupMeshNodeOutMeshPlug;
// Duplicate the mesh
//
dagNodeFn.setObject( meshNode );
dupMeshNode = dagNodeFn.duplicate();
MDagPath dupMeshDagPath;
MDagPath::getAPathTo( dupMeshNode, dupMeshDagPath );
dupMeshDagPath.extendToShape();
depNodeFn.setObject( dupMeshDagPath.node() );
dupMeshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status );
MCheckStatus( status, "Could not retrieve outMesh" );
// Retrieve the meshData
//
status = dupMeshNodeOutMeshPlug.getValue( fMeshData );
MCheckStatus( status, "Could not retrieve meshData" );
// Delete the duplicated node
//
MGlobal::deleteNode( dupMeshNode );
return status;
}
示例3: doIt
MStatus DDConvexHullCmd::doIt(const MArgList& args)
{
if (args.length() != 1)
{
MGlobal::displayError("Needs at least 2 args");
return MS::kFailure;
}
MString input = args.asString(0);
MString output = args.asString(1);
// Get the mObject for the input
MSelectionList selList;
selList.add(input);
MDagPath inputMesh;
selList.getDagPath(0, inputMesh);
// Ensure we're looking at the shape
inputMesh.extendToShape();
// Create output object
MDagModifier dm;
MObject outMeshNode = dm.createNode(MFn::kMesh);
MFnDependencyNode outMeshDag(outMeshNode);
outMeshDag.setName("poopShape#");
DDConvexHullUtils::hullOpts hullOptions;
return DDConvexHullUtils::generateMayaHull(outMeshNode,
inputMesh.node(), hullOptions);
}
示例4: onOtherNode
void liqIPRNodeMessage::onOtherNode(const MString &node, std::vector<MString> &updateObjectName)
{
MStringArray descendents;
MString cmd("listRelatives -allDescendents "+node);
MGlobal::executeCommand(cmd, descendents);
for(int i=0; i<descendents.length(); ++i)
{
addUpdateObject(updateObjectName, descendents[i]);//record descendents[i]
MDagPath dagPath;
getDagPathByName(dagPath, descendents[i].asChar());
if( dagPath.node().hasFn(MFn::kTransform) )
{
onOtherNode(descendents[i], updateObjectName);//visit descendents[i]
}
else if( dagPath.node().hasFn(MFn::kMesh) )
{
std::vector<std::string> shaderPlugs;
liquid::RendererMgr::getInstancePtr()->
getRenderer()->getValidShaderPlugsInShadingGroup(shaderPlugs);
IfMErrorWarn(dagPath.extendToShape());//extend to shape
std::vector<std::string> shadingGroups;
getShadingGroups(dagPath.fullPathName(), shadingGroups);
for(std::size_t j=0; j<shadingGroups.size(); ++j)//for each shading group
{
MString shadingGroup(shadingGroups[j].c_str());
for(std::size_t k=0; k<shaderPlugs.size(); ++k)//for each shader plug
{
MString shaderPlug(shaderPlugs[k].c_str());
int isShaderPlugExist;
cmd = "attributeQuery -node \""+shadingGroup+"\" -ex \""+shaderPlug+"\"";
IfMErrorMsgWarn(MGlobal::executeCommand( cmd, isShaderPlugExist), cmd);
if( isShaderPlugExist )
{
//get the source shade node of $shadingGroup.$shaderPlug
MStringArray shaders;
cmd = "listConnections -s true -d false -plugs false (\""+shadingGroup+"\" + \"."+shaderPlug+"\")";
IfMErrorMsgWarn(MGlobal::executeCommand( cmd, shaders), cmd);
if( shaders.length() > 0 )//has source shader node
{
onShaderNode(shaders[0], updateObjectName);
}//if( shaders.length() > 0 )//has source shader node
}//if( isShaderPlugExist )
}//for each shader plug
}//for each shading group
}//kMesh
}//for(int i=0; i<descendents.length(); ++i)
}
示例5: doIt
MStatus polyMessageCmd::doIt( const MArgList& )
//
// Takes the nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
MStatus stat;
MObject node;
MSelectionList list;
MCallbackId id;
// Register node callbacks for all nodes on the active list.
//
MGlobal::getActiveSelectionList( list );
for ( unsigned int i=0; i<list.length(); i++ )
{
list.getDependNode( i, node );
MDagPath dp;
MObject shapeNode = node;
if ( MS::kSuccess == MDagPath::getAPathTo( node, dp ) )
if ( MS::kSuccess == dp.extendToShape() )
shapeNode = dp.node();
bool wantIdChanges[3];
wantIdChanges[MPolyMessage::kVertexIndex] = true;
wantIdChanges[MPolyMessage::kEdgeIndex] = true;
wantIdChanges[MPolyMessage::kFaceIndex] = true;
id = MPolyMessage::addPolyComponentIdChangedCallback( shapeNode,
wantIdChanges, 3,
userCB,
NULL,
&stat);
// If the callback was successfully added then add the
// callback id to our callback table so it can be removed
// when the plugin is unloaded.
//
if ( stat ) {
callbackIds.append( id );
} else {
cout << "MPolyMessage.addCallback failed\n";
}
}
return stat;
}
示例6: getTCCNode
MStatus updateTCCData::getTCCNode( MSelectionList &selList )
{
MStatus status;
MItSelectionList selListIter( selList );
selListIter.setFilter( MFn::kMesh );
for( ; !selListIter.isDone(); selListIter.next() )
{
MDagPath dagPath;
MObject component;
selListIter.getDagPath( dagPath, component );
status = dagPath.extendToShape();
if (status == MS::kSuccess)
{
MFnDependencyNode meshShapeFn(dagPath.node());
MObject outMeshAttr = meshShapeFn.attribute( "outMesh" );
MPlug outMeshPlug(dagPath.node(), outMeshAttr );
// worldMeshPlug = worldMeshPlug.elementByLogicalIndex( 0 );
cout<<"inMesh-connected dagnode name: "<<endl<<" > "<<outMeshPlug.info().asChar()<<endl;
MPlugArray plugArray;
outMeshPlug.connectedTo(plugArray, true, true);
cout<<"connected attrs: "<<plugArray.length()<<endl;
for (size_t k=0; k<plugArray.length(); k++)
{
MObject TCCnode(plugArray[k].node());
MFnDependencyNode TCCDepNode( TCCnode );
cout<<"Dependency node type: "<<TCCDepNode.typeName().asChar()<<endl;
if (TCCDepNode.typeName() == "TCC")
{
fSrcDagPath = dagPath;
fTCCnode = TCCnode;
fComponent = component;
return MS::kSuccess;
}
}
}
}
return MS::kFailure;
}
示例7:
void
OpenSubdivPtexShaderOverride::addTopologyChangedCallbacks( const MDagPath& dagPath, OsdPtexMeshData *data )
{
MStatus status = MS::kSuccess;
// Extract shape node and add callback to let us know when an attribute changes
MDagPath meshDagPath = dagPath;
meshDagPath.extendToShape();
MObject shapeNode = meshDagPath.node();
MCallbackId id = MNodeMessage::addAttributeChangedCallback(shapeNode,
attrChangedCB, data, &status );
if ( status ) {
_callbackIds.append( id );
} else {
cerr << "MNodeMessage.addCallback failed" << endl;
}
}
示例8: doItQuery
void skinClusterWeights::doItQuery()
{
MStatus status;
unsigned int i, j;
MDoubleArray weights;
// To allow "skinClusterWeights -q" to return empty double array
setResult(weights);
MSelectionList selList;
for (i = 0; i < geometryArray.length(); i++) {
MDagPath dagPath;
MObject component;
selList.clear();
selList.add(geometryArray[i]);
MStatus status = selList.getDagPath(0, dagPath, component);
if (status != MS::kSuccess) {
continue;
}
if (component.isNull()) dagPath.extendToShape();
MObject skinCluster = findSkinCluster(dagPath);
if (!isSkinClusterIncluded(skinCluster)) {
continue;
}
MFnSkinCluster skinClusterFn(skinCluster, &status);
if (status != MS::kSuccess) {
continue;
}
MIntArray influenceIndexArray;
populateInfluenceIndexArray(skinClusterFn, influenceIndexArray);
weights.clear();
skinClusterFn.getWeights(dagPath, component, influenceIndexArray, weights);
if (weights.length() > 0) {
for (j = 0; j < weights.length(); j++) {
appendToResult(weights[j]);
}
}
}
}
示例9: getAABB
void btSPHCmd::getAABB(const MString &name, MPoint& min, MPoint &max)
{
_LogFunctionCall("btSPHCmd::getAABB("<< name<<")");
MStatus status = MS::kSuccess;
MSelectionList sList;
IfMErrorWarn(MGlobal::getSelectionListByName(name, sList));
assert(sList.length()==1);
MDagPath dp;
IfMErrorWarn(sList.getDagPath(0, dp));
IfMErrorWarn(dp.extendToShape());//particle shape
MFnMesh meshFn( dp, &status );
IfMErrorWarn(status);
MPointArray positions;
IfMErrorWarn(meshFn.getPoints(positions, MSpace::kWorld));
const size_t LEN = positions.length();
for(size_t i=0; i<LEN; ++i)
{
const MPoint &p = positions[i];
if(p.x<min.x) min.x = p.x;
if(p.y<min.y) min.y = p.y;
if(p.z<min.z) min.z = p.z;
if(p.x>max.x) max.x = p.x;
if(p.y>max.y) max.y = p.y;
if(p.z>max.z) max.z = p.z;
}
// MPlug plug;
// getPlugValue_asDistance(min.x, meshFn, "boundingBoxMinX");
// getPlugValue_asDistance(min.y, meshFn, "boundingBoxMinY");
// getPlugValue_asDistance(min.z, meshFn, "boundingBoxMinZ");
// getPlugValue_asDistance(max.x, meshFn, "boundingBoxMaxX");
// getPlugValue_asDistance(max.y, meshFn, "boundingBoxMaxY");
// getPlugValue_asDistance(max.z, meshFn, "boundingBoxMaxZ");
}
示例10: updateLightList
//
// Method to add in a light "prune" list. Only selected
// lights will be have their shadows requested, and
// be used for the scene render shader override.
//
MStatus viewRenderOverrideShadows::updateLightList()
{
mLightList.clear();
shadowPrepass* shadowOp = (shadowPrepass*)mRenderOperations[kShadowPrePass];
sceneRender* sceneOp = (sceneRender*)mRenderOperations[kMaya3dSceneRender];
if (!shadowOp || !sceneOp)
return MStatus::kFailure;
// Scan selection list for active lights
//
MSelectionList selectList;
MDagPath dagPath;
MObject component;
MGlobal::getActiveSelectionList( selectList );
for (unsigned int i=0; i<selectList.length(); i++)
{
selectList.getDagPath( i, dagPath, component );
dagPath.extendToShape();
if ( dagPath.hasFn( MFn::kLight ) )
{
mLightList.add( dagPath );
}
}
// Set light list to prune which lights to request shadows for
//
if (mLightList.length())
shadowOp->setLightList( &mLightList );
else
shadowOp->setLightList( NULL );
// Set light list to prune which lights to bind for scene shader
//
if (mLightList.length())
sceneOp->setLightList( &mLightList );
else
sceneOp->setLightList( NULL );
return MStatus::kSuccess;
}
示例11: getInCurveInfo
void vixo_hairCacheExport::getInCurveInfo(map<int,int>& plugMapVID,MString vixoHairNode,map<int,MVectorArray>& inCurveShape)
{
MSelectionList slist;
MGlobal::getSelectionListByName(vixoHairNode,slist);
MDagPath vixoHairNodeDag;
slist.getDagPath(0,vixoHairNodeDag);
vixoHairNodeDag.extendToShape();
MFnDagNode fnVixoHair(vixoHairNodeDag);
MPlug plugInCtrlCurveData=fnVixoHair.findPlug("inCtrlCurveData");
map<int,int>::iterator iterPlugMapVID;
for(iterPlugMapVID=plugMapVID.begin();iterPlugMapVID!=plugMapVID.end();iterPlugMapVID++)
{
MPlug inCurvePlug=plugInCtrlCurveData.elementByLogicalIndex(iterPlugMapVID->first);
MFnVectorArrayData fnVector(inCurvePlug.asMObject());
MVectorArray data=fnVector.array();
MVectorArray tangent(data.length()-1);
MPlugArray tempArr;
inCurvePlug.connectedTo(tempArr,true,false);
MFnDependencyNode fnHairSystem(tempArr[0].node());
MPlug inputHairs=fnHairSystem.findPlug("inputHair");
tempArr.clear();
inputHairs.elementByLogicalIndex(iterPlugMapVID->first).connectedTo(tempArr,true,false);
MFnDependencyNode fnFolli(tempArr[0].node());
MFnMatrixData fnMatData(fnFolli.findPlug("worldMatrix[0]").asMObject());
MMatrix mat=fnMatData.matrix();
for(int i=0;i<data.length()-1;i++)
{
tangent[i]=data[i+1]*mat-data[i]*mat;
}
inCurveShape.insert(pair<int,MVectorArray>(iterPlugMapVID->second,tangent));
}
}
示例12: iter
void
VertexPolyColourCommand::CreateJobListFromSelection(MSelectionList& selection)
{
// Go through the selection looking for relevant geometry and add them to the list of jobs
MItSelectionList iter(selection);
for ( ; !iter.isDone(); iter.next() )
{
MDagPath dagPath;
MObject component;
iter.getDagPath( dagPath, component );
// check node type
if (dagPath.node().hasFn(MFn::kTransform) || dagPath.node().hasFn(MFn::kPolyMesh) || dagPath.node().hasFn(MFn::kMesh))
{
if (component.isNull() || m_operation == OP_UpdateLayerComposite)
{
dagPath.extendToShape();
AddJob(dagPath, MObject::kNullObj);
}
else
{
switch (component.apiType())
{
case MFn::kMeshComponent:
case MFn::kMeshEdgeComponent:
case MFn::kMeshPolygonComponent:
case MFn::kMeshVertComponent:
case MFn::kMeshVtxFaceComponent:
case MFn::kMeshMapComponent:
dagPath.extendToShape();
AddJob(dagPath, component);
break;
default:
break;
}
}
}
}
for (size_t i = 0; i < m_meshes.size(); i++)
{
MeshData* meshData = m_meshes[i];
if (!MeshHasConstructionHistory(meshData->dagPath))
{
m_isRestoreSelection = true;
MString meshName = meshData->mesh->fullPathName();
//MGlobal::executeCommand(MString("select -r ") + meshName);
//MGlobal::executeCommand("polySmooth -divisions 0");
MGlobal::executeCommand(MString("polySmooth -divisions 0") + meshName);
meshData->BuildMesh();
}
/*
MPlug outMeshPlug, inMeshPlug;
MObject intermediate;
AddConstructionHistory(meshData->dagPath, outMeshPlug, inMeshPlug, intermediate, NULL);
*/
}
}
示例13: PerspectiveCamera_Synchronize
HRESULT CMayaManager::PerspectiveCamera_Synchronize()
{
MDagPath MayaCamera;
M3dView panel;
for(UINT iView= 0; iView < M3dView::numberOf3dViews(); iView++)
{
D3DXMATRIX mCamera;
M3dView::get3dView(iView, panel);
panel.getCamera(MayaCamera);
MayaCamera.pop();
MString perspNameStr( "persp" );
MString cameraNameStr = MayaCamera.partialPathName();
cameraNameStr = cameraNameStr.substring(0, perspNameStr.length()-1 );
const char* cameraName= cameraNameStr.asChar();
if(cameraNameStr == perspNameStr )
{
MayaCamera.extendToShape();
MFloatMatrix fView(MayaCamera.inclusiveMatrix().matrix );
ConvertWorldMatrix(mCamera, fView);
panel.getCamera(MayaCamera);
MFnCamera fnMayaCamera(MayaCamera.node());
MVector mUp= fnMayaCamera.upDirection();
MVector mAt= fnMayaCamera.viewDirection();
MPoint mEye= fnMayaCamera.eyePoint(MSpace::kWorld);
D3DXVECTOR3 dxEye( (float)mEye.x, (float)mEye.y, (float)-mEye.z );
D3DXVECTOR3 dxAt( (float)mAt.x, (float)mAt.y, (float)-mAt.z );
D3DXVECTOR3 dxUp( (float)mUp.x, (float)mUp.y, (float)-mUp.z );
D3DXVECTOR4 fEye;
D3DXVECTOR4 fAt;
D3DXVECTOR3 fUp;
D3DXVec3Transform(&fEye, &dxEye,(D3DXMATRIX*)&mCamera);
D3DXVec3Transform(&fAt, &dxAt,(D3DXMATRIX*)&mCamera);
D3DXVec3TransformNormal(&fUp, &dxUp,(D3DXMATRIX*)&mCamera);
D3DXMatrixLookAtLH(&PerspectiveCamera_View,
(D3DXVECTOR3*)&fEye,
(D3DXVECTOR3*)&fAt,
&fUp);
// Projection matrix
float zNear = (float)fnMayaCamera.nearClippingPlane();
float zFar = (float)fnMayaCamera.farClippingPlane();
float hFOV = (float)fnMayaCamera.horizontalFieldOfView();
float f = (float) (1.0f / (float) tan( hFOV / 2.0f ));
ZeroMemory( &PerspectiveCamera_Projection, sizeof(PerspectiveCamera_Projection) );
PerspectiveCamera_Projection._11 = f;
PerspectiveCamera_Projection._22 = f;
PerspectiveCamera_Projection._33 = (zFar+zNear) / (zFar-zNear);
PerspectiveCamera_Projection._34 = 1.0f;
PerspectiveCamera_Projection._43 = -2 * (zFar*zNear)/(zFar-zNear);
break;
}
}
return S_OK;
}
示例14: doIt
MStatus SplitFromImage::doIt(const MArgList& args) {
MSelectionList list;
MGlobal::getActiveSelectionList(list);
MObject node;
MFnDependencyNode depFn;
MStringArray types;
MString name;
MDagPath dag;
for( MItSelectionList iter( list ); !iter.isDone(); iter.next() ) {
// Print the types and function sets of all of the objects
iter.getDependNode( node );
depFn.setObject( node );
name = depFn.name();
MGlobal::getFunctionSetList( node, types );
cout << "Name: " << name.asChar() << endl;
cout << "Type: " << node.apiTypeStr() << endl;
/*cout << "Function Sets: ";
for(unsigned int i = 0; i < types.length(); i++ ) {
if ( i > 0 ) cout << ", ";
cout << types[i].asChar();
}
cout << endl << endl;*/
// Check if object has a MDagPath
if(iter.getDagPath( dag ) == MS::kSuccess) {
// Get the MFnMesh from the MDagPath
dag.extendToShape();
MFnMesh mesh(dag.node());
//MPointArray points;
//mesh.getPoints(points);
//MFloatArray uPoints;
//MFloatArray vPoints;
//mesh.getUVs(uPoints, vPoints);
//for (unsigned int i = 0; i < uPoints.length(); i++) {
// cout << "uPoints[" << i << "]: " << uPoints[i] << endl;
//}
//for(unsigned int i = 0; i < points.length(); i++) {
// cout << "Points[" << i << "]: " << points[i] << endl;
//}
if (splitFromBinaryImage(mesh, args.asString(0)) == MS::kSuccess) {
cout << "Splitted image!" << endl;
}
else {
cout << "Could not split image!" << endl;
}
}
else {
cout << "Selected object has no MDagPath!" << endl << endl;
}
}
return MS::kSuccess;
}
示例15: doIt
MStatus MayaToCorona::doIt( const MArgList& args)
{
MStatus stat = MStatus::kSuccess;
MGlobal::displayInfo("Executing mayaToCorona...");
logger.setLogLevel(Logging::Debug);
MArgDatabase argData(syntax(), args);
int width = -1;
int height = -1;
MayaScene *mayaScene = MayaTo::MayaSceneFactory().getMayaScene();
if( !mayaScene->good )
{
logger.error("Problems have occurred during creation of mayaScene(). Sorry cannot proceed.\n\n");
MayaTo::MayaSceneFactory().deleteMaysScene();
return MS::kFailure;
}
if ( argData.isFlagSet("-width", &stat))
{
argData.getFlagArgument("-width", 0, width);
logger.debug(MString("width: ") + width);
if( width > 0 )
mayaScene->renderGlobals->imgWidth = width;
}
if ( argData.isFlagSet("-height", &stat))
{
argData.getFlagArgument("-height", 0, height);
logger.debug(MString("height: ") + height);
if( height > 0 )
mayaScene->renderGlobals->imgHeight = height;
}
if ( argData.isFlagSet("-stopIpr", &stat))
{
logger.debug(MString("-stopIpr"));
EventQueue::Event e;
e.type = EventQueue::Event::IPRSTOP;
theRenderEventQueue()->push(e);
return MS::kSuccess;
}
if ( argData.isFlagSet("-pauseIpr", &stat))
{
logger.debug(MString("-pauseIpr"));
logger.debug(MString("-stopIpr"));
EventQueue::Event e;
e.type = EventQueue::Event::IPRPAUSE;
theRenderEventQueue()->push(e);
return MS::kSuccess;
}
if ( argData.isFlagSet("-startIpr", &stat))
{
logger.debug(MString("-startIpr"));
mayaScene->setRenderType(MayaScene::IPR);
}
if ( argData.isFlagSet("-camera", &stat))
{
MDagPath camera;
MSelectionList selectionList;
argData.getFlagArgument("-camera", 0, selectionList);
stat = selectionList.getDagPath(0, camera);
camera.extendToShape();
logger.debug(MString("camera: ") + camera.fullPathName());
mayaScene->setCurrentCamera(camera);
}
EventQueue::Event e;
e.type = EventQueue::Event::INITRENDER;
theRenderEventQueue()->push(e);
RenderQueueWorker::startRenderQueueWorker();
return MStatus::kSuccess;
}