本文整理汇总了C++中MFnMesh::anyIntersection方法的典型用法代码示例。如果您正苦于以下问题:C++ MFnMesh::anyIntersection方法的具体用法?C++ MFnMesh::anyIntersection怎么用?C++ MFnMesh::anyIntersection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MFnMesh
的用法示例。
在下文中一共展示了MFnMesh::anyIntersection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doIt
MStatus intersectCmd::doIt(const MArgList& args)
// Description:
// Determine if the ray from the spotlight intersects the mesh.
// If it does, display the intersection points.
{
MStatus stat = MStatus::kSuccess;
if (args.length() != 2)
{
MGlobal::displayError("Need 2 items!");
return MStatus::kFailure;
}
MSelectionList activeList;
int i;
for ( i = 0; i < 2; i++)
{
MString strCurrSelection;
stat = args.get(i, strCurrSelection);
if (MStatus::kSuccess == stat) activeList.add(strCurrSelection);
}
MItSelectionList iter(activeList);
MFnSpotLight fnLight;
MFnMesh fnMesh;
MFnDagNode dagNod;
MFnDependencyNode fnDN;
float fX = 0;
float fY = 0;
float fZ = 0;
for ( ; !iter.isDone(); iter.next() )
{
MObject tempObjectParent, tempObjectChild;
iter.getDependNode(tempObjectParent);
if (tempObjectParent.apiType() == MFn::kTransform)
{
dagNod.setObject(tempObjectParent);
tempObjectChild = dagNod.child(0, &stat);
}
// check what type of object is selected
if (tempObjectChild.apiType() == MFn::kSpotLight)
{
MDagPath pathToLight;
MERR_CHK(MDagPath::getAPathTo(tempObjectParent, pathToLight), "Couldn't get a path to the spotlight");
MERR_CHK(fnLight.setObject(pathToLight), "Failure on assigning light");
stat = fnDN.setObject(tempObjectParent);
MPlug pTempPlug = fnDN.findPlug("translateX", &stat);
if (MStatus::kSuccess == stat)
{
pTempPlug.getValue(fX);
}
pTempPlug = fnDN.findPlug("translateY", &stat);
if (MStatus::kSuccess == stat)
{
pTempPlug.getValue(fY);
}
pTempPlug = fnDN.findPlug("translateZ", &stat);
if (MStatus::kSuccess == stat)
{
pTempPlug.getValue(fZ);
}
}
else if (tempObjectChild.apiType() == MFn::kMesh)
{
MDagPath pathToMesh;
MERR_CHK(MDagPath::getAPathTo(tempObjectChild, pathToMesh), "Couldn't get a path to the spotlight");
MERR_CHK(fnMesh.setObject(pathToMesh), "Failure on assigning light");
}
else
{
MGlobal::displayError("Need a spotlight and a mesh");
return MStatus::kFailure;
}
}
MFloatPoint fpSource(fX, fY, fZ);
MFloatVector fvRayDir = fnLight.lightDirection(0, MSpace::kWorld, &stat);
MFloatPoint hitPoint;
MMeshIsectAccelParams mmAccelParams = fnMesh.autoUniformGridParams();
float fHitRayParam, fHitBary1, fHitBary2;
int nHitFace, nHitTriangle;
// a large positive number is used here for the maxParam parameter
bool bAnyIntersection = fnMesh.anyIntersection(fpSource, fvRayDir, NULL, NULL, false, MSpace::kWorld, (float)9999, false, &mmAccelParams, hitPoint, &fHitRayParam, &nHitFace, &nHitTriangle, &fHitBary1, &fHitBary2, (float)1e-6, &stat);
if (! bAnyIntersection)
{
//.........这里部分代码省略.........