View Single Post
# 1 31-10-2008 , 01:19 AM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567

closestPointOnMesh node

Hi, I'm having problems with the closest/nearestPointOnMesh (depending on Maya version). I want to collect the nearest face on the mesh to the locator. This is because I want to eventually be able to draw a curve on the surface and select the faces the curve goes over. The node returns a seemingly random 'closestFaceIndex' number, that is nowhere near the locator's posiiton. Below is what I have at mo...


// create closestPointOnMesh node
string $closestPoint = eval("createNode closestPointOnMesh -n cpom1");

//connect it to the polymesh
connectAttr -f pPlane1.outMesh ($closestPoint + ".inMesh");

//connect locator1 pos' to closestPointOnMesh pos'
connectAttr -f locator1.translateX cpom1.inPositionX;
connectAttr -f locator1.translateY cpom1.inPositionY;
connectAttr -f locator1.translateZ cpom1.inPositionZ;

//store face index
int $selectedFaces = `getAttr cpom1.closestFaceIndex`;


Has anyone had anyluck with this node, am I going about this the wrong way?

Any help/advice/suggestions would be very welcome

Many thanks,

Chris