- Home /
Precise vertex positions
Hello,
I was wondering how to get precise vertex positions in a mesh (with as many decimal places as needed as
function Start (){
var thisMatrix = transform.localToWorldMatrix;
var vertices = GetComponent.<MeshFilter>().mesh.vertices;
for (vertex in vertices) {
print("mesh1 vertex at " + thisMatrix.MultiplyPoint3x4(vertex) );
}
}
seems to return rounded positions (up to 1 decimal place)
Answer by tanoshimi · Jan 22, 2017 at 10:34 PM
Vertex positions are floating point values - they don't have any number of fixed decimal places. The print method in your example, however, does truncate values shown in the console because the ToString() method only shows a few decimal places of each component of a vector3.
You'll probably yield more accurate output in the console window by outputting each float value separately:
print("mesh1 vertex at " + thisMatrix.MultiplyPoint3x4(vertex).x + "," + thisMatrix.MultiplyPoint3x4(vertex).y + "," + thisMatrix.MultiplyPoint3x4(vertex).z );
Your answer
Follow this Question
Related Questions
UnityEngine.UI.Text characters mesh 0 Answers
Why vertex positions appear (0.0, 0.0, 0.0) ? 1 Answer
Editing vertices 1 Answer
how to find direction between two points 2 Answers
drawing vertices 1 Answer