Esempio n. 1
0
        private void ParseLine(string keyword, string data)
        {
            switch (keyword)
            {
            case "v":
                if (isLastLineAFace)
                {
                    graphObject.Groups.Add(group);
                    group           = new Group();
                    isLastLineAFace = false;
                }
                group.Vertices.Add(VertexParser.Parse(data));
                break;

            case "vt":
                group.VertexTextures.Add(VertexTextureParser.Parse(data));
                break;

            case "vn":
                group.VertexNormals.Add(VertexNormalParser.Parse(data));
                break;

            case "f":
                group.Faces.Add(FaceParser.Parse(data));
                isLastLineAFace = true;
                break;

            default:
                break;
            }
        }
        public void CanParseStyle7()
        {
            WavefrontObject wavefrontObject = new WavefrontObject();

            wavefrontObject.Vertices.Add(new Vector3());
            wavefrontObject.Normals.Add(new Vector3());
            const string line   = "f 1 1 1";
            FaceParser   parser = (FaceParser) new ObjLineParserFactory(wavefrontObject).GetLineParser(line);

            parser.Parse();
        }
        public void Parses_normal_line_correctly_1()
        {
            const string faceLine = "1 2 3";

            _faceParser.Parse(faceLine);

            var parsedFace = _faceGroupSpy.ParsedFace;

            parsedFace[0].VertexIndex.Should().Be(1);
            parsedFace[0].TextureIndex.Should().Be(0);
            parsedFace[0].NormalIndex.Should().Be(0);

            parsedFace[1].VertexIndex.Should().Be(2);
            parsedFace[1].TextureIndex.Should().Be(0);
            parsedFace[1].NormalIndex.Should().Be(0);

            parsedFace[2].VertexIndex.Should().Be(3);
            parsedFace[2].TextureIndex.Should().Be(0);
            parsedFace[2].NormalIndex.Should().Be(0);
        }
Esempio n. 4
0
        public void CanParseStyle6()
        {
            // Arrange.
            WavefrontObject wavefrontObject = new WavefrontObject();

            wavefrontObject.Vertices.Add(new Vertex());
            wavefrontObject.Normals.Add(new Vertex());
            const string line   = "f 1/1 1/1 1/1 1/1";
            FaceParser   parser = (FaceParser) new ObjLineParserFactory(wavefrontObject).GetLineParser(line);

            // Act.
            parser.Parse();
        }