public TriangleMesh(GeometryInfo geoInfo) { MeshProfile = new SurfaceProfile(); MaterialName = geoInfo.MaterialName; MeshName = geoInfo.Name; Vertices = geoInfo.VertexData.ToPointList().ToArray(); Normals = geoInfo.NormalData.ToNormalList().ToArray(); TexCoords = geoInfo.TextureData.TodVectorList().ToArray(); var triangles = new List<TriangleDataInfo>(); int index = 0; if (geoInfo.IndexData.Any()) { int[] ni = null; int[] ti = null; var hasNormals = geoInfo.NormalIndexData != null && geoInfo.NormalIndexData.Any(); var hasTexCoords = geoInfo.TextureIndexData != null && geoInfo.TextureIndexData.Any(); if (hasTexCoords) { ti = geoInfo.TextureIndexData.ToArray(); } if (hasNormals) { ni = geoInfo.NormalIndexData.ToArray(); } HasNormals = hasNormals; HasTexCoords = hasTexCoords; for (int i = 0; i < geoInfo.IndexData.Count; i += 3) { index++; var newTriangle = new TriangleDataInfo() { v0 = new MeshVertexInfo() { NormalIndex = hasNormals ? ni[i] - 1 : -1, VertexIndex = geoInfo.IndexData[i] - delta, TexCoordIndex = hasTexCoords ? ti[i] - 1 : -1 }, v1 = new MeshVertexInfo() { NormalIndex = hasNormals ? ni[i + 1] - 1 : -1, VertexIndex = geoInfo.IndexData[i + 1] - delta, TexCoordIndex = hasTexCoords ? ti[i + 1] - 1 : -1 }, v2 = new MeshVertexInfo() { NormalIndex = hasNormals ? ni[i + 2] - 1 : -1, VertexIndex = geoInfo.IndexData[i + 2] - delta, TexCoordIndex = hasTexCoords ? ti[i + 2] - 1 : -1 }, }; triangles.Add(newTriangle); } WorldBound = new AABB(this.Vertices); this.Triangles = triangles.ToArray(); this.BottomLevelBVH = new AccellerationData() {data = BvhDataAdapter.CreateBVH(Triangles, Vertices)}; } }
public TriangleMeshInfo(SceneDataInfo scene) { this.scene = scene; MeshProfile = new SurfaceProfile(); }
public TriangleMesh() { normals = new Dictionary<int, Normal[]>(300); texCoords = new Dictionary<int, UV[]>(); MeshProfile = new SurfaceProfile(); }