Exemplo n.º 1
0
        internal static BntxFile CreateBNTX(List <TextureShared> textureList)
        {
            BntxFile bntx = new BntxFile();

            bntx.Target            = new char[] { 'N', 'X', ' ', ' ' };
            bntx.Name              = "textures";
            bntx.Alignment         = 0xC;
            bntx.TargetAddressSize = 0x40;
            bntx.VersionMajor      = 0;
            bntx.VersionMajor2     = 4;
            bntx.VersionMinor      = 0;
            bntx.VersionMinor2     = 0;
            bntx.Textures          = new List <Texture>();
            bntx.TextureDict       = new Syroot.NintenTools.NSW.Bntx.ResDict();
            bntx.RelocationTable   = new RelocationTable();
            bntx.Flag              = 0;

            foreach (var tex in textureList)
            {
                //Create a new switch texture instance
                var textureNX = new Switch.SwitchTexture(bntx, null);
                textureNX.FromWiiU((WiiU.Texture)tex);

                //Now set the new texture
                bntx.Textures.Add(textureNX.Texture);
                bntx.TextureDict.Add(textureNX.Name);
            }
            return(bntx);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a Wii U texture instance to a switch texture.
        /// </summary>
        /// <param name="texture"></param>
        public void FromSwitch(Switch.SwitchTexture textureNX)
        {
            Width       = textureNX.Width;
            Height      = textureNX.Height;
            MipCount    = textureNX.MipCount;
            Depth       = 1;
            ArrayLength = textureNX.ArrayLength;
            TileMode    = GX2TileMode.Mode2dTiledThin1;
            Dim         = GX2SurfaceDim.Dim2D;
            Use         = GX2SurfaceUse.Texture;
            Format      = PlatformConverters.TextureConverter.FormatList.FirstOrDefault(
                x => x.Value == textureNX.Format).Key;
            Name = textureNX.Name;

            //Save arrays and mips into a list for swizzling back
            for (int i = 0; i < textureNX.ArrayLength; i++)
            {
                List <byte[]> mipData = new List <byte[]>();
                for (int j = 0; j < textureNX.MipCount; j++)
                {
                    mipData.Add(textureNX.GetDeswizzledData(i, j));
                }

                //Swizzle the current mip data into a switch swizzled image
                var surface = SwizzleSurfaceMipMaps(ByteUtils.CombineArray(mipData.ToArray()));
                Data       = surface.data;
                MipData    = surface.mipData;
                TileMode   = (GX2TileMode)surface.tileMode;
                MipOffsets = surface.mipOffset;
                MipCount   = surface.numMips;
                Alignment  = surface.alignment;
                Pitch      = surface.pitch;
                Swizzle    = surface.swizzle;
                Regs       = surface.texRegs;
            }

            CompSelR = ConvertChannelSelector(textureNX.Texture.ChannelRed);
            CompSelG = ConvertChannelSelector(textureNX.Texture.ChannelGreen);
            CompSelB = ConvertChannelSelector(textureNX.Texture.ChannelBlue);
            CompSelA = ConvertChannelSelector(textureNX.Texture.ChannelAlpha);

            /*     //Convert user data. BNTX doesn't share the same user data library atm so it needs manual conversion.
             *   UserData = new ResDict<UserData>();
             *   foreach (var userData in textureNX.UserData)
             *   {
             *
             *   }*/
        }