// This example shows how to retrieve the control points returned by
// NurbsSurface.GetClosestSurfacePosition2
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSphere = oRoot.AddGeometry( "Sphere", "NurbsSurface" );
// Translate the sphere
oSphere.Kinematics.Global.Parameters("posx").value = oSphere.Kinematics.Global.Parameters("posx").value + 13;
var oPosition = XSIMath.CreateVector3();
oPosition.Set( 0.0, 0.0, 0.0 );
// convert VB array to JScript array
var vbArgs = new VBArray(oSphere.ActivePrimitive.Geometry.GetClosestSurfacePosition2(oPosition));
var args = vbArgs.toArray();
LogMessage( "The origin is closest to surface : " + args[0] + " its distance from it is " + Math.sqrt(args[1]) );
LogMessage( "The UV values are U : " + args[2] + " V :" + args[3] );
LogMessage( "The corresponding position is X : " + args[4].X + " Y :" + args[4].Y + " Z :" + args[4].Z );
|