예제 #1
0
        public static void Fix(string package, string modelname, FixVersion ver)
        {
            if (System.IO.File.Exists(package))
            {
                SimPe.Packages.GeneratableFile pkg = SimPe.Packages.GeneratableFile.LoadFromFile(package);

                System.Collections.Hashtable map = RenameForm.GetNames((modelname.Trim() != ""), pkg, null, modelname);
                FixObject fo = new FixObject(pkg, ver, false);
                fo.Fix(map, false);
                fo.CleanUp();
                fo.FixGroup();

                pkg.Save();
            }
        }
예제 #2
0
        public Interfaces.Plugin.IToolResult ShowDialog(ref SimPe.Interfaces.Files.IPackedFileDescriptor pfd, ref SimPe.Interfaces.Files.IPackageFile package)
        {
            FixObject fo = new FixObject(package, FixVersion.UniversityReady, false);

            try
            {
                System.Collections.Hashtable map = fo.GetNameMap(false);
                if (map == null)
                {
                    return(new ToolResult(false, false));
                }

                WaitingScreen.Wait();

                fo.Fix(map, false);
                fo.CleanUp();
                fo.FixGroup();
            }
            catch (Exception ex)
            {
                Helper.ExceptionMessage("", ex);
            }
            finally
            {
                WaitingScreen.Stop();
            }

            if (Helper.StartedGui != Executable.Classic)
            {
                return(new ToolResult(false, false));
            }
            else
            {
                return(new ToolResult(false, true));
            }
        }
예제 #3
0
        /// <summary>
        /// Add a small Scenegraph Chain
        /// </summary>
        /// <param name="mmat">the MAterial override File for this Subset</param>
        /// <param name="txmt">The Material Definition File for this Subset</param>
        /// <param name="txtr">The Txtr File for this Subset (can be null)</param>
        /// <param name="unique">A unique String for the Filenames</param>
        /// <param name="slavemap">The Slavemap as generated by Scenegraph.GetSlaveSubsets() (if null, no slave txmts are loaded)</param>
        void AddTxmt(IPackageFile newpkg, SimPe.Plugin.MmatWrapper mmat, GenericRcol txmt, GenericRcol txtr, string unique, Hashtable slavemap)
        {
            //Get/Update Material Definition
            if (txmt != null)
            {
                string name = Hashes.StripHashFromName(txmt.FileName.Trim());

                //load Slave TXMTs
                if (slavemap != null)
                {
                    LoadSlaveTxmt(newpkg, mmat, name, unique, slavemap);
                }

                if (name.ToLower().EndsWith("_txmt"))
                {
                    name = name.Substring(0, name.Length - 5);
                }
                txmt.FileName       = FixObject.GetUniqueTxmtName(name, unique, mmat.SubsetName, true);          ///*"##0x"+Helper.HexString(Data.MetaData.CUSTOM_GROUP)+"!"+*/name+"_"+unique+"_txmt";
                txmt.FileDescriptor = ScenegraphHelper.BuildPfd(txmt.FileName, Data.MetaData.TXMT, Data.MetaData.CUSTOM_GROUP);

                mmat.Name = "##0x" + Helper.HexString(txmt.FileDescriptor.Group) + "!" + FixObject.GetUniqueTxmtName(name, unique, mmat.SubsetName, false);

                MaterialDefinition md = (MaterialDefinition)txmt.Blocks[0];
                if (txtr == null)
                {
                    txtr = mmat.GetTxtr(txmt);
                    if (txtr != null)
                    {
                        txtr.FileDescriptor = (Interfaces.Files.IPackedFileDescriptor)txtr.FileDescriptor.Clone();
                    }
                }

                //Get/Update Texture
                if (txtr != null)
                {
                    name = AddTxtr(txtr, unique, txmt, md);

                    md.FileDescription = Hashes.StripHashFromName(txmt.FileName).Trim();
                    if (md.FileDescription.ToLower().EndsWith("_txmt"))
                    {
                        md.FileDescription = md.FileDescription.Substring(0, md.FileDescription.Length - 5);
                    }
                }

                if (txtr != null)
                {
                    txtr.SynchronizeUserData();
                    if (newpkg.FindFile(txtr.FileDescriptor) == null)
                    {
                        newpkg.Add(txtr.FileDescriptor);
                    }
                }

                AddReferencedTxtr(newpkg, txmt, md, unique);

                if (txmt != null)
                {
                    txmt.SynchronizeUserData();
                    if (newpkg.FindFile(txmt.FileDescriptor) == null)
                    {
                        newpkg.Add(txmt.FileDescriptor);
                    }
                }
            }
        }