Face.<...>

Return to Introduction  Previous page  Next page

Allows manipulation of a single face in a mesh.

 

Methods

 

flip()

Reverses the order of v1 and v2 so that the face is flipped over.

 

Properties

 

v0, v1, v2

Indices of the 3 vertices used to make up the face.

materialIndex

An index of which material on this submesh to use for this face.  This index is looked up in a table at Subgroup level, so you may need to make changes to that table to introduce new materials - see the setMaterialMap function there.

 

Examples

 

function onClick()

{

       var verts=object.subgroups.Box.vertexGetArray(); // get all the vertices in the Box subgroup

       verts[15].pos.x+=10; // move a vertex +10 along the X axis

       object.subgroups.Box.vertexSetArray(verts); // save changes

 

       var faces=object.subgroups.Box.faceGetArray(); // get all the faces in the Box subgroup

       faces[0].materialIndex=1-faces[0].materialIndex; // swap material index of face between 1 and 0

       object.subgroups.Box.faceSetArray(faces); // save changes

}

 

 

Remarks

 

Changes to the mesh are not written until the faceSetArray function is called.

 

The materialIndex property can only reference materials set up on the subgroup.  To add one, click the subgroup in the objects window, and add a material in the Object Properties -> Materials panel.

 

See Also

 

System



Copyright ©2004 Worldweaver Ltd. DX Studio Home