Axiom.Graphics.TextureUnitState.RecalcTextureMatrix C# (CSharp) Method

RecalcTextureMatrix() private method

Used to update the texture matrix if need be.
private RecalcTextureMatrix ( ) : void
return void
		private void RecalcTextureMatrix()
		{
			Matrix4 xform = Matrix4.Identity;

			// texture scaling
			if ( scaleU != 1 || scaleV != 1 )
			{
				// offset to the center of the texture
				xform.m00 = 1 / scaleU;
				xform.m11 = 1 / scaleV;

				// skip matrix mult since first matrix update
				xform.m03 = ( -0.5f * xform.m00 ) + 0.5f;
				xform.m13 = ( -0.5f * xform.m11 ) + 0.5f;
			}

			// texture translation
			if ( transU != 0 || transV != 0 )
			{
				Matrix4 xlate = Matrix4.Identity;

				xlate.m03 = transU;
				xlate.m13 = transV;

				// multiplt the transform by the translation
				xform = xlate * xform;
			}

			if ( rotate != 0.0f )
			{
				Matrix4 rotation = Matrix4.Identity;

				float theta = Utility.DegreesToRadians( rotate );
				float cosTheta = Utility.Cos( theta );
				float sinTheta = Utility.Sin( theta );

				// set the rotation portion of the matrix
				rotation.m00 = cosTheta;
				rotation.m01 = -sinTheta;
				rotation.m10 = sinTheta;
				rotation.m11 = cosTheta;

				// offset the center of rotation to the center of the texture
				rotation.m03 = 0.5f + ( ( -0.5f * cosTheta ) - ( -0.5f * sinTheta ) );
				rotation.m13 = 0.5f + ( ( -0.5f * sinTheta ) + ( -0.5f * cosTheta ) );

				// multiply the rotation and transformation matrices
				xform = rotation * xform;
			}

			// store the transformation into the local texture matrix
			texMatrix = xform;

			recalcTexMatrix = false;
		}