|
Good morning,
I have the sample code below.
The selected object in the scene is a polygonal sphere positionned in the Y positive axis so that it has an intersection with the ray defined by
origin (0,0,0) and direction (0,1,0).
The result of the closestIntersection method is false !
I don’t know if the mistake is in getting the selected object or in the closestIntersection call.
Does someone see what’s wrong with my code ?
Thank you.
Chris.
MSelectionList listeObjetsSelectionnes;
MGlobal::getActiveSelectionList(listeObjetsSelectionnes)
MDagPath dagPath;
MObject obj;
listeObjetsSelectionnes.getDagPath(0,dagPath, obj)
MFnDagNode * dagNode = new MFnDagNode;
dagNode->setObject(dagPath)
cout << "objet selectionne : " << dagNode->name() << endl;
// -------------------------------------------------------
if (dagNode->typeName() == "transform")
{
obj = dagNode->child(0)
dagNode->setObject(obj)
}
cout << "type : " << obj.apiTypeStr() << endl;
int type = obj.apiType()
if (type == MFn::kMesh)
{
MFloatPoint ptInters;
int res = ((MFnMesh*)dagNode)->closestIntersection (MFloatPoint(0,0,0), MFloatVector(0,1,0), NULL, NULL, 0,
MSpace::kWorld, 1000, false,
NULL, ptInters, NULL, NULL, NULL, NULL, NULL)
cout << "ptInters : " << ptInters << endl;
cout << "res : " << res << endl;
}
|