예제 #1
0
        /// <summary>
        ///     Opens the windows used for a model.
        ///     More windows can be opened later, for files with model and other data.
        /// </summary>
        /// <param name="model">The model</param>
        /// <param name="name">The file name (without the full path and extension)</param>
        private void launchModel(RenderBase.OModelGroup model, string name)
        {
            OViewportWindow viewportWindow = new OViewportWindow();
            OModelWindow modelWindow = new OModelWindow();
            OTextureWindow textureWindow = new OTextureWindow();
            OAnimationsWindow animationWindow = new OAnimationsWindow();

            viewportWindow.Title = name;

            RenderEngine renderer = new RenderEngine();
            renderer.MSAALevel = Settings.Default.reAALevel;
            renderer.bgColor = Settings.Default.reBgColor;
            renderer.useLegacyTexturing = Settings.Default.reUseLegacyTexturing;
            renderer.showGrid = Settings.Default.reShowGrids;
            renderer.showHUD = Settings.Default.reShowHUD;
            renderer.model = model;

            launchWindow(viewportWindow);
            DockContainer.dockMainWindow();
            launchWindow(modelWindow, false);
            launchWindow(textureWindow, false);
            launchWindow(animationWindow, false);

            WindowManager.Refresh();

            modelWindow.initialize(renderer);
            textureWindow.initialize(renderer);
            animationWindow.initialize(renderer);
            viewportWindow.initialize(renderer);
        }
예제 #2
0
        public void open(Stream data, string name)
        {
            WindowManager.flush();

            FileIO.fileFormat format = FileIO.identify(data);
            if (FileIO.isCompressed(format)) FileIO.decompress(ref data, ref format);

            byte[] buffer;
            OContainerForm containerForm;
            switch (format)
            {
                case FileIO.fileFormat.dq7DMP:
                    OSingleTextureWindow singleTextureWindow = new OSingleTextureWindow();

                    singleTextureWindow.Title = name;

                    launchWindow(singleTextureWindow);
                    DockContainer.dockMainWindow();
                    WindowManager.Refresh();

                    singleTextureWindow.initialize(DMP.load(data).texture);
                    break;
                case FileIO.fileFormat.dq7FPT0:
                    containerForm = new OContainerForm();
                    containerForm.launch(FPT0.load(data));
                    containerForm.Show(this);
                    break;
                case FileIO.fileFormat.dq7Model:
                    containerForm = new OContainerForm();
                    containerForm.launch(DQVIIPack.load(data));
                    containerForm.Show(this);
                    break;
                case FileIO.fileFormat.flZMdl: launchModel(ZMDL.load(data), name); break;
                case FileIO.fileFormat.flZTex:
                    OTextureWindow textureWindow = new OTextureWindow();

                    textureWindow.Title = name;

                    launchWindow(textureWindow);
                    DockContainer.dockMainWindow();
                    WindowManager.Refresh();

                    textureWindow.initialize(ZTEX.load(data));
                    break;
                case FileIO.fileFormat.fmNLK2:
                    buffer = new byte[data.Length - 0x80];
                    data.Seek(0x80, SeekOrigin.Begin);
                    data.Read(buffer, 0, buffer.Length);
                    data.Close();
                    launchModel(CGFX.load(new MemoryStream(buffer)), name);
                    break;
                case FileIO.fileFormat.nlpSMes: launchModel(NLP.loadMesh(data), name); break;
                case FileIO.fileFormat.nw4cCGfx: launchModel(CGFX.load(data), name); break;
                case FileIO.fileFormat.nw4cH3D:
                    buffer = new byte[data.Length];
                    data.Read(buffer, 0, buffer.Length);
                    data.Close();
                    launchModel(BCH.load(new MemoryStream(buffer)), name);
                    break;
                case FileIO.fileFormat.pkmnContainer:
                    GenericContainer.OContainer container = PkmnContainer.load(data);
                    switch (container.fileIdentifier)
                    {
                        case "PC": //Pokémon model
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "MM": //Pokémon Overworld model
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "GR": //Pokémon Map model
                            launchModel(BCH.load(new MemoryStream(container.content[1].data)), name);
                            break;
                        case "PT": //Pokémon texture
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "PK": //Pokemon Visibility/Skeletal animations
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "PB": //Pokémon material animations
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                        case "AD": //???
                            launchModel(BCH.load(new MemoryStream(container.content[0].data)), name);
                            break;
                    }
                    //TODO: Add windows for extra data
                    break;
                default:
                    MessageBox.Show("Unsupported file format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    data.Close();
                    break;
            }
        }