Has anyone figured out how to get a collection of a mesh’s triangles? I think it has something to do with the “getIndexBuffer” function but I’m not sure.
Get a Mesh’s TrianglesSoftware: Away3D 4.x |
||
|
||
Stephen Hopkins, Sr. Member
Posted: 09 July 2011 04:19 AM Total Posts: 110 [ # 1 ] I’ve only done the reverse(putting together a mesh from triangles using updateVertex/IndexData), but i think you can do this: For SubGeometry there is .vertexData Can put the 2 together to construct triangles
public static function getTriangles(subgeometry:SubGeometry):Vector.<Triangle>{
|
||
Alex.R.Hogue, Newbie
Posted: 13 July 2011 09:31 PM Total Posts: 3 [ # 2 ] Hey Stephen, EDIT:
Triangle 1: Vector3D(24.1613, -24.1613, -24.1613) , Vector3D(-24.1613, -24.1613, -24.1613) , Vector3D(-24.1613, -24.1613, -24.1613) Note how some triangles (11 and 12 for example) have the same 3 points. Also I need to find the normals of these triangles as well. Any ideas?
|
||
Stephen Hopkins, Sr. Member
Posted: 14 July 2011 09:58 PM Total Posts: 110 [ # 3 ] Hm I was going to try and test it but apparently, installing flash player 11 beta uninstalled incubator, and I can’t run broomstick anymore with the current bugs because of the new api Ah I think I forgot to multiply the vertex indices by 3. There’s 3 numbers per vertex, so the indices need to be * 3
public static function getTriangles(subgeometry:SubGeometry):Vector.<Triangle>{ To find the normals, do normal = (v0 - v1).cross(v2 - v1), might need to switch the order depending on whether broomstick uses ccw or cw order. |
||
Alex.R.Hogue, Newbie
Posted: 14 July 2011 10:01 PM Total Posts: 3 [ # 4 ] That did it. Thanks so much. |