コード例 #1
0
 public static Ambertation.Scenes.Scene BuildScene(MmatWrapper mmat, SimPe.Interfaces.Files.IPackageFile package)
 {
     SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii;
     Ambertation.Scenes.Scene scn = BuildScene(out fii, mmat, package);
     fii.Clear();
     return(scn);
 }
コード例 #2
0
        public static Image Get3dPreview(Ambertation.Scenes.Scene scene)
        {
            if (scene == null)
            {
                return(null);
            }
            scn = scene;
            InitPreview();

            dxp.ResetDevice += new EventHandler(dxp_ResetDevice);

            dxp.Reset();
            dxp.ResetDefaultViewport();
            dxp.Settings.AngelX = (float)(Math.PI / 8.0);
            dxp.Settings.AngelY = (float)(Math.PI / -6.0);
            dxp.Settings.Z     *= 0.3f;
            dxp.UpdateRotation();
            dxp.Render();
            Image ret = dxp.Screenshot(Microsoft.DirectX.Direct3D.ImageFileFormat.Png);

            /*System.Windows.Forms.Form f = new System.Windows.Forms.Form();
             * f.Controls.Add(dxp);
             * f.ShowDialog();*/


            dxp.ResetDevice -= new EventHandler(dxp_ResetDevice);

            return(ret);
        }
コード例 #3
0
        public Hashtable GetMaterials(Hashtable txmts, Ambertation.Scenes.Scene scn)
        {
            Hashtable list = new Hashtable();

            foreach (string s in txmts.Keys)
            {
                Rcol rcol             = (Rcol)txmts[s];
                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];

                list[s] = md.ToSceneMaterial(scn, Hashes.StripHashFromName(rcol.FileName));
            }
            return(list);
        }
コード例 #4
0
        protected void PostponedRender(object sender, EventArgs e)
        {
            Wait.SubStart();
            Wait.Message = "Building Preview";
            SimPe.Plugin.GeometryDataContainerExt ext = ((sender as PackageInfo).RenderData) as SimPe.Plugin.GeometryDataContainerExt;
            Ambertation.Scenes.Scene scn = ext.GetScene(new SimPe.Plugin.Gmdc.ElementOrder(SimPe.Plugin.Gmdc.ElementSorting.Preview));
            nfo.RenderedImage = Get3dPreview(scn);
            scn.Dispose();

            ext.Gmdc.Dispose();
            ext.Dispose();
            Wait.SubStop();
        }
コード例 #5
0
        /// <summary>
        /// Called when a new File is started
        /// </summary>
        /// <remarks>
        /// you should use this to write Header Informations.
        /// Use the writer member to write to the File
        /// </remarks>
        protected override void InitFile()
        {
            string name = System.IO.Path.GetFileNameWithoutExtension(this.FileName);
            string path = System.IO.Path.GetDirectoryName(this.FileName);

            path = System.IO.Path.Combine(path, name + ".IMG");


            GeometryDataContainerExt gext = new GeometryDataContainerExt(Gmdc);

            Ambertation.Scenes.Scene scn = gext.GetScene(this.Groups, path, name + ".IMG", this.Component);

            Ambertation.XSI.IO.AsciiFile xsi = Ambertation.XSI.IO.AsciiFile.FromScene(scn, FileName);
            xsi.SaveToStream(this.writer);
        }
コード例 #6
0
        public static Ambertation.Scenes.Scene BuildScene(SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii, MmatWrapper mmat, SimPe.Interfaces.Files.IPackageFile package)
        {
            SimPe.Interfaces.Files.IPackageFile npkg;
            Ambertation.Scenes.Scene            scn = BuildScene(fii, mmat, package, out npkg);

            if (npkg != null)
            {
                npkg.Close();
                if (npkg is SimPe.Packages.GeneratableFile)
                {
                    ((SimPe.Packages.GeneratableFile)npkg).Dispose();
                }
            }
            npkg = null;

            return(scn);
        }
コード例 #7
0
        public static Ambertation.Scenes.Scene RenderScene(MmatWrapper mmat)
        {
            try
            {
                try
                {
                    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));

                        return(scene);
                    }
                    else
                    {
                        Exception();
                    }
                }
                finally
                {
                }
            }
            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(null);
            }


            return(null);
        }
コード例 #8
0
        /// <summary>
        /// Creates a Material Object form this Block
        /// </summary>
        /// <returns></returns>
        public Ambertation.Scenes.Material ToSceneMaterial(Ambertation.Scenes.Scene scn, string name)
        {
            MaterialDefinitionProperty p;

            Ambertation.Scenes.Material mat = scn.CreateMaterial(name);
            p = this.GetProperty("stdMatSpecCoef"); if (p != null)
            {
                mat.Specular = p.ToARGB();
            }
            p = this.GetProperty("stdMatDiffCoef"); if (p != null)
            {
                mat.Diffuse = p.ToARGB();
            }
            p = this.GetProperty("stdMatEmissiveCoef");     if (p != null)
            {
                mat.Emmissive = p.ToARGB();
            }
            p = this.GetProperty("stdMatSpecPower");        if (p != null)
            {
                mat.SpecularPower = p.ToValue();
            }

            p = this.GetProperty("stdMatAlphaBlendMode");


            if (p != null)
            {
                if (p.Value == "blend")
                {
                    MaterialDefinitionProperty p2 = this.GetProperty("stdMatLightingEnabled");
                    if (p2 != null)
                    {
                        if (p2.ToValue() == 0)
                        {
                            mat.Mode = Ambertation.Scenes.Material.TextureModes.ShadowTexture;
                        }
                    }
                }
                //if (mat.Texture.AlphaBlend) mat.Diffuse = System.Drawing.Color.FromArgb(0x10, mat.Diffuse);
            }
            return(mat);
        }
コード例 #9
0
        protected void PostponedRender(object sender, EventArgs e)
        {
            Wait.SubStart();
            Wait.Message = "Building Preview";
            PackageInfo nfo = sender as PackageInfo;

            object[] data = nfo.RenderData as object[];
            tmppkg = SimPe.Packages.GeneratableFile.LoadFromFile(data[1].ToString());
            if (tmppkg == null)
            {
                return;
            }

            SimPe.Interfaces.Scenegraph.IScenegraphFileIndex fii = SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.AddNewChild();
            SimPe.Plugin.MmatWrapper mmat = data[0] as SimPe.Plugin.MmatWrapper;

            mmat.ProcessData(mmat.FileDescriptor, tmppkg);
            if (mmat != null)
            {
                fii.AddIndexFromPackage(mmat.Package, true);
                try
                {
                    Ambertation.Scenes.Scene scn = SimPe.Plugin.PreviewForm.RenderScene(mmat);
                    nfo.RenderedImage = Downloads.DefaultTypeHandler.Get3dPreview(scn);
                    scn.Dispose();
                    mmat.Dispose();
                }
                catch {}
            }


            fii.CloseAssignedPackages();
            SimPe.Plugin.DownloadsToolFactory.TeleportFileIndex.RemoveChild(fii);

            this.DisposeTmpPkg();
            Wait.SubStop();
        }
コード例 #10
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();
        }