Esempio n. 1
0
		void ReconstructRawVertex(global_geometry_section_info_struct section_info,
			int stream_source, BlamLib.Render.VertexBufferInterface.StreamReader stream_reader)
		{
			LowLevel.Math.real_quaternion quat = new LowLevel.Math.real_quaternion();

			if (stream_source == 0)
			{
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypePosition,
					ref quat))
				{
					Point.Position.X = quat.Vector.I;
					Point.Position.Y = quat.Vector.J;
					Point.Position.Z = quat.Vector.K;
				}
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeNodeIndices,
					ref quat))
				{
					Point.NodeIndex[0].Value = ((int)quat.Vector.I) - 1;
					Point.NodeIndex[1].Value = ((int)quat.Vector.J) - 1;
					Point.NodeIndex[2].Value = ((int)quat.Vector.K) - 1;
					Point.NodeIndex[3].Value = ((int)quat.W) - 1;
				}
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeNodeWeights,
					ref quat))
				{
					Point.NodeWeight[0].Value = quat.Vector.I;
					Point.NodeWeight[1].Value = quat.Vector.J;
					Point.NodeWeight[2].Value = quat.Vector.K;
					Point.NodeWeight[3].Value = quat.W;
				}
			}
			else if (stream_source == 1)
			{
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeTexCoord,
					ref quat))
				{
					Texcoord.X = quat.Vector.I;
					Texcoord.Y = quat.Vector.J;
				}
			}
			else if (stream_source == 2)
			{
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeNormal,
					ref quat))
				{
					Normal.I = quat.Vector.I;
					Normal.J = quat.Vector.J;
					Normal.K = quat.Vector.K;
				}
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeBinormal,
					ref quat))
				{
					Binormal.I = quat.Vector.I;
					Binormal.J = quat.Vector.J;
					Binormal.K = quat.Vector.K;
				}
				if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.kTypeTangent,
					ref quat))
				{
					Tangent.I = quat.Vector.I;
					Tangent.J = quat.Vector.J;
					Tangent.K = quat.Vector.K;
				}
			}

			if (section_info != null && stream_source > 2)
			{
				int x = 2;

				// The following LM vertex sources only have one element, so we can call this here
				stream_reader.GetStreamedElement(0, ref quat);

				if (section_info.SectionLightingFlags.Test(k_lighting_flags_HasLmTexCoords) 
					&& stream_source == ++x)
				{
					PrimaryLightmapTexcoord.X = quat.Vector.I;
					PrimaryLightmapTexcoord.Y = quat.Vector.J;
				}
				else if (section_info.SectionLightingFlags.Test(k_lighting_flags_HasLmIncRad)
					&& stream_source == ++x)
				{
					PrimaryLightmapIncidentDirection.I = quat.Vector.I;
					PrimaryLightmapIncidentDirection.J = quat.Vector.J;
					PrimaryLightmapIncidentDirection.K = quat.Vector.K;
				}
				else if (section_info.SectionLightingFlags.Test(k_lighting_flags_HasLmColor)
					&& stream_source == ++x)
				{
					// alpha is quad.W, which LM color doesn't use
					PrimaryLightmapColor.R = quat.Vector.I;
					PrimaryLightmapColor.G = quat.Vector.J;
					PrimaryLightmapColor.B = quat.Vector.K;
				}
			}

			#region Unused vertex elements
// 			if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.VertexBuffersHalo2.kTypeAnisoBinormal,
// 				ref quat))
// 			{
// 				AnisotropicBinormal.I = quat.Vector.I;
// 				AnisotropicBinormal.J = quat.Vector.J;
// 				AnisotropicBinormal.K = quat.Vector.K;
// 			}
// 
// 			if (stream_reader.FindStreamedElement(BlamLib.Render.VertexBufferInterface.VertexBuffersHalo2.kTypeSecondaryTexCoord,
// 				ref quat))
// 			{
// 				SecondaryTexcoord.X = quat.Vector.I;
// 				SecondaryTexcoord.Y = quat.Vector.J;
// 			}
			#endregion
		}