A lot of tools, Plugin and native Maya API commands return closest point on surface, closest normal, closest intersection etc.
I wrote this tool for five reasons:
-
I wanted something that would return the closest CV, not the closest point on surface, because most of the time I needed to transfer deformer properties, rivet meshes together etc.
-
I wanted something that could return the closest CV of the closets object in a scene. This is why the command accept multiple objects as a input.
-
I needed something that would work not just on Polygons surfaces. closestCVonObject works on NURBS, curves and Polygons.
-
Sometimes you need more than the closest CV. This is the situation where you have two cvs on top of each other. You may want to get them both.
-
Finally I wanted to use it to do some kind of mapping if necessary, this is why you can pass multiple points. If you get all the cvs of one object and pass them to the command with the name of the object you are trying to get the mapping for, you will get as output a list that map each of the input points to the closest point of the destination surface.
The usage is pretty simple. Place the Plugin in your Plugin directory, load it and then use the following as guide:
closestCVsOnObjects px1 py1 pz1 OBJECT_NAME -np NUMBER_OF _POINTS
ex:
loadPlugin "
closestCVsOnObjects.mll";
polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;
polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
closestCVsOnObjects 0.2 0.2 0.2 pSphere1 pCube1;
Return:
// Result: pCube1.vtx[3] //
loadPlugin "closestCVsOnObjects.mll";
polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;
polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
closestCVsOnObjects 0.2 0.2 0.2 2 3 4 pSphere1 pCube1 -np 3;
Return:
// Result: pCube1.vtx[3] pSphere1.vtx[276] pSphere1.vtx[277] pSphere1.vtx[275] pSphere1.vtx[276] pSphere1.vtx[255] //
That mean that the 3 closest points to (0.2 0.2 0.2) are pCube1.vtx[3], pSphere1.vtx[276], pSphere1.vtx[277]
and the 3 closest points to (2,3,4) are pSphere1.vtx[275], pSphere1.vtx[276], pSphere1.vtx[255]
The ZIP file include a binary for Maya 2009 32bit, the source code and a README on how to install, use and compile the Plugin.
Let me know If you find any problem.
Please use the Feature Requests to give me ideas.
Please use the Support Forum if you have any questions or problems.
Please rate and review in the Review section.