/// <summary>
        /// Loads 2d texture data
        /// </summary>
        private static object Load2dTexture( string streamUrl, BinaryReader reader, TextureFileFormatVersion1.Header header, bool returnTextureData, bool generateMipMaps )
        {
            Texture2dData[] data = Load2dTextureData( reader, header );
            if ( returnTextureData )
            {
                return data;
            }
            ITexture2d texture = Graphics.Factory.CreateTexture2d( );
            if ( generateMipMaps )
            {
                if ( data.Length > 1 )
                {
                    AssetsLog.Warning( "Source \"{0}\" contained mip-maps that are being discarded in favour of generated ones", streamUrl );
                }
                texture.Create( data[ 0 ], true );
                return texture;
            }

            texture.Create( data );
            return texture;
        }
        /// <summary>
        /// Loads 2d texture data from the specified stream
        /// </summary>
        private static Texture2dData[] Load2dTextureData( BinaryReader reader, TextureFileFormatVersion1.Header header )
        {
            Texture2dData[] textureDataArray = new Texture2dData[ header.TextureDataEntries ];
            for ( int textureDataCount = 0; textureDataCount < header.TextureDataEntries; ++textureDataCount )
            {
                TextureFileFormatVersion1.Group textureGroup = TextureFileFormatVersion1.Group.Read( reader );
                if ( textureGroup.GroupId != GroupIdentifier.Texture2dDataGroup )
                {
                    throw new FileLoadException( "Expected texture group" );
                }

                int width = reader.ReadInt32( );
                int height = reader.ReadInt32( );

                Texture2dData texData = new Texture2dData( );
                texData.Create( width, height, header.Format );

                reader.Read( texData.Bytes, 0, texData.Bytes.Length );

                textureDataArray[ textureDataCount ] = texData;
            }

            return textureDataArray;
        }
 /// <summary>
 /// Loads a 3d texture from the specified stream
 /// </summary>
 private static object Load3dTexture( string streamUrl, BinaryReader reader, TextureFileFormatVersion1.Header header, bool returnTextureData, bool generateMipMaps )
 {
     Texture3dData[] data = Load3dTextureData( reader, header );
     if ( returnTextureData )
     {
         return data;
     }
     ITexture3d texture = Graphics.Factory.CreateTexture3d( );
     texture.Create( data[ 0 ] );	//	TODO: AP: Add mipmap generation
     return texture;
 }
 /// <summary>
 /// Writes a group with a dummy length value to the binary writer
 /// </summary>
 private static long BeginGroup( BinaryWriter writer, TextureFileFormatVersion1.Group group )
 {
     long startOfGroup = writer.BaseStream.Length;
     group.Write( writer );
     return startOfGroup;
 }