Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Plugins - Extensions / Problem with closestIntersection in MFnMesh or in getting the selected object (bad example code appearence in the previous mail)
  RSS 2.0 ATOM  

Problem with closestIntersection in MFnMesh or in getting the selected object (bad example code appearence in the previous mail)
Rate this thread
 
36849
 
Permlink of this thread   Subscribe to this thread
avatar
  • chrisChev
  • Posted: 18 November 2009 10:00 PM
  • Total Posts: 3
  • Joined: 19 November 2009 03:34 AM

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,dagPathobj)
 
 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)NULLNULL0
 
MSpace::kWorld1000false
 
NULLptIntersNULLNULLNULLNULLNULL)
   cout 
<< "ptInters : " << ptInters << endl;
   
cout << "res : " << res << endl;
   
}


Replies: 0




   
  Settings Choose Theme color: