Axiom.Serialization.MeshSerializerImplv11.ReadGeometryTexCoords C# (CSharp) Метод

ReadGeometryTexCoords() защищенный Метод

protected ReadGeometryTexCoords ( short bindIdx, BinaryReader reader, VertexData data, int coordSet ) : void
bindIdx short
reader System.IO.BinaryReader
data Axiom.Graphics.VertexData
coordSet int
Результат void
		protected override void ReadGeometryTexCoords( short bindIdx, BinaryReader reader, VertexData data, int coordSet )
		{
			// get the number of texture dimensions (1D, 2D, 3D, etc)
			ushort dim = ReadUShort( reader );

			// add a vertex element for the current tex coord set
			data.vertexDeclaration.AddElement(
				bindIdx, 0,
				VertexElement.MultiplyTypeCount( VertexElementType.Float1, dim ),
				VertexElementSemantic.TexCoords,
				coordSet );

			// create the vertex buffer for the tex coords
			HardwareVertexBuffer vBuffer = HardwareBufferManager.Instance.CreateVertexBuffer( data.vertexDeclaration.Clone( bindIdx ), data.vertexCount, mesh.VertexBufferUsage, mesh.UseVertexShadowBuffer );

			// lock the vertex buffer
			IntPtr texCoords = vBuffer.Lock( BufferLocking.Discard );

			// blast the tex coord data into the buffer
			ReadFloats( reader, data.vertexCount * dim, texCoords );

			// Adjust individual v values to (1 - v)
			if ( dim == 2 )
			{
				int count = 0;

				unsafe
				{
					float* pTex = (float*)texCoords.ToPointer();

					for ( int i = 0; i < data.vertexCount; i++ )
					{
						count++; // skip u
						pTex[ count ] = 1.0f - pTex[ count ]; // v = 1 - v
						count++;
					}
				}
			}

			// unlock the buffer to commit
			vBuffer.Unlock();

			// bind the tex coord buffer
			data.vertexBufferBinding.SetBinding( bindIdx, vBuffer );
		}