예제 #1
0
		private void ParseQuads(TextParser parser, ModelBlockPrimBase submesh)
		{
			var tmp = new ComplexIndex[4];
			int startIndex = submesh.Indices.Count;
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "numQuads")
				{
					parser.Consume();
					submesh.Indices.Capacity = startIndex + parser.ConsumeInt() * 2;
					continue;
				}
				if (attribute == "q")
				{
					parser.Consume();
					ParseQuad(parser, tmp);
					submesh.Indices.Add(tmp[0]);
					submesh.Indices.Add(tmp[2]);
					submesh.Indices.Add(tmp[1]);
					submesh.Indices.Add(tmp[0]);
					submesh.Indices.Add(tmp[3]);
					submesh.Indices.Add(tmp[2]);
					continue;
				}
				parser.UnknownLexemError();
			}
		}
예제 #2
0
		private void ParseTris(TextParser parser, ModelBlockPrimBase submesh)
		{
			var tmp = new ComplexIndex[3];
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "numTris")
				{
					parser.Consume();
					submesh.Indices.Capacity = submesh.Indices.Count + parser.ConsumeInt();
					continue;
				}
				if (attribute == "t")
				{
					parser.Consume();
					ParseTriangle(parser, tmp);
					submesh.Indices.Add(tmp[0]);
					submesh.Indices.Add(tmp[2]);
					submesh.Indices.Add(tmp[1]);
					continue;
				}
				parser.UnknownLexemError();
			}
		}
예제 #3
0
		private static ComplexIndex ParseTrisIndexes(TextParser parser)
		{
			parser.Consume("{");
			var i = new ComplexIndex();
			i.Vertex = parser.ConsumeInt();
			parser.Skip(",");
			if (parser.Lexem == "}")
			{
				i.Normal = -1;
			}
			else
			{
				i.Normal = parser.ConsumeInt();
				parser.Skip(",");
			}
			if (parser.Lexem == "}")
			{
				i.UV0 = -1;
			}
			else
			{
				i.UV0 = parser.ConsumeInt();
				parser.Skip(",");
			}
			if (parser.Lexem == "}")
			{
				i.UV1 = -1;
			}
			else
			{
				i.UV1 = parser.ConsumeInt();
				parser.Skip(",");
			}
			if (parser.Lexem == "}")
			{
				i.Color = -1;
			}
			else
			{
				i.Color = parser.ConsumeInt();
			}
			parser.Consume("}");
			return i;
		}