コード例 #1
0
        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);
            }
        }
コード例 #2
0
 public VertexEntry(Vector pos, Vector norm, Coords2d coords)
 {
     position = pos;
     normal = norm;
     texCoords = coords;
 }
コード例 #3
0
 public bool Matches(Coords2d other)
 {
     return other.u == u && other.v == v;
 }
コード例 #4
0
 public bool Matches(Coords2d other)
 {
     return(other.u == u && other.v == v);
 }
コード例 #5
0
 public VertexEntry(Vector pos, Vector norm, Coords2d coords)
 {
     position  = pos;
     normal    = norm;
     texCoords = coords;
 }