Subgroup.<...>

Return to Introduction  Previous page  Next page

Allows manipulation of a single face in a mesh.

 

Properties

 

id

Gets or sets the name of the subgroup (string).

visible

Gets or sets whether the subgroup is visible (boolean).

materials

A collection of all the Materials

pos

Local Vector position of the subgroup for this object.

rot

Local Rotation of the subgroup for this object.

scale

Local Vector scale of the subgroup for this object.

posMesh

A read-only Vector that determines the actual position of the subgroup within the whole Mesh.

posWorld

A read-only Vector that determines the current true world position of the subgroup.

texturePos

Vector where the x and y components offset the texture map by the given amount.

textureScale

Vector where the x and y components scale the texture map by the given amount.

offsetPos

Vector position used to offset the subgroup's mesh before animation or attachment are applied.

offsetRot

Rotation amount used to offset the subgroup's mesh before animation or attachment are applied.

offsetScale

Vector scale used to offset the subgroup's mesh before animation or attachment are applied.

texturePos

Vector where the x and y components offset the texture map by the given amount.

textureScale

Vector where the x and y components scale the texture map by the given amount.

pivotPos

Vector pivot position of the subgroup in local coordinates before any other transforms are applied.

pivotRot

Rotation applied about the pivot in local coordinates before any other transforms are applied.

morphAmount

Gets or sets the amount (a float between 0 and 1) that this subgroup applies it's difference to the base.  See Vertex Morphing in the Wiki for how to set this up.

 

Methods

 

vertexGetArray()

Returns an array of Vertex objects that can be manipulated.

faceGetArray()

Returns an array of Face objects that can be manipulated.

vertexSetArray(vertexarray)

Writes the given array of Vertex objects back into the mesh.

faceSetArray(facearray)

Wrties the given array of Face objects back into the mesh.

attachedObjectGetArray()

Returns an Array of Object types listing all objects currently attached to this particular subgroup.

setMaterialMap(materialIndex,materialName)

Call this function to set the mapping of material indices used by faces to materials set for the object.  e.g. setMaterialMap(0,"metal") would mean all faces with 0 as a material index will use the object's material called "metal".

getMaterialMap(materialIndex)

Returns a string if the given material index is mapped to a material name, or null if it's not mapped.

updateFaceVertexCache()

If you've modified the faces/vertices in a subgroup and intend to use the mesh for 'picking' with the mouse, you should call this function to update the cache.

rebuildNormals()

If you've modified the vertex positions in a subgroup, this function will rebuild the surface normals so the lighting is correct.

 

Examples

 

// in this example, the following script is attached to a newly created box object...

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

}

 

 

See Also

 

System



Copyright ©2004 Worldweaver Ltd. DX Studio Home