Command Name

closestPointOnMesh

Synopsis

closestPointOnMesh -mesh -position

ReturnValue

[float[]] : Float array of result data with 9 elements (0-8).
Index
Data
0
Polygon ID
1
Position X
2
Position Y
3
Position Z
4
Normal X
5
Normal Y
6
Normal Z
7
U Value
8
V Value

Description

The closestPointOnMesh command allows you to query the closest point on a polygonal mesh to a specified position.  The command returns the id of the closest polygon, the closest point on that polygon, the normal of the polygon, and the closest U and V coordinates on the polygon.  The results are returned as a float array that has 9 elements.  

Flags

-m/-mesh
STRING
name of the polygonal mesh to sample
-p/-position
DOUBLE DOUBLE DOUBLE
position in world space to sample

Examples

//  Sample the polygonal mesh, polySphereShape1 at position 5, -3, 10
//
float $results[] = `closestPointOnMesh -mesh "polySphereShape1" -position "5,-3,10"';

//  Results
5, 13.2, -1, 8,  .2, .7, .1, .3, .4