Ejemplo n.º 1
0
        //static Ambertation.Panel3D p3d;
        public static void Execute(SimPe.PackedFiles.Wrapper.Cpf cmmat, SimPe.Interfaces.Files.IPackageFile package)
        {
            if (!(cmmat is MmatWrapper))
            {
                return;
            }

            MmatWrapper mmat = cmmat as MmatWrapper;

            try
            {
                PreviewForm f = new PreviewForm();
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii;
                f.scene = BuildScene(out fii, mmat, package);
                fii.Clear();
                if (f.scene == null)
                {
                    return;
                }
                f.dx.Reset();
                f.dx.ResetDefaultViewport();
                f.ShowDialog();
                f.dx.Meshes.Clear(true);
            }
            catch (System.IO.FileNotFoundException)
            {
                Wait.Stop();
                if (MessageBox.Show("The Microsoft Managed DirectX Extensions were not found on your System. Without them, the Preview is not available.\n\nYou can install them manually, by extracting the content of the DirectX\\ManagedDX.CAB on your Sims 2 Installation CD #1. If you double click on the extracted msi File, all needed Files will be installed.\n\nYou can also let SimPE install it automatically. SimPE will download the needed Files (3.5MB) from the SimPE Homepage and install them. Do you want SimPE to download and install the Files?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (WebUpdate.InstallMDX())
                    {
                        MessageBox.Show("Managed DirectX Extension were installed succesfully!");
                    }
                }

                return;
            }
            catch (Exception ex)
            {
                Wait.Stop();
                Helper.ExceptionMessage(ex);
            }
            finally
            {
            }
        }
Ejemplo n.º 2
0
        //static Ambertation.Panel3D p3d;
        public static void Execute(SimPe.PackedFiles.Wrapper.Cpf cmmat, SimPe.Interfaces.Files.IPackageFile package)
        {
            if (!(cmmat is MmatWrapper))
            {
                return;
            }

            MmatWrapper mmat = cmmat as MmatWrapper;

            Wait.Start();
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii = FileTable.FileIndex.AddNewChild();
            try
            {
                FileTable.FileIndex.Load();
                fii.AddIndexFromPackage(package);
                if (System.IO.File.Exists(package.SaveFileName))
                {
                    fii.AddIndexFromFolder(System.IO.Path.GetDirectoryName(package.SaveFileName));
                }


                GenericRcol rcol = mmat.GMDC;
                if (rcol != null)
                {
                    GeometryDataContainerExt gmdcext = new GeometryDataContainerExt(rcol.Blocks[0] as GeometryDataContainer);
                    gmdcext.UserTxmtMap[mmat.SubsetName] = mmat.TXMT;
                    gmdcext.UserTxtrMap[mmat.SubsetName] = mmat.TXTR;
                    Ambertation.Scenes.Scene scene = gmdcext.GetScene(new SimPe.Plugin.Gmdc.ElementOrder(Gmdc.ElementSorting.Preview));

                    PreviewForm f = new PreviewForm();
                    f.dx.AddScene(scene);
                    f.dx.ResetDefaultViewport();
                    f.ShowDialog();
                    f.dx.Meshes.Clear(true);
                }
                else
                {
                    Exception();
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                Wait.Stop();
                if (MessageBox.Show("The Microsoft Managed DirectX Extensions were not found on your System. Without them, the Preview is not available.\n\nYou can install them manually, by extracting the content of the DirectX\\ManagedDX.CAB on your Sims 2 Installation CD #1. If you double click on the extracted msi File, all needed Files will be installed.\n\nYou can also let SimPE install it automatically. SimPE will download the needed Files (3.5MB) from the SimPE Homepage and install them. Do you want SimPE to download and install the Files?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (WebUpdate.InstallMDX())
                    {
                        MessageBox.Show("Managed DirectX Extension were installed succesfully!");
                    }
                }

                return;
            }
            catch (Exception ex)
            {
                Wait.Stop();
                Helper.ExceptionMessage(ex);
            }
            finally
            {
                FileTable.FileIndex.RemoveChild(fii);
                fii.Clear();
            }
            Wait.Stop();
        }