- Home /
normalising the vertices of a cube mesh
hi all, im trying to normalise the vertices of a cube mesh, with the idea that it will turn it into a sphere. its partially working, but it only makes a hemisphere and i dont know why.
ive checked that the origin is in the centre and it seems to be. i exported the cube with 6 subdivisions on each axis, and made sure the origin is in the centre, but still not working. it only seems to make a hemisphere.
the code im using is below: void Start () { Mesh mesh = GetComponent<MeshFilter>().mesh; Vector3[] vertices = mesh.vertices; Vector3[] normals = mesh.normals; for (int i = 0; i < vertices.Length; i++) { vertices [i].Normalize (); } mesh.vertices = vertices; }
thanks for any help...
paul uk
Sounds like your pivot is at the bottom center of the cube... (or center of a face) rather than in center of cube. Try rotating just the cube, in all axis... to see what is it rotating around. or try with some other random meshes.. to check your code.
Jon uk
Your answer
Follow this Question
Related Questions
Normalizing a cube made up of 24 meshes into a Sphere 0 Answers
Mesh SetVertices() vs vertices 2 Answers
Mirror vertices procedurally 2 Answers
Alternative Ways of Finding Vertices 2 Answers