Axiom.RenderSystems.OpenGLES.GLESRenderSystem.SetTextureCoordCalculation C# (CSharp) Method

SetTextureCoordCalculation() public method

public SetTextureCoordCalculation ( int stage, TexCoordCalcMethod method, Frustum frustum ) : void
stage int
method TexCoordCalcMethod
frustum Frustum
return void
		public override void SetTextureCoordCalculation( int stage, TexCoordCalcMethod method, Frustum frustum )
		{
			if ( stage > _fixedFunctionTextureUnits )
			{
				// Can't do this
				return;
			}
			float[] m = new float[ 16 ];
			Matrix4 projectionBias = Matrix4.Identity;

			// Default to no extra auto texture matrix
			_useAutoTextureMatrix = false;

			if ( !ActivateGLTextureUnit( stage ) )
				return;

			switch ( method )
			{
				case TexCoordCalcMethod.None:
					break;
				case TexCoordCalcMethod.EnvironmentMap:
					_useAutoTextureMatrix = true;
					_autoTextureMatrix = new float[ 16 ];
					_autoTextureMatrix[ 0 ] = _autoTextureMatrix[ 10 ] = _autoTextureMatrix[ 15 ] = 1.0f;
					_autoTextureMatrix[ 5 ] = -1.0f;
					break;
				case TexCoordCalcMethod.EnvironmentMapPlanar:
					// TODO not implemented
					break;
				case TexCoordCalcMethod.EnvironmentMapReflection:
					// We need an extra texture matrix here
					// This sets the texture matrix to be the inverse of the view matrix
					_useAutoTextureMatrix = true;
					MakeGLMatrix( ref m, _ViewMatrix );
					if ( _autoTextureMatrix == null )
						_autoTextureMatrix = new float[ 16 ];
					// Transpose 3x3 in order to invert matrix (rotation)
					// Note that we need to invert the Z _before_ the rotation
					// No idea why we have to invert the Z at all, but reflection is wrong without it
					_autoTextureMatrix[ 0 ] = m[ 0 ];
					_autoTextureMatrix[ 1 ] = m[ 4 ];
					_autoTextureMatrix[ 2 ] = -m[ 8 ];
					_autoTextureMatrix[ 4 ] = m[ 1 ];
					_autoTextureMatrix[ 5 ] = m[ 5 ];
					_autoTextureMatrix[ 6 ] = -m[ 9 ];
					_autoTextureMatrix[ 8 ] = m[ 2 ];
					_autoTextureMatrix[ 9 ] = m[ 6 ];
					_autoTextureMatrix[ 10 ] = -m[ 10 ];
					_autoTextureMatrix[ 3 ] = _autoTextureMatrix[ 7 ] = _autoTextureMatrix[ 11 ] = 0.0f;
					_autoTextureMatrix[ 12 ] = _autoTextureMatrix[ 13 ] = _autoTextureMatrix[ 14 ] = 0.0f;
					_autoTextureMatrix[ 15 ] = 1.0f;
					break;
				case TexCoordCalcMethod.EnvironmentMapNormal:
					break;
				case TexCoordCalcMethod.ProjectiveTexture:
					_useAutoTextureMatrix = true;
					if ( _autoTextureMatrix == null )
						_autoTextureMatrix = new float[ 16 ];

					// Set scale and translation matrix for projective textures
					projectionBias = Matrix4.ClipSpace2DToImageSpace;

					projectionBias = projectionBias * frustum.ProjectionMatrix;
					projectionBias = projectionBias * frustum.ViewMatrix;
					projectionBias = projectionBias * _worldMatrix;

					MakeGLMatrix( ref _autoTextureMatrix, projectionBias );
					break;
				default:
					break;
			}


			ActivateGLTextureUnit( 0 );
		}
		/// <summary>
GLESRenderSystem