public void AddMesh(Mesh m) { MeshNormals meshNormals = m.GetMeshNormals(); MeshTextureCoords meshTextureCoords = m.GetMeshTextureCoords(); MeshMaterialList meshMaterialList = m.GetMeshMaterialList(); Debug.Assert(meshNormals != null); Debug.Assert(meshTextureCoords != null); Debug.Assert(meshMaterialList != null); Debug.Assert(meshNormals.faceNormals.Length == m.faces.Length); for (int faceIndex = 0; faceIndex < m.faces.Length; ++faceIndex) { MeshFace face = m.faces[faceIndex]; MeshFace normalFace = meshNormals.faceNormals[faceIndex]; Material material = meshMaterialList.GetMaterialByFace(faceIndex); Debug.Assert(face.faceVertexIndices.Length == normalFace.faceVertexIndices.Length); List <int> polygonPoints = new List <int>(); for (int pointIndex = 0; pointIndex < face.faceVertexIndices.Length; ++pointIndex) { int vertexIndex = face.faceVertexIndices[pointIndex]; int normalIndex = normalFace.faceVertexIndices[pointIndex]; Vector position = m.vertices[vertexIndex]; Vector normal = meshNormals.normals[normalIndex]; Coords2d texCoords = meshTextureCoords.textureCoords[vertexIndex]; VertexEntry vertexEntry = new VertexEntry(position, normal, texCoords); int newVertexIndex = AddVertex(material, vertexEntry); polygonPoints.Add(newVertexIndex); // Either add the point to poly, or add a new poly for the point. } if (!indexSets.ContainsKey(material)) { indexSets[material] = new List <List <int> >(); } indexSets[material].Add(polygonPoints); } }
public VertexEntry(Vector pos, Vector norm, Coords2d coords) { position = pos; normal = norm; texCoords = coords; }
public bool Matches(Coords2d other) { return other.u == u && other.v == v; }
public bool Matches(Coords2d other) { return(other.u == u && other.v == v); }