Пример #1
0
		private static void ParseUVs(TextParser parser, Mesh mesh)
		{
			ListMeshStream<Vector2> uvs = null;

			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "setID")
				{
					parser.Consume();
					var setId = parser.ConsumeInt();
					if (setId == 0)
					{
						uvs = mesh.UV0;
					}
					else if (setId == 1)
					{
						uvs = mesh.UV1;
					}
					else
					{
						parser.Error("Only 2 UV streams supported");
					}
					continue;
				}
				if (attribute == "numUVs")
				{
					parser.Consume();
					if (uvs == null)
					{
						uvs = mesh.UV0;
					}
					uvs.Capacity = parser.ConsumeInt();
					continue;
				}
				if (attribute == "uv")
				{
					parser.Consume();
					if (uvs == null)
					{
						uvs = mesh.UV0;
					}
					uvs.Add(parser.ConsumeVector2());
					continue;
				}
				parser.UnknownLexemError();
			}
		}