Esempio n. 1
0
        /// <summary>
        /// Adss a DesignMode Block and returns it
        /// </summary>
        /// <param name="gmnd"></param>
        /// <param name="dle"></param>
        protected void AddDesignModeBlock(SimPe.Plugin.Rcol gmnd, DataListExtension dle)
        {
            dle.Extension.VarName = "tsDesignModeEnabled";

            /*IRcolBlock[] newblock = new IRcolBlock[gmnd.Blocks.Length+1];
             * for (int i=0; i<gmnd.Blocks.Length; i++)
             * {
             *      if (i==0) newblock[i] = gmnd.Blocks[i];
             *      else newblock[i+1] = gmnd.Blocks[i];
             * }
             * newblock[1] = dle;
             * gmnd.Blocks = newblock;*/


            SimPe.Plugin.GeometryNode gn = (SimPe.Plugin.GeometryNode)gmnd.Blocks[0];

            ObjectGraphNodeItem item = new ObjectGraphNodeItem();

            item.Enabled   = 0x01;
            item.Dependant = 0x00;
            item.Index     = (uint)gmnd.Blocks.Length;

            gn.ObjectGraphNode.Items = (ObjectGraphNodeItem[])Helper.Add(gn.ObjectGraphNode.Items, item);
            gmnd.Blocks = (IRcolBlock[])Helper.Add(gmnd.Blocks, dle, typeof(IRcolBlock));
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Will return a List of all SubSets that can be recolored
        /// </summary>
        /// <param name="pkg"></param>
        /// <returns>a List of Subset Names</returns>
        public static ArrayList GetSubsets(SimPe.Interfaces.Files.IPackageFile pkg, string blockname)
        {
            if (blockname == null)
            {
                blockname = "";
            }
            ArrayList list = new ArrayList();

            if (pkg == null)
            {
                return(list);
            }

            blockname = blockname.Trim().ToLower();
            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);

                foreach (IRcolBlock irb in gmnd.Blocks)
                {
                    if (irb.BlockName == "cDataListExtension")
                    {
                        DataListExtension dle = (DataListExtension)irb;
                        if (dle.Extension.VarName.Trim().ToLower() == blockname)
                        {
                            foreach (ExtensionItem ei in dle.Extension.Items)
                            {
                                list.Add(ei.Name.Trim().ToLower());
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 5
0
        /// <summary>
        /// Adds the Slave definitions of the passed gmnd to the passed map
        /// </summary>
        /// <param name="gmnd">the GMND File</param>
        /// <param name="map">the Map Table (key=master subset name, value= ArrayList of slave subsets</param>
        public static void GetSlaveSubsets(SimPe.Plugin.GenericRcol gmnd, Hashtable map)
        {
            foreach (IRcolBlock irb in gmnd.Blocks)
            {
                if (irb.BlockName == "cDataListExtension")
                {
                    DataListExtension dle = (DataListExtension)irb;
                    if (dle.Extension.VarName.Trim().ToLower() == "tsdesignmodeslavesubsets")
                    {
                        foreach (ExtensionItem ei in dle.Extension.Items)
                        {
                            string[]  slaves    = ei.String.Split(",".ToCharArray());
                            ArrayList slavelist = new ArrayList();
                            foreach (string s in slaves)
                            {
                                slavelist.Add(s.Trim().ToLower());
                            }

                            map[ei.Name.Trim().ToLower()] = slavelist;
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// adds the subsets to the tsDesignMode.. Block and returns a List of all added Subsets
        /// </summary>
        /// <param name="shpes"></param>
        /// <param name="gmnd"></param>
        /// <param name="subsets"></param>
        protected void GetSubsets(SimPe.Plugin.Rcol[] shpes, SimPe.Plugin.Rcol gmnd, ArrayList subsets)
        {
            ArrayList         list         = new ArrayList();
            ArrayList         localsubsets = new ArrayList();
            DataListExtension dle          = new DataListExtension(gmnd);
            uint index = (uint)(gm_pkg.FindFiles(0x4C697E5A).Length + 1);

            foreach (SimPe.Plugin.Rcol shpe in shpes)
            {
                SimPe.Plugin.Shape sh   = (SimPe.Plugin.Shape)shpe.Blocks[0];
                SimPe.Plugin.Rcol  cres = FindResourceNode(shpe);

                foreach (SimPe.Plugin.ShapePart part in sh.Parts)
                {
                    if (subsets.Contains(part.Subset))
                    {
                        continue;
                    }
                    if (localsubsets.Contains(part.Subset))
                    {
                        continue;
                    }

                    //Read the MATD
                    Interfaces.Files.IPackedFileDescriptor[] pfds = package.FindFile(part.FileName + "_txmt", 0x49596978);
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
                    {
                        SimPe.Plugin.Rcol matd = new GenericRcol(null, false);
                        matd.ProcessData(pfd, package);
                        SimPe.Plugin.MaterialDefinition md = (SimPe.Plugin.MaterialDefinition)matd.Blocks[0];

                        //check that the Material is not transparent
                        if (md.GetProperty("stdMatAlphaBlendMode").Value == "none")
                        {
                            //check that the Material references a texture
                            if (package.FindFile(md.GetProperty("stdMatBaseTextureName").Value + "_txtr", 0x1C4A276C).Length > 0)
                            {
                                localsubsets.Add(part.Subset);

                                SimPe.Plugin.ExtensionItem ei = new ExtensionItem();
                                ei.Name     = part.Subset;
                                ei.Typecode = ExtensionItem.ItemTypes.Array;

                                WorkshopMMAT i   = new WorkshopMMAT(part.Subset);
                                object[]     tag = new object[3];
                                tag[0] = matd;
                                tag[1] = cres.FileName;
                                tag[2] = ei;
                                i.Tag  = tag;

                                //if (md.GetProperty("stdMatAlphaBlendMode").Value!="none") i.AddObjectStateIndex(1);
                                list.Add(i);
                                //dle.Extension.Items = (ExtensionItem[])Helper.Add(dle.Extension.Items, ei);
                                //AddMMAT(matd, part.Type, cres.FileName, index++);
                            }
                        }
                    }
                }
            }

            WorkshopMMAT[] mmats = new WorkshopMMAT[list.Count];
            list.CopyTo(mmats);

            Listing li = new Listing();

            if (mmats.Length > 0)
            {
                mmats = li.Execute(mmats);
            }

            foreach (WorkshopMMAT mmat in mmats)
            {
                subsets.Add(mmat.Subset);
                dle.Extension.Items = (ExtensionItem[])Helper.Add(dle.Extension.Items, (ExtensionItem)mmat.Tag[2]);
                AddMMAT((SimPe.Plugin.Rcol)mmat.Tag[0], mmat.Subset, (string)mmat.Tag[1], index++, false);
            }

            if (dle.Extension.Items.Length > 0)
            {
                AddDesignModeBlock(gmnd, dle);
                gmnd.SynchronizeUserData();
                dn_pkg.Add(gmnd.FileDescriptor);
            }
        }