Beispiel #1
0
        private void ImportTexture(List <GTXImporterSettings> settings)
        {
            Cursor.Current = Cursors.WaitCursor;
            foreach (var setting in settings)
            {
                if (setting.GenerateMipmaps)
                {
                    setting.DataBlockOutput.Clear();
                    setting.DataBlockOutput.Add(setting.GenerateMips());
                }

                if (setting.DataBlockOutput != null)
                {
                    FTEX ftex = new FTEX();
                    ftex.texture = new ResU.Texture();
                    var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting);
                    var tex     = FTEX.FromGx2Surface(surface, setting.TexName);
                    ftex.UpdateTex(tex);
                    ftex.IsEdited = true;

                    ftex.Read(ftex.texture);
                    ftex.LoadOpenGLTexture();
                    AddNode(ftex);
                }
                else
                {
                    MessageBox.Show("Something went wrong???");
                }
            }
        }
Beispiel #2
0
        public void ImportTexture(string[] FileNames)
        {
            GTXTextureImporter         importer = new GTXTextureImporter();
            List <GTXImporterSettings> settings = new List <GTXImporterSettings>();

            foreach (string name in FileNames)
            {
                string TextureName = Path.GetFileNameWithoutExtension(name);


                string ext = Path.GetExtension(name);
                ext = ext.ToLower();

                if (ext == ".bftex")
                {
                    FTEX ftex = new FTEX();
                    ftex.texture = new ResU.Texture();
                    ftex.texture.Import(name, GetResFileU());
                    ftex.IsEdited = true;
                    ftex.Read(ftex.texture);
                    AddNode(ftex);
                }
                else if (ext == ".dds" || ext == ".dds2")
                {
                    FTEX ftex = new FTEX();
                    ftex.texture = new ResU.Texture();

                    GTXImporterSettings setting = FTEX.SetImporterSettings(name);

                    if (setting.DataBlockOutput != null)
                    {
                        var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting);
                        var tex     = FTEX.FromGx2Surface(surface, setting.TexName);
                        ftex.UpdateTex(tex);

                        ftex.IsEdited = true;
                        ftex.Read(ftex.texture);
                        ftex.LoadOpenGLTexture();
                        AddNode(ftex);
                    }
                }
                else
                {
                    settings.Add(FTEX.SetImporterSettings(name));
                }
            }
            if (settings.Count == 0)
            {
                importer.Dispose();
            }
            else
            {
                importer.LoadSettings(settings);
                if (importer.ShowDialog() == DialogResult.OK)
                {
                    ImportTexture(settings);

                    settings.Clear();

                    GC.Collect();
                    Cursor.Current = Cursors.Default;
                }
            }
        }