View Single Post
# 2 31-10-2008 , 11:11 PM
bendingiscool's Avatar
Subscriber
Join Date: Jul 2006
Location: London
Posts: 567
OK I have this so far, it loops through creating a locator in a random pos (for test purposes), then it makes a new 'nearestPointOnMesh' node each time and an int to grab the value of the 'faceIndex'.

Unfortunatly it seems to be averaging out the position and selecting the face in the middle of the locators, rather than grabbing each face as it goes through. Does anyone know what I'm doing wroung here?


for ($i=1;$i<5;$i++){
spaceLocator -p (rand(-10,10)) 0 (rand(-10,10)) -n ("locator" + $i);

string $nearestPoint = `createNode nearestPointOnMesh -n ("npom" + $i)`;

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

//connect locator1 pos' to nearestPointOnMesh pos'
connectAttr -f (("locator" + $i) + ".translateX") (("npom" + $i) + ".inPositionX");
connectAttr -f (("locator" + $i) + ".translateY") (("npom" + $i) + ".inPositionY");
connectAttr -f (("locator" + $i) + ".translateZ") (("npom" + $i) + ".inPositionZ");

//store face index
int $selFaces = `getAttr (("npom" + $i) + ".nearestFaceIndex")`;

select -add pPlane1.f[$selFaces];
}


Any input would be greatly apreciated,

Chris