Hello,
I want to create a sphere from six planes (to use normal maps on them).
But I have problems with the math.
I got the math from here
Converted it to a formular I want to use in unity
var mesh : Mesh = GetComponent(MeshFilter).mesh;
var vertices : Vector3[] = mesh.vertices;
var normals : Vector3[] = mesh.normals;
for (var i = 0; i < vertices.Length; i++)
{
vertices *+= Vector3(Mathf.Sqrt(*
_ 1-(Mathf.Pow(vertices*.y,2) / 2)_
_ - (Mathf.Pow(vertices.z,2) / 2)
+ ((Mathf.Pow(vertices.y,2) * Mathf.Pow(vertices.z,2)) / 3)),
Mathf.Sqrt(
1-(Mathf.Pow(vertices.z,2) / 2)
- (Mathf.Pow(vertices.x,2) / 2)
+ ((Mathf.Pow(vertices.z,2) * Mathf.Pow(vertices.x,2)) / 3)),
Mathf.Sqrt(
1-(Mathf.Pow(vertices.x,2) / 2)
- (Mathf.Pow(vertices.y,2) / 2)
+ ((Mathf.Pow(vertices.x,2) * Mathf.Pow(vertices.y,2)) / 3)));
}
mesh.vertices = vertices;
Im fairly sure I did something wrong with the formular , im really not good in mathematics.
Thats how it looks like that:
![alt text][1]
You see its just wrong ![]()
Its like its shrinked, it is not flat, its a little “rounded”, but its not like I want it, also much much too low poly (I tried it with a from 3ds max imported high poly cube, same result)
I used that formular from the website:
![alt text][2]
[1]: http://desmond.imageshack.us/Himg850/scaled.php?server=850&filename=cubej.png&res=medium*_
[2]: http://farm1.staticflickr.com/18/24013697_73e20d567a_o.jpg