Question by
SenseOfLife42 · Feb 08, 2016 at 04:24 PM ·
transformmeshvector3
(Solved) Please, help me to understand this strange fact.
I have a simple question, but after searching the internet I have found no answer. I have a mesh. I copy all his vertices in another array and than I prin on the Log the vaules of each Vector3. All vertices have velue: (0.0, 0.0, 0.0). Then if I transform all points in world space I found that every vertex has a position as I expect. Code is:
actualMesh = GetComponent<MeshFilter> ().mesh;
meshVertices = actualMesh.vertices;
int i = 0;
foreach (Vector3 v in meshVertices) {
meshVertices [i++] *= 3;
Debug.Log(meshVertices[i-1]);
Debug.Log(transform.TransformPoint (meshVertices[i-1]));
}
The question is: why the first call to Log always write zero and in the second case no? Even if the vertices are in local space I expect they should have a value different from zero.
Comment
Is the mesh very small but scaled up? Try debugging each variable in the Vector3 as Debug truncates Vector3 :
Debug.Log( meshVertices[i-1].x + " " + meshVertices[i-1].y + " " + meshVertices[i-1].z );
@alucardj that was the answer. Thanks, it wasn't so difficult in the end. Stupid me.