Exemplo n.º 1
0
        /// <summary>
        /// Retusn a Hashtable that contains the largest Images of the passed Textures
        /// </summary>
        /// <param name="txtrs"></param>
        /// <returns>The Keys of the Hashtabel are the Subset names, the values contain ImageStreams</returns>
        public Hashtable GetLargestImages(Hashtable txtrs)
        {
            Hashtable list = new Hashtable();

            foreach (string s in txtrs.Keys)
            {
                Rcol      rcol = (Rcol)txtrs[s];
                ImageData id   = (ImageData)rcol.Blocks[0];

                id.GetReferencedLifos();
                System.Drawing.Image img = id.LargestTexture.Texture;                //null;

                /*foreach (MipMapBlock mmp in id.MipMapBlocks)
                 * {
                 *      foreach (MipMap mm in mmp.MipMaps)
                 *      {
                 *              if (mm.Texture!=null) img=mm.Texture;
                 *      }
                 * }*/


                if (img != null)
                {
                    //img.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    list.Add(s, ms);
                }
            }

            return(list);
        }
Exemplo n.º 2
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.º 3
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.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        public BoundingVolumeBuilder(Rcol parent) : base(parent)
        {
            gb      = new GeometryBuilder(null);
            BlockID = 0x1cfeceb8;

            u1 = new byte[5];
        }
Exemplo n.º 5
0
        /// <summary>
        /// Is called by SimPe (through the Wrapper) when the Panel is going to be displayed, so
        /// you should updatet the Data displayed by the Panel with the Attributes stored in the
        /// passed Wrapper.
        /// </summary>
        /// <param name="wrapper">The Attributes of this Wrapper have to be displayed</param>
        public void UpdateGUI(IFileWrapper wrapper)
        {
            Rcol wrp = (Rcol)wrapper;

            form.wrapper = wrp;

            form.cbitem.Items.Clear();
            foreach (IRcolBlock rb in wrp.Blocks)
            {
                SimPe.CountedListItem.AddHex(form.cbitem, rb);
            }
            if (form.cbitem.Items.Count > 0)
            {
                form.cbitem.SelectedIndex = 0;
            }
            else
            {
                form.BuildChildTabControl(null);
            }

            form.lbref.Items.Clear();
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in wrp.ReferencedFiles)
            {
                form.lbref.Items.Add(pfd);
            }
            if (form.lbref.Items.Count > 0)
            {
                form.lbref.SelectedIndex = 0;
            }

            form.tbResource.TabPages.Remove(form.tpref);
            form.tv.Nodes.Clear();
            if (typeof(IScenegraphItem) == wrp.GetType().GetInterface("IScenegraphItem"))
            {
                form.tbResource.TabPages.Add(form.tpref);
                System.Collections.Hashtable refmap = ((IScenegraphItem)wrp).ReferenceChains;
                foreach (string k in refmap.Keys)
                {
                    System.Collections.ArrayList l = (System.Collections.ArrayList)refmap[k];
                    TreeNode node = new TreeNode(k);

                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in l)
                    {
                        TreeNode child = new TreeNode(pfd.Filename + ": " + pfd.ToString());
                        child.Tag = pfd;
                        node.Nodes.Add(child);
                    }

                    form.tv.Nodes.Add(node);
                }
            }
            form.tbResource.SelectedIndex = 0;

            if (wrp.Blocks.Length > 0)
            {
                ((AbstractRcolBlock)wrp.Blocks[0]).AddToResourceTabControl(form.tbResource, form.cbitem);
            }

            form.Enabled = !wrp.Duff;
        }
Exemplo n.º 6
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.º 7
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.º 8
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TSFaceGeometryBuilder(Rcol parent) : base(parent)
        {
            gb      = new GeometryBuilder(null);
            BlockID = 0x2b70b86e;

            items = new TSFaceGeometryBuilderItems();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Returns the RCOL which lists this Resource in it's ReferencedFiles Attribute
        /// </summary>
        /// <returns>null or the RCOl Ressource</returns>
        Rcol FindReferencingCRES_Int()
        {
            //WaitingScreen.UpdateMessage("Loading Geometry Node");
            Wait.Message = "Loading Geometry Node";
            Rcol step = FindReferencingParent_NoLoad(Data.MetaData.GMND);

            if (step == null)
            {
                return(null);
            }


            //WaitingScreen.UpdateMessage("Loading Shape");
            Wait.Message = "Loading Shape";
            step         = ((GeometryNode)step.Blocks[0]).FindReferencingSHPE_NoLoad();
            if (step == null)
            {
                return(null);
            }

            //WaitingScreen.UpdateMessage("Loading ResourceNode");
            Wait.Message = "Loading ResourceNode";
            step         = ((AbstractRcolBlock)step.Blocks[0]).FindReferencingParent_NoLoad(Data.MetaData.CRES);
            if (step == null)
            {
                return(null);
            }

            return(step);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a new Instance
        /// </summary>
        public static IRcolBlock Create(Type type, Rcol parent, uint id)
        {
            IRcolBlock irb = Create(type, parent);

            irb.BlockID = id;
            return(irb);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ProcessDeformationsBuilder(Rcol parent) : base(parent)
        {
            gb      = new GeometryBuilder(null);
            BlockID = 0x5ce7e026;

            pfd = new SimPe.Packages.PackedFileDescriptor();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Fix a Txtr Reference in the Properties of a TXMT File
        /// </summary>
        /// <param name="name"></param>
        /// <param name="matd"></param>
        void FixTxtrRef(string propname, MaterialDefinition matd, Hashtable map, Rcol rcol)
        {
            string reference = matd.GetProperty(propname).Value.Trim().ToLower();
            string newref    = (string)map[Hashes.StripHashFromName(reference) + "_txtr"];

            if (newref != null)
            {
                newref = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + Hashes.StripHashFromName(newref);
                matd.GetProperty(propname).Value = newref.Substring(0, newref.Length - 5);
            }

            for (int i = 0; i < matd.Listing.Length; i++)
            {
                newref = (string)map[Hashes.StripHashFromName(matd.Listing[i].Trim().ToLower()) + "_txtr"];
                if (newref != null)
                {
                    matd.Listing[i] = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + Hashes.StripHashFromName(newref.Substring(0, newref.Length - 5));
                }
            }

            string name = Hashes.StripHashFromName(rcol.FileName);

            if (name.Length > 5)
            {
                name = name.Substring(0, name.Length - 5);
            }
            matd.FileDescription = name;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LightT(Rcol parent) : base(parent)
        {
            version = 11;
            BlockID = 0;

            sgres = new SGResource(null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor
        /// </summary>
        public IndexedMeshBuilder(Rcol parent) : base(parent)
        {
            gb      = new GeometryBuilder(null);
            BlockID = 0x9bffc10d;

            v1 = new Vectors3f();
            v2 = new Vectors3f();
            v3 = new Vectors2f();
            v4 = new Vectors2f();
            v5 = new Vectors2f();
            v6 = new Vectors2f();

            ia1 = new IntArrayList();
            ia2 = new IntArrayList();
            ia3 = new IntArrayList();
            ia4 = new IntArrayList();

            mbi = new IndexedMeshBuilderItems();

            zero1 = new byte[0x14];
            zero2 = new byte[0x14];

            u2 = new float[0x200];
            s1 = "face";
        }
Exemplo n.º 15
0
        /// <summary>
        /// Collec all Material
        /// </summary>
        /// <param name="gmdc">The GMDC File you want to find the Textures for</param>
        /// <returns>The Keys of the Hashtabel are the Subset names and the Values are the TXTR Files</returns>
        public Hashtable FindMaterials(Rcol gmdc)
        {
            Rcol      gmnd  = this.FindReferencingGMND(gmdc, null);
            Rcol      shpe  = this.FindReferencingSHPE(gmnd, null);
            Hashtable txmts = this.FindReferencedTXMT(shpe, null);

            return(txmts);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 public TagExtension(Rcol parent) : base(parent)
 {
     en      = "cExtension";
     eid     = 0;
     ever    = 3;
     BlockID = 0x9a809646;
     s1      = "";
 }
Exemplo n.º 17
0
        //int unknown1;
        //int unknown2;
        #endregion


        /// <summary>
        /// Constructor
        /// </summary>
        public Extension(Rcol parent) : base(parent)
        {
            items    = new ExtensionItem[0];
            version  = 0x03;
            typecode = 0x07;
            data     = new byte[0];
            varname  = "";
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates a new Instance
        /// </summary>
        public static IRcolBlock Create(Type type, Rcol parent)
        {
            object[] args = new object[1];
            args[0] = parent;
            IRcolBlock irb = (IRcolBlock)Activator.CreateInstance(type, args);

            return(irb);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CinematicScene(Rcol parent) : base(parent)
        {
            sgres = new SGResource(null);
            desc  = "";

            items   = new CinematicSceneItem[0];
            BlockID = 0x4D51F042;
        }
Exemplo n.º 20
0
        //Rcol parent;

        /*public Rcol Parent
         * {
         *      get { return parent; }
         * }*/

        /// <summary>
        /// Constructor
        /// </summary>
        public LevelInfo(Rcol parent) : base(parent)
        {
            texturesize = new Size(0, 0);
            zlevel      = 0;
            sgres       = new SGResource(null);
            BlockID     = 0xED534136;
            data        = new byte[0];
            datatype    = MipMapType.SimPE_PlainData;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MaterialDefinition(Rcol parent) : base(parent)
 {
     properties = new MaterialDefinitionProperty[0];
     listing    = new String[0];
     sgres      = new SGResource(null);
     BlockID    = 0x49596978;
     fldsc      = "";
     mattype    = "";
 }
Exemplo n.º 22
0
        /// <summary>
        /// Collec all Textures
        /// </summary>
        /// <param name="gmdc">The GMDC File you want to find the Textures for</param>
        /// <returns>The Keys of the Hashtabel are the Subset names and the Values are the TXTR Files</returns>
        public Hashtable FindTextures(Rcol gmdc)
        {
            Rcol      gmnd  = this.FindReferencingGMND(gmdc, null);
            Rcol      shpe  = this.FindReferencingSHPE(gmnd, null);
            Hashtable txmts = this.FindReferencedTXMT(shpe, null);
            Hashtable txtrs = this.FindReferencedTXTR(txmts, null);

            return(txtrs);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Constructor
        /// </summary>
        public GeometryNode(Rcol parent) : base(parent)
        {
            ogn        = new ObjectGraphNode(null);
            this.sgres = new SGResource(null);

            version = 0x0c;
            BlockID = 0x7BA3838C;

            data = new IRcolBlock[0];
        }
Exemplo n.º 24
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ResourceNode(Rcol parent) : base(parent)
        {
            sgres = new SGResource(null);
            ogn   = new ObjectGraphNode(null);
            ctn   = new CompositionTreeNode(null);
            items = new ResourceNodeItem[0];

            version  = 0x07;
            typecode = 0x01;
            BlockID  = 0xE519C933;
        }
Exemplo n.º 25
0
 public AbstractRcolBlock(Rcol parent)
 {
     this.parent = (Rcol)parent;
     if (parent != null)
     {
         this.Register(Rcol.Tokens);
     }
     sgres   = null;
     blockid = 0;
     version = 0;
 }
Exemplo n.º 26
0
        /*public Rcol Parent
         * {
         *      get { return parent; }
         * }*/

        /// <summary>
        /// Constructor
        /// </summary>
        public Shape(Rcol parent) : base(parent)
        {
            sgres   = new SGResource(null);
            refnode = new ReferentNode(null);
            ogn     = new ObjectGraphNode(null);

            unknown = new uint[0];
            items   = new ShapeItem[0];
            parts   = new ShapePart[0];
            BlockID = 0xFC6EB1F7;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LightRefNode(Rcol parent) : base(parent)
        {
            version = 0xa;
            BlockID = 0x253d2018;

            rn = new RenderableNode(null);
            bn = new BoundedNode(null);
            tn = new TransformNode(null);

            items    = new string[0];
            unknown2 = new byte[13];
        }
Exemplo n.º 28
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ImageData(Rcol parent) : base(parent)
 {
     texturesize     = new Size(1, 1);
     mipmapblocks    = new MipMapBlock[1];
     mipmapblocks[0] = new MipMapBlock(this);
     mipmaplevels    = 1;
     sgres           = new SGResource(null);
     BlockID         = 0x1c4a276c;
     filenamerep     = "";
     this.version    = 0x09;
     unknown_0       = (float)1.0;
     format          = SimPe.Plugin.ImageLoader.TxtrFormats.ExtRaw24Bit;
 }
Exemplo n.º 29
0
        /// <summary>
        /// Constructor
        /// </summary>
        public DirectionalLight(Rcol parent) : base(parent)
        {
            version = 1;
            BlockID = 0xC9C81BA3;

            slb   = new StandardLightBase(null);
            sgres = new SGResource(null);
            lt    = new LightT(null);
            rn    = new ReferentNode(null);
            ogn   = new ObjectGraphNode(null);

            unknown2 = "";
        }
Exemplo n.º 30
0
        public Hashtable GetMaterials(Hashtable txmts, Ambertation.Scenes.Scene scn)
        {
            Hashtable list = new Hashtable();

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

                list[s] = md.ToSceneMaterial(scn, Hashes.StripHashFromName(rcol.FileName));
            }
            return(list);
        }