Axiom.SceneManagers.Bsp.TextureLight.CreateTexture C# (CSharp) Method

CreateTexture() public static method

public static CreateTexture ( ) : Axiom.Core.Texture
return Axiom.Core.Texture
		public static Texture CreateTexture()
		{
			Texture tex = (Texture)TextureManager.Instance.GetByName( "Axiom/LightingTexture" );
			if ( tex == null )
			{
				byte[] fotbuf = new byte[ 128 * 128 * 4 ];
				for ( int y = 0; y < 128; y++ )
					for ( int x = 0; x < 128; x++ )
					{
						byte alpha = 0;
						float radius = ( x - 64 ) * ( x - 64 ) + ( y - 64 ) * ( y - 64 );
						radius = 4000 - radius;
						if ( radius > 0 )
						{
							alpha = (byte)( ( radius / 4000 ) * 255 );
						}
						fotbuf[ y * 128 * 4 + x * 4 ] = 255;
						fotbuf[ y * 128 * 4 + x * 4 + 1 ] = 255;
						fotbuf[ y * 128 * 4 + x * 4 + 2 ] = 255;
						fotbuf[ y * 128 * 4 + x * 4 + 3 ] = alpha;
					}

				System.IO.MemoryStream stream = new System.IO.MemoryStream( fotbuf );
				Axiom.Media.Image img = Axiom.Media.Image.FromRawStream( stream, 128, 128, Axiom.Media.PixelFormat.A8R8G8B8 );
				TextureManager.Instance.LoadImage( "Axiom/LightingTexture", ResourceGroupManager.DefaultResourceGroupName, img, TextureType.TwoD, 0, 1, false, Axiom.Media.PixelFormat.A8R8G8B8 );

				tex = (Texture)TextureManager.Instance.GetByName( "Axiom/LightingTexture" );
			}

			return tex;
		}