Exemple #1
0
        private void replaceSurfaceLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.dds|" +
                         "Microsoft DDS |*.dds|" +
                         "All files(*.*)|*.*";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DDS dds = new DDS(ofd.FileName);
                textureData.Texture.MipCount = (uint)dds.header.mipmapCount;

                if (textureData.Texture.Height != (uint)dds.header.height)
                {
                    throw new Exception("Invalid height! Must be same as original!");
                }

                if (textureData.Texture.Width != (uint)dds.header.width)
                {
                    throw new Exception("Invalid Width! Must be same as original!");
                }

                List <byte[]> Mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(textureData.Texture, dds.bdata, TileMode.Default);
                textureData.Surfaces[CurArrayDisplayLevel].mipmaps = Mipmaps;

                UpdateMipDisplay();
                textureData.LoadOpenGLTexture();
            }
        }
Exemple #2
0
        public override void SetImageData(Bitmap bitmap, int ArrayLevel)
        {
            if (!Runtime.NUTEXBSettings.IsSwizzled)
            {
                MipCount  = GenerateMipCount(bitmap.Width, bitmap.Height);
                ImageData = GenerateMipsAndCompress(bitmap, MipCount, Format);
                return;
            }

            if (!Runtime.NUTEXBSettings.LimitFileSize)
            {
                MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);
            }

            Texture tex = new Texture();

            tex.Height      = (uint)bitmap.Height;
            tex.Width       = (uint)bitmap.Width;
            tex.Format      = TextureData.GenericToBntxSurfaceFormat(Format);
            tex.Name        = Text;
            tex.Path        = "";
            tex.TextureData = new List <List <byte[]> >();

            STChannelType[] channels = SetChannelsByFormat(Format);
            tex.sparseBinding   = 0; //false
            tex.sparseResidency = 0; //false
            tex.Flags           = 0;
            tex.Swizzle         = 0;
            tex.textureLayout   = 0;
            tex.Regs            = new uint[0];
            tex.AccessFlags     = AccessFlags.Texture;
            tex.ArrayLength     = (uint)ArrayLevel;
            tex.MipCount        = MipCount;
            tex.Depth           = Depth;
            tex.Dim             = Dim.Dim2D;
            tex.TileMode        = TileMode.Default;
            tex.textureLayout2  = 0x010007;
            tex.SurfaceDim      = SurfaceDim.Dim2D;
            tex.SampleCount     = 1;
            tex.Pitch           = 32;

            tex.MipOffsets = new long[tex.MipCount];

            var mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(tex,
                                                                        GenerateMipsAndCompress(bitmap, MipCount, Format), MipCount);

            byte[] output = Utils.CombineByteArray(mipmaps.ToArray());
            if (Runtime.NUTEXBSettings.LimitFileSize && output.Length > ImageData.Length)
            {
                throw new Exception("Image must be the same size or smaller!");
            }

            ImageData = SetImageData(output);
        }
Exemple #3
0
        public override void SetImageData(Bitmap bitmap, int ArrayLevel)
        {
            if (!IsSwizzled)
            {
                //   MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);

                //  ImageData = GenerateMipsAndCompress(bitmap, Format);
                return;
            }

            Texture tex = new Texture();

            tex.Height      = (uint)bitmap.Height;
            tex.Width       = (uint)bitmap.Width;
            tex.Format      = TextureData.GenericToBntxSurfaceFormat(Format);
            tex.Name        = Text;
            tex.Path        = "";
            tex.TextureData = new List <List <byte[]> >();

            STChannelType[] channels = SetChannelsByFormat(Format);
            tex.sparseBinding   = 0; //false
            tex.sparseResidency = 0; //false
            tex.Flags           = 0;
            tex.Swizzle         = 0;
            tex.textureLayout   = 0;
            tex.Regs            = new uint[0];
            tex.AccessFlags     = 0x20;
            tex.ArrayLength     = (uint)ArrayLevel;
            tex.MipCount        = MipCount;
            tex.Depth           = Depth;
            tex.Dim             = Dim.Dim2D;
            tex.TileMode        = TileMode.Default;
            tex.textureLayout2  = 0x010007;
            tex.SurfaceDim      = SurfaceDim.Dim2D;
            tex.SampleCount     = 1;
            tex.Pitch           = 32;
            tex.MipOffsets      = new long[tex.MipCount];

            MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);

            var mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(tex,
                                                                        GenerateMipsAndCompress(bitmap, Format), MipCount);

            ImageData = Utils.CombineByteArray(mipmaps.ToArray());
        }
Exemple #4
0
            public override void SetImageData(Bitmap bitmap, int ArrayLevel)
            {
                if (bitmap == null)
                {
                    return; //Image is likely disposed and not needed to be applied
                }
                MipCount = GenerateMipCount(bitmap.Width, bitmap.Height);

                XTXFormat = ConvertFromGenericFormat(Format);

                var tex = new Syroot.NintenTools.NSW.Bntx.Texture();

                tex.Height      = (uint)bitmap.Height;
                tex.Width       = (uint)bitmap.Width;
                tex.Format      = TextureData.GenericToBntxSurfaceFormat(Format);
                tex.Name        = Text;
                tex.Path        = "";
                tex.TextureData = new List <List <byte[]> >();

                STChannelType[] channels = SetChannelsByFormat(Format);
                tex.sparseBinding   = 0; //false
                tex.sparseResidency = 0; //false
                tex.Flags           = 0;
                tex.Swizzle         = 0;
                tex.textureLayout   = 0;
                tex.Regs            = new uint[0];
                tex.AccessFlags     = AccessFlags.Texture;
                tex.ArrayLength     = (uint)ArrayLevel;
                tex.MipCount        = MipCount;
                tex.Depth           = Depth;
                tex.Dim             = Syroot.NintenTools.NSW.Bntx.GFX.Dim.Dim2D;
                tex.TileMode        = Syroot.NintenTools.NSW.Bntx.GFX.TileMode.Default;
                tex.textureLayout2  = 0x010007;
                tex.SurfaceDim      = Syroot.NintenTools.NSW.Bntx.GFX.SurfaceDim.Dim2D;
                tex.SampleCount     = 1;
                tex.Pitch           = 32;

                tex.MipOffsets = new long[tex.MipCount];

                var mipmaps = TextureImporterSettings.SwizzleSurfaceMipMaps(tex,
                                                                            GenerateMipsAndCompress(bitmap, MipCount, Format), MipCount);

                ImageData = Utils.CombineByteArray(mipmaps.ToArray());
            }