Example #1
0
        /// <summary>
        /// Returns a list of all GMNDs that need a tsDesignMode Block
        /// </summary>
        /// <returns>List of GMNDs</returns>
        /// <remarks>Will return an empty List if the Block is found in at least one of the GMNDs</remarks>
        protected SimPe.Plugin.Rcol[] GetGeometryNodes()
        {
            ArrayList list = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor[] pfds = this.package.FindFiles(0x7BA3838C);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol gmnd = new GenericRcol(null, false);
                gmnd.ProcessData(pfd, package);
                foreach (IRcolBlock rb in gmnd.Blocks)
                {
                    if (rb.BlockName == "cDataListExtension")
                    {
                        DataListExtension dle = (DataListExtension)rb;
                        //if (dle.Extension.VarName.Trim().ToLower()=="tsnoshadow") list.Add(gmnd);
                        if (dle.Extension.VarName.Trim().ToLower() == "tsdesignmodeenabled")
                        {
                            return(new Rcol[0]);
                        }
                    }
                }
                list.Add(gmnd);
            }

            SimPe.Plugin.Rcol[] rcols = new Rcol[list.Count];
            list.CopyTo(rcols);
            return(rcols);
        }
Example #2
0
        /// <summary>
        /// Add the MATD referenced by the passed MMAT
        /// </summary>
        /// <param name="mmat">A valid MMAT file</param>
        protected void AddMATD(SimPe.PackedFiles.Wrapper.Cpf mmat)
        {
            SimPe.Packages.File pkg  = SimPe.Packages.File.LoadFromFile(System.IO.Path.Combine(PathProvider.Global.GetExpansion(Expansions.BaseGame).InstallFolder, "TSData\\Res\\Sims3D\\Objects02.package"));
            ArrayList           list = new ArrayList();
            string flname            = Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue) + "_txmt";

            Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(flname, 0x49596978);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol matd = new GenericRcol(null, false);
                matd.ProcessData(pfd, pkg);

                if (matd.FileName.Trim().ToLower() == flname.Trim().ToLower())
                {
                    matd.SynchronizeUserData();
                    if (package.FindFile(matd.FileDescriptor) == null)
                    {
                        package.Add(matd.FileDescriptor);
                    }
                }
            }

            //pkg.Reader.Close();
        }
Example #3
0
        /// <summary>
        /// Returns a List of all objects that Refer to the passed GMND
        /// </summary>
        /// <param name="gmnd">a GMND</param>
        /// <returns>List of SHPEs</returns>
        protected SimPe.Plugin.Rcol[] GetReferingShape(SimPe.Plugin.Rcol gmnd)
        {
            ArrayList list = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor[] pfds = this.package.FindFiles(0xFC6EB1F7);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol shpe = new GenericRcol(null, false);
                shpe.ProcessData(pfd, package);
                SimPe.Plugin.Shape sh = (SimPe.Plugin.Shape)shpe.Blocks[0];

                foreach (SimPe.Plugin.ShapeItem item in sh.Items)
                {
                    if (item.FileName.Trim().ToLower() == gmnd.FileName.Trim().ToLower())
                    {
                        list.Add(shpe);
                        break;
                    }
                }
            }

            SimPe.Plugin.Rcol[] rcols = new Rcol[list.Count];
            list.CopyTo(rcols);
            return(rcols);
        }
Example #4
0
        public static void Execute(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem animitem)
        {
            SimPe.Plugin.GenericRcol rcol = new GenericRcol();
            rcol.ProcessData(animitem);

            Execute(rcol);
        }
Example #5
0
        /// <summary>
        /// Loads Slave TXMTs by name Replacement
        /// </summary>
        /// <param name="pkg">the package File with the base TXMTs</param>
        /// <param name="slaves">The Hashtable holding als Slave Subsets</param>
        public static void AddSlaveTxmts(SimPe.Interfaces.Files.IPackageFile pkg, Hashtable slaves)
        {
            ArrayList files = new ArrayList();
            ArrayList items = new ArrayList();

            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                GenericRcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, pkg);

                if (rcol.FileDescriptor.Type == Data.MetaData.TXMT)
                {
                    AddSlaveTxmts(new ArrayList(), new ArrayList(), files, items, rcol, slaves);
                }
            }

            foreach (GenericRcol rcol in files)
            {
                if (pkg.FindFile(rcol.FileDescriptor) == null)
                {
                    rcol.FileDescriptor = rcol.FileDescriptor.Clone();
                    rcol.SynchronizeUserData();
                    pkg.Add(rcol.FileDescriptor);
                }
            }
        }
Example #6
0
        /// <summary>
        /// Add Resources referenced from 3IDR Files
        /// </summary>
        /// <param name="names"></param>
        public void AddFrom3IDR(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.REF_FILE);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.RefFile re = new RefFile();
                re.ProcessData(pfd, pkg);

                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor p in re.Items)
                {
                    SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(p, null);
                    foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                    {
                        try
                        {
                            SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false);
                            sub.ProcessData(item);
                            LoadReferenced(this.modelnames, this.exclude, files, itemlist, sub, item, true, setup);
                        }
                        catch (Exception ex)
                        {
                            if (Helper.DebugMode)
                            {
                                Helper.ExceptionMessage("", ex);
                            }
                        }
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// Find the GMND that is referencing the passed gmdc
        /// </summary>
        /// <param name="gmdc"></param>
        /// <param name="flname">null, or the Filename of a package to search in</param>
        /// <returns>null or the found gmnd</returns>
        public Rcol FindReferencingGMND(Rcol gmdc, string flname)
        {
            if (gmdc == null)
            {
                return(null);
            }

            SimPe.Interfaces.Files.IPackageFile lpackage = package;
            if (flname != null)
            {
                lpackage = SimPe.Packages.File.LoadFromFile(flname);
            }

            Interfaces.Files.IPackedFileDescriptor[] pfds = lpackage.FindFiles(0x7BA3838C);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, lpackage);
                foreach (Interfaces.Files.IPackedFileDescriptor rpfd in rcol.ReferencedFiles)
                {
                    if ((gmdc.FileDescriptor.Group == rpfd.Group) &&
                        (gmdc.FileDescriptor.Instance == rpfd.Instance) &&
                        (gmdc.FileDescriptor.SubType == rpfd.SubType) &&
                        (gmdc.FileDescriptor.Type == rpfd.Type))
                    {
                        return(rcol);
                    }
                }
            }

            return(null);
        }
Example #8
0
        /// <summary>
        /// Find the SHPE that is referencing the passed GMND
        /// </summary>
        /// <param name="gmnd"></param>
        /// <param name="flname">null, or the Filename of a package to search in</param>
        /// <returns>null or the first found shpe</returns>
        public Rcol FindReferencingSHPE(Rcol gmnd, string flname)
        {
            if (gmnd == null)
            {
                return(null);
            }

            SimPe.Interfaces.Files.IPackageFile lpackage = package;
            if (flname != null)
            {
                lpackage = SimPe.Packages.File.LoadFromFile(flname);
            }

            Interfaces.Files.IPackedFileDescriptor[] pfds = lpackage.FindFiles(0xFC6EB1F7);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, lpackage);

                Shape shp = (Shape)rcol.Blocks[0];
                foreach (ShapeItem i in shp.Items)
                {
                    if (Hashes.StripHashFromName(i.FileName).Trim().ToLower() == Hashes.StripHashFromName(gmnd.FileName).Trim().ToLower())
                    {
                        return(rcol);
                    }
                }
            }

            return(null);
        }
Example #9
0
        protected GenericRcol LoadTXTR(GenericRcol txmt)
        {
            if (txmt == null)
            {
                return(null);
            }

            try
            {
                MaterialDefinition md       = (MaterialDefinition)txmt.Blocks[0];
                string             txtrname = md.FindProperty("stdMatBaseTextureName").Value.Trim().ToLower();
                if (!txtrname.EndsWith("_txtr"))
                {
                    txtrname += "_txtr";
                }

                Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(txtrname, Data.MetaData.TXTR, Data.MetaData.LOCAL_GROUP, true);
                if (item != null)
                {
                    SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(item, false);

                    return(rcol);
                }
            }
            catch {}

            return(null);
        }
Example #10
0
        /// <summary>
        /// Returns the RCOL which lists this Resource in it's ReferencedFiles Attribute
        /// </summary>
        /// <returns>null or the RCOl Ressource</returns>
        /// <remarks>This Version will not Load the FileTable!</remarks>
        public Rcol FindReferencingSHPE_NoLoad()
        {
            Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(SimPe.Data.MetaData.SHPE, true);
            string mn = Hashes.StripHashFromName(this.Parent.FileName.Trim().ToLower());

            foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item  in items)
            {
                Rcol r = new GenericRcol(null, false);
                //try to open the File in the same package, not in the FileTable Package!
                if (item.Package.SaveFileName.Trim().ToLower() == parent.Package.SaveFileName.Trim().ToLower())
                {
                    r.ProcessData(parent.Package.FindFile(item.FileDescriptor), parent.Package);
                }
                else
                {
                    r.ProcessData(item);
                }

                Shape s = (Shape)r.Blocks[0];

                foreach (ShapeItem i in s.Items)
                {
                    string n = Hashes.StripHashFromName(i.FileName).Trim().ToLower();
                    if (n == mn)
                    {
                        return(r);
                    }
                }
            }

            return(null);
        }
Example #11
0
        public void GraphItemClick(object sender, EventArgs e)
        {
            GraphItem gi = (GraphItem)sender;
            Hashtable ht = null;

            llopen.Enabled = false;
            selpfd         = null;
            if (gi.Tag.GetType() == typeof(string))
            {
                this.tbflname.Text = (string)gi.Tag;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
            }
            else if (gi.Tag.GetType() == typeof(GenericRcol))
            {
                GenericRcol rcol = (GenericRcol)gi.Tag;
                this.tbflname.Text = rcol.FileName;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
                ht = rcol.ReferenceChains;

                if (rcol.Package.FileName == open_pkg.FileName)
                {
                    selpfd = rcol.FileDescriptor;
                }
            }
            else if (gi.Tag.GetType() == typeof(SimPe.Plugin.MmatWrapper))
            {
                SimPe.Plugin.MmatWrapper mmat = (SimPe.Plugin.MmatWrapper)gi.Tag;
                this.tbflname.Text = mmat.SubsetName;
                this.cbrefnames.Items.Clear();
                cbrefnames.Text = "";
                ht = mmat.ReferenceChains;

                if (mmat.Package.FileName == open_pkg.FileName)
                {
                    selpfd = mmat.FileDescriptor;
                }
            }

            llopen.Enabled = (selpfd != null);

            if (ht != null)
            {
                foreach (string s in ht.Keys)
                {
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in (ArrayList)ht[s])
                    {
                        this.cbrefnames.Items.Add(pfd.Filename);
                    }
                }
            }

            if (cbrefnames.Items.Count > 0)
            {
                cbrefnames.SelectedIndex = 0;
            }
        }
Example #12
0
        private void llExport_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            AnimBlock1  ab1  = (AnimBlock1)tv.SelectedNode.Tag;
            GenericRcol gmdc = ab1.FindUsedGMDC(ab1.FindDefiningCRES());

            if (gmdc != null)
            {
            }
        }
Example #13
0
        protected string AddTxtr(GenericRcol txtr, string unique, GenericRcol txmt, MaterialDefinition md)
        {
            string old = Hashes.StripHashFromName(txtr.FileName.Trim().ToLower());

            if (old.EndsWith("_txtr"))
            {
                old = old.Substring(0, old.Length - 5);
            }
            //Console.WriteLine("Adding Texture: "+old);

            string name = txtr.FileName.Trim();

            if (name.ToLower().EndsWith("_txtr"))
            {
                name = name.Substring(0, name.Length - 5);
            }

            string tname = RenameForm.ReplaceOldUnique(name, unique, true);

            txtr.FileName = tname + "_txtr";

            txtr.FileDescriptor = ScenegraphHelper.BuildPfd(txtr.FileName, Data.MetaData.TXTR, Data.MetaData.CUSTOM_GROUP);

            for (int i = 0; i < md.Listing.Length; i++)
            {
                if (Hashes.StripHashFromName(md.Listing[i].Trim().ToLower()) == old)
                {
                    md.Listing[i] = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                }
            }

            //update References
            foreach (string k in txmt.ReferenceChains.Keys)
            {
                if (k == "TXTR" || k == "Generic")
                {
                    continue;
                }
                //Console.WriteLine("    Checking Property "+k);
                string thisname = Hashes.StripHashFromName(md.FindProperty(k).Value.Trim().ToLower());

                if (thisname == old)
                {
                    string nname = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                    //Console.WriteLine("    --> Updating to "+nname);
                    md.FindProperty(k).Value = nname;
                }
            }

            //Load the Lifos into the Texture File
            ImageData id = (ImageData)txtr.Blocks[0];

            id.GetReferencedLifos();

            return(name);
        }
Example #14
0
        protected GenericRcol GetGmdc()
        {
            GenericRcol rcol = CRES;

            if (rcol != null)
            {
                Hashtable refs = rcol.ReferenceChains;
                ArrayList shps = (ArrayList)refs["Generic"];
                if (shps != null)
                {
                    if (shps.Count > 0)
                    {
                        Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile((Interfaces.Files.IPackedFileDescriptor)shps[0], null);
                        if (items.Length > 0)
                        {
                            GenericRcol shpe = new GenericRcol(null, false);
                            shpe.ProcessData(items[0].FileDescriptor, items[0].Package);

                            refs = shpe.ReferenceChains;
                            ArrayList gmnds = (ArrayList)refs["Models"];
                            if (gmnds != null)
                            {
                                if (gmnds.Count > 0)
                                {
                                    items = FileTable.FileIndex.FindFile((Interfaces.Files.IPackedFileDescriptor)gmnds[0], null);
                                    if (items.Length > 0)
                                    {
                                        GenericRcol gmnd = new GenericRcol(null, false);
                                        gmnd.ProcessData(items[0].FileDescriptor, items[0].Package);

                                        refs = gmnd.ReferenceChains;
                                        ArrayList gmdcs = (ArrayList)refs["Generic"];
                                        if (gmdcs != null)
                                        {
                                            if (gmdcs.Count > 0)
                                            {
                                                items = FileTable.FileIndex.FindFile((Interfaces.Files.IPackedFileDescriptor)gmdcs[0], null);
                                                if (items.Length > 0)
                                                {
                                                    GenericRcol gmdc = new GenericRcol(null, false);
                                                    gmdc.ProcessData(items[0].FileDescriptor, items[0].Package);

                                                    return(gmdc);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
Example #15
0
        /// <summary>
        /// Loads Slave TXMTs by name Replacement
        /// </summary>
        /// <param name="slaves">The Hashtable holding als Slave Subsets</param>
        public void AddSlaveTxmts(Hashtable slaves)
        {
            for (int i = files.Count - 1; i >= 0; i--)
            {
                GenericRcol rcol = (GenericRcol)files[i];

                if (rcol.FileDescriptor.Type == Data.MetaData.TXMT)
                {
                    AddSlaveTxmts(this.modelnames, this.exclude, files, itemlist, rcol, slaves);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Returns the RCOL which lists this Resource in it's ReferencedFiles Attribute
        /// </summary>
        /// <param name="type">the Type of the ressource youar looking for</param>
        /// <returns>null or the RCOl Ressource</returns>
        /// <remarks>This Version will not load the FileTable</remarks>
        public Rcol FindReferencingParent_NoLoad(uint type)
        {
            WaitMessasge wm;

            Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(type, true);
            try
            {
                if (Wait.Running)
                {
                    wm = delegate(string message) { Wait.Message = message; Wait.Progress++; }; Wait.SubStart(items.Length);
                }
                else
                {
                    wm = delegate(string message) { }
                };

                foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in items)
                {
                    wm("");
                    Rcol r = new GenericRcol(null, false);

                    //try to open the File in the same package, not in the FileTable Package!
                    if (item.Package.SaveFileName.Trim().ToLower() == parent.Package.SaveFileName.Trim().ToLower())
                    {
                        r.ProcessData(parent.Package.FindFile(item.FileDescriptor), parent.Package);
                    }
                    else
                    {
                        r.ProcessData(item);
                    }

                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in r.ReferencedFiles)
                    {
                        if (
                            pfd.Type == this.Parent.FileDescriptor.Type &&
                            (pfd.Group == this.Parent.FileDescriptor.Group || (pfd.Group == Data.MetaData.GLOBAL_GROUP && Parent.FileDescriptor.Group == Data.MetaData.LOCAL_GROUP)) &&
                            pfd.SubType == this.Parent.FileDescriptor.SubType &&
                            pfd.Instance == this.Parent.FileDescriptor.Instance
                            )
                        {
                            return(r);
                        }
                    }
                }
            }
            finally { if (Wait.Running)
                      {
                          Wait.SubStop();
                      }
            }

            return(null);
        }
Example #17
0
        protected string AddTxtr(IPackageFile newpkg, GenericRcol txtr, string unique, GenericRcol txmt, MaterialDefinition md)
        {
            string name = AddTxtr(txtr, unique, txmt, md);

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

            return(name);
        }
Example #18
0
        /// <summary>
        /// Clone the Makeup of a Sim
        /// </summary>
        /// <returns>the new Package for the patient Sim</returns>
        /// <param name="eyecolor">true, if you want to alter the eyecolor</param>
        /// <param name="makeups">true, if you want to alter the makeup</param>
        public SimPe.Packages.GeneratableFile CloneMakeup(bool eyecolor, bool makeups)
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);

            ArrayList list = new ArrayList();

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            //Update TXMT Files for the Face
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, ret);

                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];
                this.UpdateMakeup(md, eyecolor, makeups);

                rcol.SynchronizeUserData();
            }

            if (eyecolor)
            {
                //Update DNA File
                Interfaces.Files.IPackedFileDescriptor dna  = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
                Interfaces.Files.IPackedFileDescriptor adna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, sarchetype.Instance);
                if ((dna != null) && (adna != null))
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                    cpf.ProcessData(dna, ngbh);

                    SimPe.PackedFiles.Wrapper.Cpf acpf = new Cpf();
                    acpf.ProcessData(adna, ngbh);
                    cpf.GetSaveItem("3").StringValue = acpf.GetSaveItem("3").StringValue;

                    cpf.SynchronizeUserData();
                }
            }
            return(ret);
        }
Example #19
0
        /// <summary>
        /// Will return a Hashtable (key = subset name) of ArrayLists (slave subset names)
        /// </summary>
        /// <param name="pkg"></param>
        /// <returns></returns>
        public static Hashtable GetSlaveSubsets(SimPe.Interfaces.Files.IPackageFile pkg)
        {
            Hashtable map = new Hashtable();

            SimPe.Interfaces.Files.IPackedFileDescriptor[] gmnds = pkg.FindFiles(Data.MetaData.GMND);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in gmnds)
            {
                SimPe.Plugin.GenericRcol gmnd = new GenericRcol(null, false);
                gmnd.ProcessData(pfd, pkg);

                GetSlaveSubsets(gmnd, map);
            }
            return(map);
        }
Example #20
0
        /// <summary>
        /// Add Wallmasks (if available) to the Clone
        /// </summary>
        /// <param name="instances"></param>
        public void AddStrLinked(SimPe.Interfaces.Files.IPackageFile pkg, CloneSettings.StrIntsanceAlias[] instances)
        {
            foreach (CloneSettings.StrIntsanceAlias instance in instances)
            {
                ArrayList rcols = LoadStrLinked(pkg, instance);

                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in rcols)
                {
                    SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false);
                    sub.ProcessData(item);
                    LoadReferenced(this.modelnames, this.exclude, files, itemlist, sub, item, true, setup);
                }
            }
        }
Example #21
0
        /// <summary>
        /// Add Wallmasks (if available) to the Clone
        /// </summary>
        /// <param name="modelnames"></param>
        /// <remarks>based on Instructions By Numenor</remarks>
        public void AddWallmasks(string[] modelnames)
        {
            foreach (string s in modelnames)
            {
                ArrayList txmt = LoadWallmask(s);

                foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in txmt)
                {
                    SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false);
                    sub.ProcessData(item);
                    LoadReferenced(this.modelnames, this.exclude, files, itemlist, sub, item, true, setup);
                }
            }
        }
Example #22
0
        /// <summary>
        /// Loads the ModelNames of the Objects referenced in all tsMaterialsMeshName Block
        /// </summary>
        /// <param name="pkg"></param>
        /// <param name="delete">true, if the tsMaterialsMeshName Blocks should get cleared</param>
        /// <returns>A List of Modelnames</returns>
        public static string[] LoadParentModelNames(SimPe.Interfaces.Files.IPackageFile pkg, bool delete)
        {
            if (WaitingScreen.Running)
            {
                WaitingScreen.UpdateMessage("Loading Parent Modelnames");
            }
            ArrayList list = new ArrayList();

            Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFiles(Data.MetaData.GMND);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, pkg);

                foreach (IRcolBlock irb in rcol.Blocks)
                {
                    if (irb.BlockName.Trim().ToLower() == "cdatalistextension")
                    {
                        DataListExtension dle = (DataListExtension)irb;
                        if (dle.Extension.VarName.Trim().ToLower() == "tsmaterialsmeshname")
                        {
                            foreach (ExtensionItem ei in dle.Extension.Items)
                            {
                                string mname = ei.String.Trim().ToLower();
                                if (mname.EndsWith("_cres"))
                                {
                                    mname += "_cres";
                                }

                                if (!list.Contains(mname))
                                {
                                    list.Add(mname);
                                }
                            }

                            dle.Extension.Items = new ExtensionItem[0];
                            rcol.SynchronizeUserData();
                            break;
                        }
                    }
                }
            }

            string[] ret = new string[list.Count];
            list.CopyTo(ret);

            return(ret);
        }
Example #23
0
        protected GenericRcol LoadRcol(uint type, Interfaces.Files.IPackedFileDescriptor pfd)
        {
            if (pfd.Type == type)
            {
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFile(pfd, null);
                if (items.Length > 0)
                {
                    SimPe.Plugin.GenericRcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(items[0], false);

                    return(rcol);
                }
            }

            return(null);
        }
Example #24
0
        /// <summary>
        /// Searches RCOL Files
        /// </summary>
        /// <param name="pfd"></param>
        /// <param name="package"></param>
        /// <param name="prov"></param>
        /// <returns>Null if no match or a valid SearchItem Object</returns>
        public SearchItem RcolSearch(Interfaces.Files.IPackedFileDescriptor pfd, Interfaces.Files.IPackageFile package, Interfaces.IProviderRegistry prov)
        {
            string flname = Hashes.StripHashFromName(tbflname.Text);
            uint   inst   = Hashes.InstanceHash(flname);
            uint   st     = Hashes.SubTypeHash(flname);

            if ((pfd.Instance == inst) && ((pfd.SubType == st) || pfd.SubType == 0))
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(prov, false);
                rcol.ProcessData(pfd, package);
                return(new SearchItem(rcol.FileName, pfd));
            }


            return(null);
        }
Example #25
0
        /// <summary>
        /// Load a Texture belonging to a TXMT
        /// </summary>
        /// <param name="txmt">a valid txmt</param>
        /// <returns>the Texture or null</returns>
        public GenericRcol GetTxtr(GenericRcol txmt)
        {
            if (txmt == null)
            {
                return(null);
            }
            Hashtable refs  = txmt.ReferenceChains;
            ArrayList txtrs = (ArrayList)refs["stdMatBaseTextureName"];            //["TXTR"];

            if (txtrs != null)
            {
                if (txtrs.Count > 0)
                {
                    Interfaces.Files.IPackedFileDescriptor pfd = package.FindFile((Interfaces.Files.IPackedFileDescriptor)txtrs[0]);
                    if (pfd == null)                   //fallback code
                    {
                        Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(((Interfaces.Files.IPackedFileDescriptor)txtrs[0]).Filename, Data.MetaData.TXTR);
                        if (pfds.Length > 0)
                        {
                            pfd = pfds[0];
                        }
                    }
                    if (pfd != null)
                    {
                        GenericRcol txtr = new GenericRcol(null, false);
                        txtr.ProcessData(pfd, package);

                        return(txtr);
                    }

                    if (pfd == null)                   //FileTable fallback code
                    {
                        Interfaces.Scenegraph.IScenegraphFileIndexItem[] items = FileTable.FileIndex.FindFileDiscardingGroup((Interfaces.Files.IPackedFileDescriptor)txtrs[0]);
                        if (items.Length > 0)
                        {
                            GenericRcol txtr = new GenericRcol(null, false);
                            txtr.ProcessData(items[0].FileDescriptor, items[0].Package);

                            return(txtr);
                        }
                    }
                }
            }

            return(null);
        }
Example #26
0
        SimPe.Interfaces.Scenegraph.IScenegraphItem BuildRcol(SimPe.Interfaces.Files.IPackedFileDescriptor pfd, SimPe.Interfaces.Files.IPackageFile pkg, GraphItem gi)
        {
            GenericRcol rcol = new GenericRcol(null, false);

            rcol.ProcessData(pfd, pkg);

            gi.Text = Hashes.StripHashFromName(rcol.FileName);
            gi.Tag  = rcol;

            if (pfd.Type == Data.MetaData.TXTR)
            {
                ImageData id = (ImageData)rcol.Blocks[0];
                gi.Size      = new Size(gi.Size.Width, 80);
                gi.Thumbnail = ImageLoader.Preview(id.LargestTexture.Texture, new Size(48, 48));
            }
            return(rcol);
        }
Example #27
0
        /// <summary>
        /// This adds all second Leve Textures to the Recolor (like normal Maps)
        /// </summary>
        /// <param name="newpkg"></param>
        /// <param name="md"></param>
        protected void AddReferencedTxtr(IPackageFile newpkg, GenericRcol txmt, MaterialDefinition md, string unique)
        {
            foreach (string k in txmt.ReferenceChains.Keys)
            {
                if (k.ToLower() == "stdmatnormalmaptexturename")               //at the moment i only know of NormalMaps that need to be added
                {
                    MaterialDefinitionProperty mdp = md.GetProperty(k);
                    if (mdp != null)
                    {
                        string name = Hashes.StripHashFromName(mdp.Value).Trim();
                        if (!name.EndsWith("_txtr"))
                        {
                            name += "_txtr";
                        }

                        //Console.Write("loading second txtr "+mdp.Name+" = "+mdp.Value);
                        IPackageFile pkg = txmt.Package;
                        SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(name, Data.MetaData.TXTR);
                        if (pfds.Length > 0)
                        {
                            SimPe.Interfaces.Files.IPackedFileDescriptor pfd = pfds[0];
                            //Console.Write(" [found in local Package]");

                            GenericRcol txtr = new GenericRcol();
                            txtr.ProcessData(pfd, pkg);

                            AddTxtr(newpkg, txtr, unique, txmt, md);
                        }

                        /*else  //we don't pull from the Filetable, as we expect, that all needed Files are already cloned!
                         * {
                         *      SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(name, Data.MetaData.TXTR, Hashes.GetHashGroupFromName(mdp.Value, Data.MetaData.GLOBAL_GROUP), true);
                         *      if (item!=null)
                         *      {
                         *              Console.Write(" [found in FileTable]");
                         *      }
                         * }*/


                        //Console.WriteLine();
                    }
                }
            }
        }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="map"></param>
        public void FixNames(Hashtable map)
        {
            foreach (uint type in Data.MetaData.RcolList)
            {
                Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(type);
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    Rcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(pfd, package);

                    string name = Hashes.StripHashFromName(FindReplacementName(map, rcol));
                    //if (rcol.FileDescriptor.Type==Data.MetaData.TXMT || rcol.FileDescriptor.Type==Data.MetaData.TXTR) name = "##0x"+Helper.HexString(Data.MetaData.CUSTOM_GROUP)+"!"+name;
                    rcol.FileName = name;

                    FixResource(map, rcol);
                    rcol.SynchronizeUserData();
                }
            }
        }
Example #29
0
        /// <summary>
        /// Add a New Item to the ListView
        /// </summary>
        /// <param name="lv">the list view you want to add the items to</param>
        /// <param name="mmats">an array of MmatWraper Objects having all possible states</param>
        protected void AddItem(ListView lv, ArrayList mmats)
        {
            if (mmats.Count == 0)
            {
                return;
            }


            ListViewItem lvi  = new ListViewItem();
            GenericRcol  txtr = ((SimPe.Plugin.MmatWrapper)mmats[0]).TXTR;
            GenericRcol  txmt = ((SimPe.Plugin.MmatWrapper)mmats[0]).TXMT;

            if (txmt != null)
            {
                string txmtname = Hashes.StripHashFromName(txmt.FileName.Trim().ToLower());
                if (!txmtnames.ContainsKey(txmtname))
                {
                    if (txtr != null)
                    {
                        lvi.Text = txtr.FileName;
                        lvi.Tag  = mmats;

                        MakePreview(lv.LargeImageList, lvi, mmats);

                        lv.Items.Add(lvi);
                    }
                    else
                    {
                        lvi.Text = txmt.FileName;
                        lvi.Tag  = mmats;
                        lv.Items.Add(lvi);
                    }

                    txmtnames.Add(txmtname, lvi);
                }                 //txmtnames
                else
                {
                    ListViewItem l  = (ListViewItem)txmtnames[txmtname];
                    ArrayList    ls = (ArrayList)l.Tag;
                    ls.AddRange(mmats);
                }
            }
        }
Example #30
0
        /// <summary>
        /// Returns the Hasvalue used for the Patient
        /// </summary>
        /// <returns></returns>
        uint GetPatientHash()
        {
            Random rn        = new Random();
            uint   hashgroup = (uint)((uint)rn.Next(0xffffff) | 0xff000000);

            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                ///This is a scenegraph Resource so get the Hash from there!
                if (Data.MetaData.RcolList.Contains(pfd.Type))
                {
                    SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                    rcol.ProcessData(pfd, patient);
                    hashgroup = Hashes.GroupHash(rcol.FileName);
                    break;
                }
            }

            return(hashgroup);
        }