示例#1
0
        public bool AddFace(int[] vertexPoints)
        {
            if (vertexPoints.Length < 3)
            {
                return(false);
            }
            DSMeshFace face = DSMeshFace.CreateFace(vertexPoints.Length);

            for (int i = 0; i < vertexPoints.Length; ++i)
            {
                face.AddFacePoint(vertexPoints[i], i);
            }
            Faces.Add(face);
            return(true);
        }
示例#2
0
        public bool AddFace(int[][] facePoints)
        {
            if (facePoints.Length < 3)
            {
                return(false);
            }
            DSMeshFace face = DSMeshFace.CreateFace(facePoints.Length);

            for (int i = 0; i < facePoints.Length; ++i)
            {
                if (facePoints[i].Length != 3)
                {
                    return(false);
                }
                face.AddFacePoint(facePoints[i][0], facePoints[i][1], facePoints[i][2], i);
            }
            Faces.Add(face);
            return(true);
        }
示例#3
0
        public bool AddFace(String rawData)
        {
            if (currentGroup == null)
            {
                AddGroup("Default");
            }
            string[] verticesInfo = rawData.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            if (verticesInfo.Length == 0)
            {
                return(false);
            }
            DSMeshFace face = DSMeshFace.CreateFace(verticesInfo.Length);

            for (int i = 0; i < verticesInfo.Length; ++i)
            {
                string[] parts = verticesInfo[i].Split(new[] { '/' }, StringSplitOptions.None);
                if (parts.Length == 0)
                {
                    return(false);
                }
                int vertex, texture = 0, normal = 0;
                if (!int.TryParse(parts[0], out vertex))
                {
                    return(false);
                }
                if (parts.Length > 1 && !String.IsNullOrWhiteSpace(parts[1]) && !int.TryParse(parts[1], out texture))
                {
                    return(false);
                }
                if (parts.Length > 2 && !String.IsNullOrWhiteSpace(parts[2]) && !int.TryParse(parts[2], out normal))
                {
                    return(false);
                }
                face.AddFacePoint(vertex - 1, texture - 1, normal - 1, i);
            }
            currentGroup.Faces.Add(face);
            return(true);
        }