/*
This example uses point locators to place a null positioned
and oriented to a surface location corresponding to each
control vertex of the NURBS sphere.
*/
NewScene( null, false );
var root = Application.ActiveSceneRoot;
var SphereGeom = root.AddGeometry("Sphere", "NurbsSurface").ActivePrimitive.Geometry;
var PointLocatorsFromSpherePoints = SphereGeom.GetSurfacePointLocatorsFromPoints();
CreateNullsAtPointLocations(SphereGeom, PointLocatorsFromSpherePoints);
function CreateNullsAtPointLocations( InGeom, InPointLocators )
{
var SpherePositions = InGeom.EvaluatePositions(InPointLocators).toArray();
var SphereNormals = InGeom.EvaluateNormals(InPointLocators).toArray();
var TempVector = XSIMath.CreateVector3();
var TempRotation = XSIMath.CreateRotation();
for (i = 0; i < SpherePositions.length; i+=3)
{
var NullObj = root.AddNull();
TempVector.Set(SpherePositions[i], SpherePositions[i+1], SpherePositions[i+2]);
NullObj.LocalTranslation = TempVector;
TempVector.Set(SphereNormals[i], SphereNormals[i+1], SphereNormals[i+2]);
TempRotation.SetFromXYZAxes( TempVector, TempVector, TempVector );
NullObj.LocalRotation = TempRotation;
}
} |