Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public static void Execute(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem animitem)
        {
            SimPe.Plugin.GenericRcol rcol = new GenericRcol();
            rcol.ProcessData(animitem);

            Execute(rcol);
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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);
                }
            }
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
                }
            }
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
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();
                    }
                }
            }
        }
Exemplo n.º 23
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();
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Create a new Instance and build the CRES chain
        /// </summary>
        /// <param name="modelnames">Name of all Models</param>
        /// <param name="ex">List of all ReferenceNames that should be excluded from the chain</param>
        public void Init(string[] modelnames, ArrayList ex)
        {
            exclude         = ex;
            this.modelnames = new ArrayList();
            ArrayList cres = LoadCres(modelnames);

            files    = new ArrayList();
            itemlist = new ArrayList();
            foreach (SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item in cres)
            {
                SimPe.Plugin.GenericRcol sub = new GenericRcol(null, false);
                sub.ProcessData(item);
                LoadReferenced(this.modelnames, ex, files, itemlist, sub, item, true, setup);
            }
            foreach (string s in modelnames)
            {
                this.modelnames.Add(s);
            }
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Add Resources referenced from XML Files
 /// </summary>
 protected void AddFromXml(SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem[] items)
 {
     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);
             }
         }
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Find the TXTRs that are referenced by the passed TXMTs
        /// </summary>
        /// <param name="txmts"></param>
        /// <param name="flname">null, or the Filename of a package to search in</param>
        /// <returns>null or the first found shpe</returns>
        public Hashtable FindReferencedTXTR(Hashtable txmts, string flname)
        {
            Hashtable ht = new Hashtable();

            if (txmts == null)
            {
                return(ht);
            }

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

            foreach (string subset in txmts.Keys)
            {
                Rcol rcol = (Rcol)txmts[subset];
                MaterialDefinition txmt     = (MaterialDefinition)rcol.Blocks[0];
                string             txtrname = Hashes.StripHashFromName(txmt.GetProperty("stdMatBaseTextureName").Value) + "_txtr";
                txtrname = txtrname.Trim().ToLower();

                Interfaces.Files.IPackedFileDescriptor[] pfds = lpackage.FindFile(txtrname, 0x1C4A276C);
                foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                {
                    Rcol txtr = new GenericRcol(null, false);
                    txtr.ProcessData(pfd, lpackage);

                    if (Hashes.StripHashFromName(txtr.FileName).Trim().ToLower() == txtrname)
                    {
                        if (!ht.Contains(subset))
                        {
                            ht.Add(subset, txtr);
                        }
                    }
                }
            }


            return(ht);
        }
Exemplo n.º 28
0
        /// <summary>
        /// If this MipMap is a LifoReference, then this Method will try to load the Lifo Data
        /// </summary>
        protected bool GetReferencedLifo_NoLoad()
        {
            if (datatype == MipMapType.LifoReference)
            {
                SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(this.lifofile, SimPe.Data.MetaData.LIFO, SimPe.Data.MetaData.LOCAL_GROUP, true);
                GenericRcol rcol = null;

                if (item != null)               //we have a global LIFO (loads faster)
                {
                    rcol = new GenericRcol(null, false);
                    rcol.ProcessData(item.FileDescriptor, item.Package);
                }
                else                 //the lifo wasn't found globaly, so we look for it in the local package
                {
                    SimPe.Interfaces.Files.IPackageFile            pkg  = parent.Parent.Package;
                    SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = pkg.FindFile(this.lifofile, SimPe.Data.MetaData.LIFO);
                    if (pfds.Length > 0)
                    {
                        rcol = new GenericRcol(null, false);
                        rcol.ProcessData(pfds[0], pkg);
                    }
                }

                //process the Lifo File if found
                if (rcol != null)
                {
                    LevelInfo li = (LevelInfo)rcol.Blocks[0];

                    this.img  = null;
                    this.Data = li.Data;

                    return(true);
                }
            }
            else
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 29
0
        string FindTxtrName(string name)
        {
            SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(name, Data.MetaData.TXTR, 0xffffffff, true);
            if (item != null)
            {
                Rcol txtr = new GenericRcol(null, false);
                txtr.ProcessData(item);
                name = txtr.FileName.Trim();
                if (name.ToLower().EndsWith("_txtr"))
                {
                    name = name.Substring(0, name.Length - 5);
                }
                if (name.StartsWith("#"))
                {
                    name = "_" + name;
                }
            }
            name = name.Replace("-", "_");

            return(name);
        }
Exemplo n.º 30
0
        /// <summary>
        /// ind the ResourceNode that is referencing the passed Shape
        /// </summary>
        /// <param name="shpe"></param>
        /// <returns></returns>
        protected SimPe.Plugin.Rcol FindResourceNode(SimPe.Plugin.Rcol shpe)
        {
            Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFiles(0xE519C933);
            Interfaces.Files.IPackedFileDescriptor   pfd  = shpe.FileDescriptor;

            foreach (Interfaces.Files.IPackedFileDescriptor cpfd in pfds)
            {
                SimPe.Plugin.Rcol cres = new GenericRcol(null, false);
                cres.ProcessData(cpfd, package);

                foreach (Interfaces.Files.IPackedFileDescriptor rpfd in cres.ReferencedFiles)
                {
                    if ((rpfd.Group == pfd.Group) && (rpfd.Instance == pfd.Instance) && (rpfd.SubType == pfd.SubType) && (rpfd.Type == pfd.Type))
                    {
                        return(cres);
                    }
                }
            }

            return(new GenericRcol(null, false));
        }