URGENT How to get triangles of mesh in world space?
I found how to get vertices of mesh in world space but I can not find it for triangles in world space
Here is code for vertices in world space bur how about is triangle in the world space
public MeshFilter meshFilter;
public Vector3[] vertices;
public int[] triangles;
Matrix4x4 localToWorld;
void Start()
{
meshFilter = GetComponent<MeshFilter>();
localToWorld = transform.localToWorldMatrix;
vertices = new Vector3[meshFilter.mesh.vertexCount * 3];
for (int i = 0; i < meshFilter.mesh.vertexCount; i++)
{
vertices[i * 3] = localToWorld.MultiplyPoint3x4(meshFilter.mesh.vertices[i]);
}
// For TRIANGLES??????????????????
}
mesh.triangles
is just an array of indices so there is no such things as "world triangles". triangles[0]
, triangles[1]
and triangles[2]
are the indices of the vertex for$$anonymous$$g the 1st triangle.
So correctly I understood that There is nothing to with world space triangle?
so for Triangles I will use like this
triangles = new int[meshFilter.mesh.triangles.Length];
for (int i = 0; i < meshFilter.mesh.triangles.Length; i++)
{
triangles[i] = meshFilter.mesh.triangles[i];
}
I wanted just to tell that this is not one object. There are a lot of meshes that I want to get word space vertices. So you say that there is not triangle world space then ok I will test If there would be issue then I will tell you
Your answer
Follow this Question
Related Questions
Getting face of mesh when you already have one tri 0 Answers
Can't get submesh to work 1 Answer
How to convert Mesh from local to World Space? 0 Answers
[SOLVED] How to convert Mesh from local to World Space? CODE FIXED! 0 Answers
Procedural Mesh Problems 0 Answers