private static Mesh CreateSkyboxMesh() { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices = new List <ReflectionProbeEx.CubemapSkyboxVertex>(); for (int i = 0; i < 24; i++) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex = new ReflectionProbeEx.CubemapSkyboxVertex(); Vector3 vector3 = Vector3.Normalize(new Vector3(ReflectionProbeEx.octaVerts[i * 3], ReflectionProbeEx.octaVerts[i * 3 + 1], ReflectionProbeEx.octaVerts[i * 3 + 2])); float single = vector3.x; float single1 = single; cubemapSkyboxVertex.tu = single; cubemapSkyboxVertex.x = single1; float single2 = vector3.y; single1 = single2; cubemapSkyboxVertex.tv = single2; cubemapSkyboxVertex.y = single1; float single3 = vector3.z; single1 = single3; cubemapSkyboxVertex.tw = single3; cubemapSkyboxVertex.z = single1; cubemapSkyboxVertex.color = Color.white; cubemapSkyboxVertices.Add(cubemapSkyboxVertex); } for (int j = 0; j < 3; j++) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices1 = new List <ReflectionProbeEx.CubemapSkyboxVertex>(cubemapSkyboxVertices.Count); cubemapSkyboxVertices1.AddRange(cubemapSkyboxVertices); int count = cubemapSkyboxVertices1.Count; cubemapSkyboxVertices.Clear(); cubemapSkyboxVertices.Capacity = count * 4; for (int k = 0; k < count; k += 3) { ReflectionProbeEx.Subdivide(cubemapSkyboxVertices, cubemapSkyboxVertices1[k], cubemapSkyboxVertices1[k + 1], cubemapSkyboxVertices1[k + 2]); } } for (int l = 0; l < 2; l++) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertices2 = new List <ReflectionProbeEx.CubemapSkyboxVertex>(cubemapSkyboxVertices.Count); cubemapSkyboxVertices2.AddRange(cubemapSkyboxVertices); int num = cubemapSkyboxVertices2.Count; float single4 = Mathf.Pow(0.5f, (float)l + 1f); cubemapSkyboxVertices.Clear(); cubemapSkyboxVertices.Capacity = num * 4; for (int m = 0; m < num; m += 3) { if (Mathf.Max(Mathf.Max(Mathf.Abs(cubemapSkyboxVertices2[m].y), Mathf.Abs(cubemapSkyboxVertices2[m + 1].y)), Mathf.Abs(cubemapSkyboxVertices2[m + 2].y)) <= single4) { ReflectionProbeEx.SubdivideYOnly(cubemapSkyboxVertices, cubemapSkyboxVertices2[m], cubemapSkyboxVertices2[m + 1], cubemapSkyboxVertices2[m + 2]); } else { cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m]); cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m + 1]); cubemapSkyboxVertices.Add(cubemapSkyboxVertices2[m + 2]); } } } Mesh mesh = new Mesh(); Vector3[] vector3Array = new Vector3[cubemapSkyboxVertices.Count]; Vector2[] vector2Array = new Vector2[cubemapSkyboxVertices.Count]; int[] numArray = new int[cubemapSkyboxVertices.Count]; for (int n = 0; n < cubemapSkyboxVertices.Count; n++) { vector3Array[n] = new Vector3(cubemapSkyboxVertices[n].x, cubemapSkyboxVertices[n].y, cubemapSkyboxVertices[n].z); vector2Array[n] = new Vector3(cubemapSkyboxVertices[n].tu, cubemapSkyboxVertices[n].tv); numArray[n] = n; } mesh.vertices = vector3Array; mesh.uv = vector2Array; mesh.triangles = numArray; return(mesh); }
private static Mesh CreateSkyboxMesh() { List <ReflectionProbeEx.CubemapSkyboxVertex> destArray = new List <ReflectionProbeEx.CubemapSkyboxVertex>(); for (int index = 0; index < 24; ++index) { ReflectionProbeEx.CubemapSkyboxVertex cubemapSkyboxVertex = new ReflectionProbeEx.CubemapSkyboxVertex(); Vector3 vector3 = Vector3.Normalize(new Vector3(ReflectionProbeEx.octaVerts[index * 3], ReflectionProbeEx.octaVerts[index * 3 + 1], ReflectionProbeEx.octaVerts[index * 3 + 2])); cubemapSkyboxVertex.x = cubemapSkyboxVertex.tu = (float)vector3.x; cubemapSkyboxVertex.y = cubemapSkyboxVertex.tv = (float)vector3.y; cubemapSkyboxVertex.z = cubemapSkyboxVertex.tw = (float)vector3.z; cubemapSkyboxVertex.color = Color.get_white(); destArray.Add(cubemapSkyboxVertex); } for (int index1 = 0; index1 < 3; ++index1) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertexList = new List <ReflectionProbeEx.CubemapSkyboxVertex>(destArray.Count); cubemapSkyboxVertexList.AddRange((IEnumerable <ReflectionProbeEx.CubemapSkyboxVertex>)destArray); int count = cubemapSkyboxVertexList.Count; destArray.Clear(); destArray.Capacity = count * 4; for (int index2 = 0; index2 < count; index2 += 3) { ReflectionProbeEx.Subdivide(destArray, cubemapSkyboxVertexList[index2], cubemapSkyboxVertexList[index2 + 1], cubemapSkyboxVertexList[index2 + 2]); } } for (int index1 = 0; index1 < 2; ++index1) { List <ReflectionProbeEx.CubemapSkyboxVertex> cubemapSkyboxVertexList = new List <ReflectionProbeEx.CubemapSkyboxVertex>(destArray.Count); cubemapSkyboxVertexList.AddRange((IEnumerable <ReflectionProbeEx.CubemapSkyboxVertex>)destArray); int count = cubemapSkyboxVertexList.Count; float num = Mathf.Pow(0.5f, (float)index1 + 1f); destArray.Clear(); destArray.Capacity = count * 4; for (int index2 = 0; index2 < count; index2 += 3) { if ((double)Mathf.Max(Mathf.Max(Mathf.Abs(cubemapSkyboxVertexList[index2].y), Mathf.Abs(cubemapSkyboxVertexList[index2 + 1].y)), Mathf.Abs(cubemapSkyboxVertexList[index2 + 2].y)) > (double)num) { destArray.Add(cubemapSkyboxVertexList[index2]); destArray.Add(cubemapSkyboxVertexList[index2 + 1]); destArray.Add(cubemapSkyboxVertexList[index2 + 2]); } else { ReflectionProbeEx.SubdivideYOnly(destArray, cubemapSkyboxVertexList[index2], cubemapSkyboxVertexList[index2 + 1], cubemapSkyboxVertexList[index2 + 2]); } } } Mesh mesh = new Mesh(); Vector3[] vector3Array = new Vector3[destArray.Count]; Vector2[] vector2Array = new Vector2[destArray.Count]; int[] numArray = new int[destArray.Count]; for (int index = 0; index < destArray.Count; ++index) { vector3Array[index] = new Vector3(destArray[index].x, destArray[index].y, destArray[index].z); vector2Array[index] = Vector2.op_Implicit(new Vector3(destArray[index].tu, destArray[index].tv)); numArray[index] = index; } mesh.set_vertices(vector3Array); mesh.set_uv(vector2Array); mesh.set_triangles(numArray); return(mesh); }