X3DObject.AddPolygonMesh

Description

Creates a PolygonMesh object. This is typically used for creating a polygon mesh from a set of geometry data.

Scripting Syntax

oReturn = X3DObject.AddPolygonMesh( [Vertices], [PolygonData], [Name] );

Return Value

Returns the X3DObject parent of the new geometry. The new X3DObject is parented under this X3DObject.

Parameters

Parameter Type Description
Vertices Array Array representing the polygon vertices. The array is either a 1D ordered array of x,y,z values or a 2D array (Nx3) of x,y,z values.
PolygonData Array An ordered array of polygon definitions, each polygon is defined by a list of elements, the first element of a polygon definition must be set with the number of indices for that polygon. The ordering of vertices must respect a ccw ordering to get out going normals (right-hand rule). For example, an array of polygons with 4 indices each = {4,0,1,4,3,4,1,2,5,4... }
Name String name of object

Examples

1. VBScript Example

NewScene , false
points = Array(_
        -1., 0., -1., _
        -1., 0., 0., _
        -1., 0., 1., _
        0., 0., -1., _
        0., 0., 0., _
        0., 0., 1., _
        1., 0., -1., _
        1., 0., 0., _
        1., 0., 1. _
)
data = Array( _
        4,0,1,4,3, _
        4,1,2,5,4, _
        4,3,4,7,6, _
        4,4,5,8,7 _
)
set oRoot = ActiveProject.ActiveScene.Root
set oPolyMesh = oRoot.AddPolygonMesh( points, data, "MyMesh" )
Application.LogMessage TypeName(oPolyMesh)
' Expected results:
'INFO : X3DObject

2. JScript Example

NewScene( null, false );
var oRoot = Application.ActiveSceneRoot;
var aVertices = new Array(0,0,0, 0,0,1, 1,0,1, 1,0,0);
var aPolygons = new Array(4,0,1,2,3);
oRoot.AddPolygonMesh( aVertices, aPolygons, "MyPolygonMesh" );