/// <summary> /// Fills in a set of spherically mapped texture coordinates to the passed in mesh /// </summary> private static void SetSphericalTextureCoordinates(Mesh mesh) { BoundingSphere boundingSphere = BufferHelper.ComputeBoundingSphere(mesh); var vertexes = BufferHelper.ReadVertexBuffer <PositionNormalTextured>(mesh); for (int i = 0; i < vertexes.Length; i++) { Vector3 vertexRay = Vector3.Normalize(vertexes[i].Position - boundingSphere.Center); double phi = Math.Acos(vertexRay.Z); vertexes[i].Tu = CalculateTu(vertexRay, phi); vertexes[i].Tv = (float)(phi / Math.PI); } BufferHelper.WriteVertexBuffer(mesh, vertexes); }