Esempio n. 1
0
		private IMeshStream CreateMeshStream(ISource source, string semantic)
		{
			var floatArray = source as FloatArraySource;
			if (floatArray != null)
			{
				bool swapY = (semantic == Streams.TexCoord);
				if (source.GetStride() == 3)
				{
					var arrayMeshStream = new ArrayMeshStream<Float3>(source.GetCount(), streamConverterFactory);
					for (int i = 0; i < arrayMeshStream.Count; ++i)
					{
						var y = floatArray[i * 3 + 1];
						if (swapY) y = 1.0f - y;
						arrayMeshStream[i] = new Float3(floatArray[i * 3 + 0], y, floatArray[i * 3 + 2]);
					}
					return arrayMeshStream;
				}
				else if (source.GetStride() == 2)
				{
					var arrayMeshStream = new ArrayMeshStream<Float2>(source.GetCount(), streamConverterFactory);
					for (int i = 0; i < arrayMeshStream.Count; ++i)
					{
						var y = floatArray[i * 2 + 1];
						if (swapY) y = 1.0f - y;
						arrayMeshStream[i] = new Float2(floatArray[i * 2 + 0], y);
					}
					return arrayMeshStream;
				}
				else if (source.GetStride() == 4)
				{
					var arrayMeshStream = new ArrayMeshStream<Float4>(source.GetCount(), streamConverterFactory);
					for (int i = 0; i < arrayMeshStream.Count; ++i)
					{
						var y = floatArray[i * 4 + 1];
						if (swapY) y = 1.0f - y;
						arrayMeshStream[i] = new Float4(floatArray[i * 4 + 0], y, floatArray[i * 4 + 2], floatArray[i * 4 + 3]);
					}
					return arrayMeshStream;
				}
			}
			else
			{
				throw new NotImplementedException();
			}
			throw new NotImplementedException();
		}