Example #1
0
        protected override void Parse(string keyword, string data)
        {
            switch (keyword.ToLower())
            {
            case "v":
                Vertices.Add(ParseVertex(data));
                break;

            case "vp":
                throw new NotImplementedException();
                break;

            case "vn":
                Normals.Add(ParseNormal(data));
                break;

            case "vt":
                TextureVertices.Add(ParseTextureVertex(data));
                break;

            case "g":

                break;

            case "f":
                Faces.Add(ParseFace(data));
                break;

            case "usemtl":
                Materials.Add(_currentMaterial = LoadedMaterials.First(m => m.Name == data));
                break;

            case "mtllib":
                using (var stream = FileSource.Get(data))
                {
                    MaterialFiles.Add(new MATFile(stream, FileSource));
                }
                break;

            default:
                throw new Exception(keyword);
                break;
                //
            }
        }
Example #2
0
        private void ProcessLine(string line)
        {
            var parts = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length <= 0)
            {
                return;
            }

            switch (parts[0])
            {
            case "v":
                var vertex = new GeometricVertex();
                vertex.ProcessData(parts, _maxValue);
                GeometricVertices.Add(vertex);
                break;

            case "f":
                var face = new FaceVertex();
                face.ProcessData(parts);
                FaceVertices.Add(face);
                break;

            case "vt":
                var textureVertex = new TextureVertex();
                textureVertex.ProcessData(parts);
                TextureVertices.Add(textureVertex);
                break;

            case "vn":
                var normalVertex = new NormalVertex();
                normalVertex.ProcessData(parts);
                NormalVertices.Add(normalVertex);
                break;
            }
        }