How can i get each face of a mesh in 4.0 ?

Software: Away3D 4.x

woonin, Newbie
Posted: 28 October 2011 03:23 AM   Total Posts: 12

in away3.6 , we can get faces use this :

var f:Face;

for(var 
i:uint=0;i<somemesh.faces.length;i++)
{
     f 
somemesh.faces[i];


and then,how can i get the each face in 4.0 ?

 

   

Avatar
Fabrice Closier, Administrator
Posted: 28 October 2011 11:04 AM   Total Posts: 1265   [ # 1 ]

In 4.0 its a bit more complicated than this. There is no concept of a face as a Face data object as in previous version. There is in core.base.data a Face data object class to store a face as a Face, but its not related to the engine structure at all.

A mesh has a geometry, this object can be composed of one or more subgeometries. Each subgeometry holds vertexnormals, vertices, indices, uv’s and tangent vectors.
The indices are the one that will help you access/define a “Face”.
A face is always represented as a triangle. 9 numbers for vertices, 3 indices uint and 6 uv’s numbers. Normals and Tangents are sync with the vertices, so same index can be shared to access them.

Each indice entry represents the pointer in vertices vector. As the vertices are expressed as 3 numbers entry, the pointer is actually the x component of the vertex.
The first face of a subgeometry is then represented as indices[0], indices[1] and indices[2].
vertices[indices[0]*3] gives you the “v0.x”
vertices[(indices[1]*3) + 1] gives you the “v1.y”
uvs[(indices[2]*2) + 1] gives you the “uv2.v”

Take a look at some of the tools classes.

 

   
   
‹‹ Scene light

X

Away3D Forum

Member Login

Username

Password

Remember_me



X