Exemplo n.º 1
0
        private void importObjMtlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!CheckSaveUnsavedChanges())
            {
                return;
            }

            if (ofdLoadObj.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            List <string> modelWarningLog;
            ObjMtlModel   model;

            try {
                model = new ObjMtlModel(ofdLoadObj.FileName, out modelWarningLog);
                if (modelWarningLog.Count != 0)
                {
                    ObjMtlWarningLogDialog warningDlg = new ObjMtlWarningLogDialog(modelWarningLog);
                    if (warningDlg.ShowDialog() != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error loading the OBJ file. " + ex.Message, "Error loading the OBJ file.",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Dictionary <Bitmap, int> textureIndexMapping;

            Tpl = new Tpl(model, out textureIndexMapping);
            Gma = new Gma(model, textureIndexMapping);
            paneStageViewer.SetDrawTextures(true);

            // Set TPL / GMA as changed
            HaveUnsavedGmaChanges = true;
            HaveUnsavedTplChanges = true;

            // Update model list
            paneModels.UpdateTree();
            paneModels.UpdateModelButtons();

            // Update material tab
            paneMaterials.UpdateTrees();

            //UpdateTextureButtons();

            // Update stage viewer
            paneStageViewer.InvalidateGL();
        }
Exemplo n.º 2
0
        private void tsBtnImportObjMtl_Click(object sender, EventArgs e)
        {
            if (!CheckSaveUnsavedChanges())
            {
                return;
            }

            if (ofdLoadObj.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            List <string> modelWarningLog;
            ObjMtlModel   model;

            try
            {
                model = new ObjMtlModel(ofdLoadObj.FileName, out modelWarningLog);
                if (modelWarningLog.Count != 0)
                {
                    ObjMtlWarningLogDialog warningDlg = new ObjMtlWarningLogDialog(modelWarningLog);
                    if (warningDlg.ShowDialog() != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading the OBJ file. " + ex.Message, "Error loading the OBJ file.",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Dictionary <Bitmap, int> textureIndexMapping;

            tpl = new Tpl(model, out textureIndexMapping);
            gma = new Gma(model, textureIndexMapping);

            // Set TPL / GMA as changed
            haveUnsavedGmaChanges = true;
            haveUnsavedTplChanges = true;

            // Update model list
            UpdateModelTree();
            UpdateModelButtons();
            UpdateModelDisplay();

            // Update material tab
            UpdateMaterialList();
            UpdateMaterialDisplay();

            // Update texture list
            UpdateTextureTree();
            UpdateTextureButtons();
            UpdateTextureDisplay();

            // Update model viewer
            reloadOnNextRedraw = true;
            glControlModel.Invalidate();
        }