public void LoadTextures()
        {
            textureImageList.Images.Clear();
            textureListView.Items.Clear();
            textureListView.LargeImageList = textureImageList;
            textureListView.FullRowSelect  = true;

            int CurTex = 0;

            foreach (BinaryTextureContainer bntx in PluginRuntime.bntxContainers)
            {
                foreach (TextureData item in bntx.Textures.Values)
                {
                    ListViewItem it = new ListViewItem();
                    it.Text       = item.Text;
                    it.ImageIndex = CurTex++;

                    textureListView.Items.Add(it);

                    TextureData tex = bntx.Textures[item.Text];
                    tex.LoadOpenGLTexture();


                    TextureData.BRTI_Texture renderedTex = tex.renderedGLTex;

                    Bitmap temp = tex.GLTextureToBitmap(renderedTex, renderedTex.display);

                    textureImageList.Images.Add(tex.Text, temp);

                    var dummy = textureImageList.Handle;
                    temp.Dispose();
                }
            }
        }
예제 #2
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();
            }
        }
예제 #3
0
        private void ImportPlaceholderTexture(byte[] data, string TextureName)
        {
            TextureImporterSettings importDDS = new TextureImporterSettings();

            importDDS.LoadDDS(TextureName, BinaryTexFile, data);

            TextureData texData = importDDS.textureData;

            texData.Text = TextureName;

            Nodes.Add(texData);
            Textures.Add(TextureName, texData);
            texData.LoadOpenGLTexture();
        }
예제 #4
0
        public TextureData AddTexture(string name)
        {
            var importer = new TextureImporterSettings();

            TextureData texData = null;
            string      ext     = Path.GetExtension(name);

            ext = ext.ToLower();

            switch (ext)
            {
            case ".bftex":
                Texture tex = new Texture();
                tex.Import(name);
                texData = new TextureData(tex, BinaryTexFile);
                break;

            case ".dds":
                importer.LoadDDS(name, BinaryTexFile);
                texData = importer.textureData;
                break;

            default:
                importer.LoadBitMap(name, BinaryTexFile);
                texData = importer.textureData;
                break;
            }
            if (texData != null)
            {
                List <string> keyList = new List <string>(Textures.Keys);
                texData.Text = Utils.RenameDuplicateString(keyList, texData.Text);

                Nodes.Add(texData);
                Textures.Add(texData.Text, texData);
                texData.LoadOpenGLTexture();
            }
            return(texData);
        }