Ejemplo n.º 1
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            // read structure data
            this.Unknown_10h       = reader.ReadUInt32();
            this.Unknown_14h       = reader.ReadUInt32();
            this.Unknown_18h       = reader.ReadUInt32();
            this.Unknown_1Ch       = reader.ReadUInt32();
            this.TextureNameHashes = reader.ReadBlock <ResourceSimpleList64_uint>();
            this.Textures          = reader.ReadBlock <ResourcePointerList64 <Texture> >();

            var dict = new Dictionary <uint, Texture>();

            if ((Textures?.data_items != null) && (TextureNameHashes?.data_items != null))
            {
                for (int i = 0; (i < Textures.data_items.Length) && (i < TextureNameHashes.data_items.Length); i++)
                {
                    var tex  = Textures.data_items[i];
                    var hash = TextureNameHashes.data_items[i];
                    dict[hash] = tex;
                }
            }
            Dict = dict;// new Dictionary<uint, Texture>(dict);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT         = reader.ReadUInt32();
            this.Unknown_4h  = reader.ReadUInt32();
            this.Unknown_8h  = reader.ReadUInt32();
            this.Unknown_Ch  = reader.ReadUInt32();
            this.Unknown_10h = reader.ReadUInt32();
            this.Unknown_14h = reader.ReadUInt32();
            this.Unknown_18h = reader.ReadUInt32();
            this.Unknown_1Ch = reader.ReadUInt32();
            this.Unknown_20h = reader.ReadBlock <ResourcePointerList64 <ExpressionUnk1> >();
            this.Unknown_30h = reader.ReadBlock <ResourceSimpleList64_uint>();
            this.Unknown_40h = reader.ReadBlock <ResourceSimpleList64 <ExpressionUnk2> >();
            this.Unknown_50h = reader.ReadBlock <ResourceSimpleList64_uint>();
            this.NamePointer = reader.ReadUInt64();
            this.Unknown_68h = reader.ReadUInt32();
            this.Unknown_6Ch = reader.ReadUInt32();
            this.Unknown_70h = reader.ReadUInt32();
            this.Unknown_74h = reader.ReadUInt32();
            this.len         = reader.ReadUInt16();
            this.Unknown_7Ah = reader.ReadUInt16();
            this.Unknown_7Ch = reader.ReadUInt32();
            this.Unknown_80h = reader.ReadUInt32();
            this.Unknown_84h = reader.ReadUInt32();
            this.Unknown_88h = reader.ReadUInt32();
            this.Unknown_8Ch = reader.ReadUInt32();

            // read reference data
            this.Name = reader.ReadBlockAt <string_r>(
                this.NamePointer // offset
                );
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the data block.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            int numElements1 = Convert.ToInt32(parameters[0]);
            int numElements2 = Convert.ToInt32(parameters[1]);

            Array1 = reader.ReadBlock <ResourceSimpleArray <T> >(numElements1);
            Array2 = reader.ReadBlock <ResourceSimpleArray <U> >(numElements2);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            // read structure data
            this.Unknown_10h          = reader.ReadUInt32();
            this.Unknown_14h          = reader.ReadUInt32();
            this.Unknown_18h          = reader.ReadUInt32();
            this.Unknown_1Ch          = reader.ReadUInt32();
            this.ExpressionNameHashes = reader.ReadBlock <ResourceSimpleList64_uint>();
            this.Expressions          = reader.ReadBlock <ResourcePointerList64 <Expression> >();
        }
Ejemplo n.º 5
0
        }                                     // 0x00000000

        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT         = reader.ReadUInt32();
            this.Unknown_4h  = reader.ReadUInt32();
            this.Unknown_8h  = reader.ReadUInt32();
            this.Unknown_Ch  = reader.ReadUInt32();
            this.Unknown_10h = reader.ReadUInt32();
            this.Unknown_14h = reader.ReadUInt32();
            this.Unknown_18h = reader.ReadBlock <ResourceSimpleList64_ulong>();
            this.Unknown_28h = reader.ReadBlock <ResourceSimpleList64_uint>();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();
        }
Ejemplo n.º 6
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Fragment = rd.ReadBlock <FragType>();

            if (Fragment.Drawable != null)
            {
                Fragment.Drawable.Owner = this;
            }
            if (Fragment.Drawable2 != null)
            {
                Fragment.Drawable2.Owner = this;
            }

            Loaded = true;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.EntriesPointer  = reader.ReadUInt64();
            this.EntriesCount    = reader.ReadUInt16();
            this.EntriesCapacity = reader.ReadUInt16();
            reader.Position     += 4;

            // read reference data
            //this.Entries = reader.ReadBlockAt<ResourceSimpleArray<T>>(
            //    this.EntriesPointer, // offset
            //    this.EntriesCount
            //);

            //TODO: NEEDS TO BE TESTED!!!
            data_items = new T[EntriesCount];
            var posbckp = reader.Position;

            reader.Position = (long)EntriesPointer;
            for (int i = 0; i < EntriesCount; i++)
            {
                data_items[i] = reader.ReadBlock <T>();
            }
            reader.Position = posbckp;
        }
Ejemplo n.º 8
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;
            //Hash = entry.ShortNameHash;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = null;

            try
            {
                rd = new ResourceDataReader(resentry, data);
            }
            catch (Exception ex)
            {
                //data = entry.File.DecompressBytes(data); //??
                LoadException = ex.ToString();
            }

            FrameFilterDictionary = rd?.ReadBlock <FrameFilterDictionary>();
        }
Ejemplo n.º 9
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            //MemoryUsage = 0;

            try
            {
                PtfxList = rd.ReadBlock <ParticleEffectsList>();
                //Drawable.Owner = this;
                //MemoryUsage += Drawable.MemoryUsage; //uses decompressed filesize now...
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
            }


            BuildDrawableDict();
            BuildParticleDict();

            Loaded = true;
        }
Ejemplo n.º 10
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            RpfFileEntry = entry;
            Name         = entry.Name;
            FilePath     = Name;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                NonMetaLoad(data);
                Loaded = true;
                return;
            }


            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Meta = rd.ReadBlock <Meta>();


            LoadMeta();



            Loaded = true;
        }
Ejemplo n.º 11
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            //MemoryUsage = 0;

            try
            {
                Waypoints = rd.ReadBlock <WaypointRecordList>();
            }
            catch (Exception ex)
            {
                string err = ex.ToString();
            }



            Loaded = true;
        }
Ejemplo n.º 12
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            //MemoryUsage = 0;

            try
            {
                Drawable       = rd.ReadBlock <Drawable>();
                Drawable.Owner = this;
                //MemoryUsage += Drawable.MemoryUsage; //uses decompressed filesize now...
            }
            catch (Exception ex)
            {
                string err = ex.ToString();
            }

            Loaded = true;
        }
Ejemplo n.º 13
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            Bounds = rd.ReadBlock <Bounds>();

            Bounds.OwnerYbn  = this;
            Bounds.OwnerName = entry.Name;

#if DEBUG
            Analyzer = new ResourceAnalyzer(rd);
#endif

            Loaded = true;
        }
Ejemplo n.º 14
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            //Name = entry.Name;
            //Hash = entry.ShortNameHash;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            ClipDictionary = rd.ReadBlock <ClipDictionary>();

            ClipMap = new Dictionary <MetaHash, ClipMapEntry>();
            if ((ClipDictionary != null) && (ClipDictionary.Clips != null) && (ClipDictionary.Clips.data_items != null))
            {
                foreach (var cme in ClipDictionary.Clips.data_items)
                {
                    if (cme != null)
                    {
                        ClipMap[cme.Hash] = cme;
                    }
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Reads the data block.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            int numElements = Convert.ToInt32(parameters[0]);

            Data = new List <T>(numElements);
            for (int i = 0; i < numElements; i++)
            {
                T item = reader.ReadBlock <T>();
                Data.Add(item);
            }
        }
Ejemplo n.º 16
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;
            //Hash = entry.ShortNameHash;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = null;

            try
            {
                rd = new ResourceDataReader(resentry, data);
            }
            catch (Exception ex)
            {
                //data = entry.File.DecompressBytes(data); //??
                LoadException = ex.ToString();
            }

            ClothDictionary = rd?.ReadBlock <ClothDictionary>();


            if (ClothDictionary != null)
            {
                Dict = new Dictionary <uint, CharacterCloth>();
                int n = ClothDictionary.ClothNameHashes?.data_items?.Length ?? 0;
                for (int i = 0; i < n; i++)
                {
                    if (i >= (ClothDictionary.Clothes?.data_items?.Length ?? 0))
                    {
                        break;
                    }

                    var hash  = ClothDictionary.ClothNameHashes.data_items[i];
                    var cloth = ClothDictionary.Clothes.data_items[i];

                    Dict[hash] = cloth;
                }
            }

            Loaded = true;
        }
Ejemplo n.º 17
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            FileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                MemoryStream ms = new MemoryStream(data);
                if (RbfFile.IsRBF(ms))
                {
                    Rbf = new RbfFile();
                    Rbf.Load(ms);

                    //x64j.rpf\\levels\\gta5\\_citye\\indust_01\\id1_props.rpf\\_manifest.ymf
                    //x64j.rpf\\levels\\gta5\\_citye\\indust_02\\id2_props.rpf\\_manifest.ymf
                    //x64q.rpf\\levels\\gta5\\_hills\\country_01\\cs1_railwyc.rpf\\_manifest.ymf
                    //all just HDTxd bindings

                    return;
                }
                if (PsoFile.IsPSO(ms))
                {
                    Pso = new PsoFile();
                    Pso.Load(ms);

                    //PsoTypes.EnsurePsoTypes(Pso);

                    ProcessPSO();

                    return;
                }
                else
                {
                }
                return;
            }
            else
            {
            }  //doesn't get here



            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Meta = rd.ReadBlock <Meta>();
        }
Ejemplo n.º 18
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name = entry.Name;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            TextureDict = rd.ReadBlock<TextureDictionary>();

            //MemoryUsage = 0; //uses decompressed file size now..
            //if (TextureDict != null)
            //{
            //    MemoryUsage += TextureDict.MemoryUsage;
            //}
        }
Ejemplo n.º 19
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            NodeDictionary = rd.ReadBlock <NodeDictionary>();

            InitNodesFromDictionary();

            UpdateAllNodePositions();

            //links will be populated by the space... maybe move that code here?



            string areaidstr = Name.ToLowerInvariant().Replace("nodes", "").Replace(".ynd", "");
            int    areaid    = 0;

            int.TryParse(areaidstr, out areaid);
            AreaID = areaid;

            UpdateBoundingBox();


            BuildBVH();


            Loaded     = true;
            LoadQueued = true;
        }
Ejemplo n.º 20
0
        public AwcAudioAnimClipDict(DataReader r, AwcChunkInfo info)
        {
            Data = r.ReadBytes(info.Size);

            if ((Data == null) || (Data.Length < 16))
            {
                return;
            }

            var data = Data;

            RpfResourceFileEntry resentry = new RpfResourceFileEntry();
            uint rsc7    = BitConverter.ToUInt32(data, 0);
            int  version = BitConverter.ToInt32(data, 4);

            resentry.SystemFlags   = BitConverter.ToUInt32(data, 8);
            resentry.GraphicsFlags = BitConverter.ToUInt32(data, 12);

            if (rsc7 != 0x37435352)
            {
            }                  //testing..
            if (version != 46) //46 is Clip Dictionary...
            {
            }

            int newlen = data.Length - 16;                                              //trim the header from the data passed to the next step.
            int arrlen = Math.Max(newlen, resentry.SystemSize + resentry.GraphicsSize); //expand it as necessary for the reader.

            byte[] newdata = new byte[arrlen];
            Buffer.BlockCopy(data, 16, newdata, 0, newlen);
            data = newdata;

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            ClipDict = rd.ReadBlock <ClipDictionary>();
        }
Ejemplo n.º 21
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            DrawableDict = rd.ReadBlock <DrawableDictionary>();

            //MemoryUsage = 0; //uses decompressed filesize now...
            //if (DrawableDict != null)
            //{
            //    MemoryUsage += DrawableDict.MemoryUsage;
            //}

            if ((DrawableDict != null) &&
                (DrawableDict.Drawables != null) &&
                (DrawableDict.Drawables.data_items != null) &&
                (DrawableDict.Hashes != null))
            {
                Dict = new Dictionary <uint, Drawable>();
                var drawables = DrawableDict.Drawables.data_items;
                var hashes    = DrawableDict.Hashes;
                for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
                {
                    var drawable = drawables[i];
                    var hash     = hashes[i];
                    Dict[hash]     = drawable;
                    drawable.Owner = this;
                }


                for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
                {
                    var drawable = drawables[i];
                    var hash     = hashes[i];
                    if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd")))
                    {
                        string hstr = JenkIndex.TryGetString(hash);
                        if (!string.IsNullOrEmpty(hstr))
                        {
                            drawable.Name = hstr;
                        }
                        else
                        {
                        }
                    }
                }

                Drawables = Dict.Values.ToArray();
            }

            Loaded = true;
        }
Ejemplo n.º 22
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            this.Entries = reader.ReadBlock <ResourceSimpleList64 <VehicleRecordEntry> >();
        }
Ejemplo n.º 23
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;
            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                MemoryStream ms = new MemoryStream(data);
                if (RbfFile.IsRBF(ms))
                {
                    Rbf = new RbfFile();
                    Rbf.Load(ms);
                }
                else if (PsoFile.IsPSO(ms))
                {
                    Pso = new PsoFile();
                    Pso.Load(ms);
                    //PsoTypes.EnsurePsoTypes(Pso);
                }
                else
                {
                }
                return;
            }



            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Meta = rd.ReadBlock <Meta>();


            _CMapTypes = MetaTypes.GetTypedData <CMapTypes>(Meta, MetaName.CMapTypes);


            List <Archetype> allarchs = new List <Archetype>();

            var ptrs = MetaTypes.GetPointerArray(Meta, _CMapTypes.archetypes);

            if (ptrs != null)
            {
                for (int i = 0; i < ptrs.Length; i++)
                {
                    var ptr    = ptrs[i];
                    var offset = ptr.Offset;
                    var block  = Meta.GetBlock(ptr.BlockID);
                    if (block == null)
                    {
                        continue;
                    }
                    if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length))
                    {
                        continue;
                    }

                    Archetype a = null;
                    switch (block.StructureNameHash)
                    {
                    case MetaName.CBaseArchetypeDef:
                        var basearch = PsoTypes.ConvertDataRaw <CBaseArchetypeDef>(block.Data, offset);
                        a = new Archetype();
                        a.Init(this, ref basearch);
                        a.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
                        break;

                    case MetaName.CTimeArchetypeDef:
                        var timearch = PsoTypes.ConvertDataRaw <CTimeArchetypeDef>(block.Data, offset);
                        var ta       = new TimeArchetype();
                        ta.Init(this, ref timearch);
                        ta.Extensions = MetaTypes.GetExtensions(Meta, timearch._BaseArchetypeDef.extensions);
                        a             = ta;
                        break;

                    case MetaName.CMloArchetypeDef:
                        var mloarch = PsoTypes.ConvertDataRaw <CMloArchetypeDef>(block.Data, offset);
                        var ma      = new MloArchetype();
                        ma.Init(this, ref mloarch);
                        ma.Extensions = MetaTypes.GetExtensions(Meta, mloarch._BaseArchetypeDef.extensions);

                        ma.LoadChildren(Meta);

                        a = ma;
                        break;

                    default:
                        continue;
                    }

                    if (a != null)
                    {
                        allarchs.Add(a);
                    }
                }
            }
            AllArchetypes = allarchs.ToArray();


            Extensions = MetaTypes.GetExtensions(Meta, _CMapTypes.extensions);

            if (Extensions != null)
            {
            }


            //AudioEmitters = MetaTypes.GetTypedDataArray<CExtensionDefAudioEmitter>(Meta, MetaName.CExtensionDefAudioEmitter);
            //if (AudioEmitters != null)
            //{ }

            //CEntityDefs = MetaTypes.GetTypedDataArray<CEntityDef>(Meta, MetaName.CEntityDef);


            CompositeEntityTypes = MetaTypes.ConvertDataArray <CCompositeEntityType>(Meta, MetaName.CCompositeEntityType, _CMapTypes.compositeEntityTypes);
            if (CompositeEntityTypes != null)
            {
            }

            NameHash = _CMapTypes.name;
            if (NameHash == 0)
            {
                int ind = entry.NameLower.LastIndexOf('.');
                if (ind > 0)
                {
                    NameHash = JenkHash.GenHash(entry.NameLower.Substring(0, ind));
                }
                else
                {
                    NameHash = JenkHash.GenHash(entry.NameLower);
                }
            }

            Strings = MetaTypes.GetStrings(Meta);
            if (Strings != null)
            {
                foreach (string str in Strings)
                {
                    JenkIndex.Ensure(str); //just shove them in there
                }
            }


            //foreach (var block in Meta.DataBlocks)
            //{
            //    switch(block.StructureNameHash)
            //    {
            //        case MetaName.CMapTypes:
            //        case MetaName.CTimeArchetypeDef:
            //        case MetaName.CBaseArchetypeDef:
            //        case MetaName.CMloArchetypeDef:
            //        case MetaName.CMloTimeCycleModifier:
            //        case MetaName.CMloRoomDef:
            //        case MetaName.CMloPortalDef:
            //        case MetaName.CMloEntitySet:
            //        case MetaName.CEntityDef:
            //        case MetaName.CExtensionDefParticleEffect:
            //        case MetaName.CExtensionDefAudioCollisionSettings:
            //        case MetaName.CExtensionDefSpawnPoint:
            //        case MetaName.CExtensionDefSpawnPointOverride:
            //        case MetaName.CExtensionDefExplosionEffect:
            //        case MetaName.CExtensionDefAudioEmitter:
            //        case MetaName.CExtensionDefLadder:
            //        case MetaName.CExtensionDefBuoyancy:
            //        case MetaName.CExtensionDefExpression:
            //        case MetaName.CExtensionDefLightShaft:
            //        case MetaName.CExtensionDefLightEffect:
            //        case MetaName.CExtensionDefDoor:
            //        case MetaName.CExtensionDefWindDisturbance:
            //        case MetaName.CExtensionDefProcObject:
            //        case MetaName.CLightAttrDef:
            //        case (MetaName)MetaTypeName.STRING:
            //        case (MetaName)MetaTypeName.POINTER:
            //        case (MetaName)MetaTypeName.UINT:
            //        case (MetaName)MetaTypeName.VECTOR4:
            //            break;
            //        default:
            //            break;
            //    }
            //}



            //MetaTypes.ParseMetaData(Meta);
        }
Ejemplo n.º 24
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            //MemoryUsage = 0;

            try
            {
                PtfxList = rd.ReadBlock <ParticleEffectsList>();
                //Drawable.Owner = this;
                //MemoryUsage += Drawable.MemoryUsage; //uses decompressed filesize now...
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
            }


            var dDict = PtfxList?.DrawableDictionary;

            if ((dDict != null) &&
                (dDict.Drawables != null) &&
                (dDict.Drawables.data_items != null) &&
                (dDict.Hashes != null))
            {
                DrawableDict = new Dictionary <uint, Drawable>();
                var drawables = dDict.Drawables.data_items;
                var hashes    = dDict.Hashes;
                for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
                {
                    var drawable = drawables[i];
                    var hash     = hashes[i];
                    DrawableDict[hash] = drawable;
                    drawable.Owner     = this;
                }

                for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
                {
                    var drawable = drawables[i];
                    var hash     = hashes[i];
                    if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd")))
                    {
                        string hstr = JenkIndex.TryGetString(hash);
                        if (!string.IsNullOrEmpty(hstr))
                        {
                            drawable.Name = hstr;
                        }
                        else
                        {
                            drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0');
                        }
                    }
                }
            }



            Loaded = true;
        }
Ejemplo n.º 25
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            Nav = rd.ReadBlock <NavMesh>();


            if (Nav != null)
            {
                Vector3 posoffset = Nav.SectorTree?.AABBMin.XYZ() ?? Vector3.Zero;
                Vector3 aabbsize  = Nav.AABBSize;

                if (Nav.Vertices != null)
                {
                    var verts = Nav.Vertices.GetFullList();
                    Vertices = new List <Vector3>(verts.Count);
                    for (int i = 0; i < verts.Count; i++)
                    {
                        var ov = verts[i].ToVector3();
                        Vertices.Add(posoffset + ov * aabbsize);
                    }
                }
                if (Nav.Indices != null)
                {
                    Indices = Nav.Indices.GetFullList();
                }
                if (Nav.AdjPolys != null)
                {
                    AdjPolys = Nav.AdjPolys.GetFullList();
                }
                if (Nav.Polys != null)
                {
                    var polys = Nav.Polys.GetFullList();
                    Polys = new List <YnvPoly>(polys.Count);
                    for (int i = 0; i < polys.Count; i++)
                    {
                        YnvPoly poly = new YnvPoly();
                        poly.Init(this, polys[i]);
                        poly.Index = i;
                        poly.CalculatePosition(); //calc poly center for display purposes..
                        Polys.Add(poly);

                        if (poly.PortalType > 0)
                        {
                            if (poly.PortalType != 2) //seems to be what portal links need to understand..
                            {
                            }
                        }
                    }
                }
                if (Nav.Portals != null)
                {
                    var portals = Nav.Portals;
                    Portals = new List <YnvPortal>(portals.Length);
                    for (int i = 0; i < portals.Length; i++)
                    {
                        YnvPortal portal = new YnvPortal();
                        portal.Init(this, portals[i]);
                        portal.Index        = i;
                        portal.PositionFrom = posoffset + portal._RawData.PositionFrom.ToVector3() * aabbsize;
                        portal.PositionTo   = posoffset + portal._RawData.PositionTo.ToVector3() * aabbsize;
                        Portals.Add(portal);
                    }
                }


                ////### add points to the list and calculate positions...
                var treestack = new Stack <NavMeshSector>();
                var pointi    = 0;
                if (Nav.SectorTree != null)
                {
                    treestack.Push(Nav.SectorTree);
                }
                while (treestack.Count > 0)
                {
                    var sector = treestack.Pop();
                    if (sector.Data != null)
                    {
                        var points = sector.Data.Points;
                        if (points != null)
                        {
                            if (Points == null)
                            {
                                Points = new List <YnvPoint>();
                            }
                            for (int i = 0; i < points.Length; i++)
                            {
                                YnvPoint point = new YnvPoint();
                                point.Init(this, points[i]);
                                point.Index    = pointi; pointi++;
                                point.Position = posoffset + point._RawData.Position * aabbsize;
                                Points.Add(point);
                            }
                        }
                    }
                    if (sector.SubTree1 != null)
                    {
                        treestack.Push(sector.SubTree1);
                    }
                    if (sector.SubTree2 != null)
                    {
                        treestack.Push(sector.SubTree2);
                    }
                    if (sector.SubTree3 != null)
                    {
                        treestack.Push(sector.SubTree3);
                    }
                    if (sector.SubTree4 != null)
                    {
                        treestack.Push(sector.SubTree4);
                    }
                }
            }



            UpdateAllNodePositions();

            UpdateTriangleVertices();

            BuildBVH();


            Loaded     = true;
            LoadQueued = true;
        }
Ejemplo n.º 26
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            NodeDictionary = rd.ReadBlock <NodeDictionary>();

            if (NodeDictionary != null)
            {
                if (NodeDictionary.Nodes != null)
                {
                    var nodes = NodeDictionary.Nodes;
                    Nodes = new YndNode[nodes.Length];
                    for (int i = 0; i < nodes.Length; i++)
                    {
                        var n = new YndNode();
                        n.Init(this, nodes[i]);
                        Nodes[i] = n;
                        if (n.NodeID != i)
                        {
                        }   //never hit here - nodeid's have to match the index!
                    }
                }
                if ((NodeDictionary.JunctionRefs != null) && (NodeDictionary.Junctions != null))
                {
                    var juncrefs = NodeDictionary.JunctionRefs;
                    var juncs    = NodeDictionary.Junctions;
                    Junctions = new YndJunction[juncrefs.Length];
                    for (int i = 0; i < juncrefs.Length; i++)
                    {
                        var juncref = NodeDictionary.JunctionRefs[i];
                        if (juncref.JunctionID >= juncs.Length)
                        {
                            continue;
                        }

                        var j = new YndJunction();
                        j.Init(this, juncs[juncref.JunctionID], juncref);
                        j.Heightmap  = new YndJunctionHeightmap(NodeDictionary.JunctionHeightmapBytes, j);
                        Junctions[i] = j;
                    }
                }
            }

            UpdateAllNodePositions();

            //links will be populated by the space... maybe move that code here?



            string areaidstr = Name.ToLower().Replace("nodes", "").Replace(".ynd", "");
            int    areaid    = 0;

            int.TryParse(areaidstr, out areaid);
            AreaID = areaid;

            UpdateBoundingBox();


            BuildBVH();


            Loaded     = true;
            LoadQueued = true;
        }
Ejemplo n.º 27
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;
            //Hash = entry.ShortNameHash;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            ClipDictionary = rd.ReadBlock <ClipDictionary>();

            ClipMap = new Dictionary <MetaHash, ClipMapEntry>();
            AnimMap = new Dictionary <MetaHash, AnimationMapEntry>();
            if (ClipDictionary != null)
            {
                if ((ClipDictionary.Clips != null) && (ClipDictionary.Clips.data_items != null))
                {
                    foreach (var cme in ClipDictionary.Clips.data_items)
                    {
                        if (cme != null)
                        {
                            ClipMap[cme.Hash] = cme;
                            var nxt = cme.Next;
                            while (nxt != null)
                            {
                                ClipMap[nxt.Hash] = nxt;
                                nxt = nxt.Next;
                            }
                        }
                    }
                }
                if ((ClipDictionary.Animations != null) && (ClipDictionary.Animations.Animations != null) && (ClipDictionary.Animations.Animations.data_items != null))
                {
                    foreach (var ame in ClipDictionary.Animations.Animations.data_items)
                    {
                        if (ame != null)
                        {
                            AnimMap[ame.Hash] = ame;
                            var nxt = ame.NextEntry;
                            while (nxt != null)
                            {
                                AnimMap[nxt.Hash] = nxt;
                                nxt = nxt.NextEntry;
                            }
                        }
                    }
                }
            }

            foreach (var cme in ClipMap.Values)
            {
                var clip = cme.Clip;
                if (clip == null)
                {
                    continue;
                }
                clip.Ycd = this;
                if (string.IsNullOrEmpty(clip.Name))
                {
                    continue;
                }
                string name  = clip.Name.Replace('\\', '/');
                var    slidx = name.LastIndexOf('/');
                if ((slidx >= 0) && (slidx < name.Length - 1))
                {
                    name = name.Substring(slidx + 1);
                }
                var didx = name.LastIndexOf('.');
                if ((didx > 0) && (didx < name.Length))
                {
                    name = name.Substring(0, didx);
                }
                clip.ShortName = name;
                name           = name.ToLowerInvariant();
                JenkIndex.Ensure(name);


                //if (name.EndsWith("_uv_0")) //hash for these entries match string with this removed, +1
                //{
                //}
                //if (name.EndsWith("_uv_1")) //same as above, but +2
                //{
                //}
            }
            foreach (var ame in AnimMap.Values)
            {
                var anim = ame.Animation;
                if (anim == null)
                {
                    continue;
                }
                anim.Ycd = this;
            }


            ClipMapEntries = ClipMap.Values.ToArray();
            AnimMapEntries = AnimMap.Values.ToArray();
        }
Ejemplo n.º 28
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                NonMetaLoad(data);
                return;
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Meta = rd.ReadBlock <Meta>();



            CMapData = MetaTypes.GetTypedData <CMapData>(Meta, MetaName.CMapData);



            Strings = MetaTypes.GetStrings(Meta);
            if (Strings != null)
            {
                foreach (string str in Strings)
                {
                    JenkIndex.Ensure(str); //just shove them in there
                }
            }

            physicsDictionaries = MetaTypes.GetHashArray(Meta, CMapData.physicsDictionaries);


            EnsureEntities(Meta); //load all the entity data and create the YmapEntityDefs

            EnsureInstances(Meta);

            EnsureLodLights(Meta);

            EnsureDistantLODLights(Meta);

            EnsureTimeCycleModifiers(Meta);

            EnsureCarGens(Meta);

            EnsureBoxOccluders(Meta);

            EnsureOccludeModels(Meta);

            EnsureContainerLods(Meta);


            #region data block test and old code

            //foreach (var block in Meta.DataBlocks)
            //{
            //    switch (block.StructureNameHash)
            //    {
            //        case MetaName.STRING:
            //        case MetaName.POINTER:
            //        case MetaName.HASH:
            //        case MetaName.UINT:
            //        case MetaName.VECTOR3: //distant lod lights uses this
            //        case MetaName.CMapData:
            //        case MetaName.CEntityDef:
            //        case MetaName.CTimeCycleModifier: //these sections are handled already
            //        case MetaName.CCarGen:
            //        case MetaName.CLightAttrDef:
            //        case MetaName.CMloInstanceDef:
            //        case MetaName.CExtensionDefDoor:
            //        case MetaName.CExtensionDefLightEffect:
            //        case MetaName.CExtensionDefSpawnPointOverride:
            //        case MetaName.rage__fwGrassInstanceListDef: //grass instance buffer
            //        case MetaName.rage__fwGrassInstanceListDef__InstanceData: //grass instance buffer data
            //            break;
            //        case MetaName.PhVerletClothCustomBounds: //these sections still todo..
            //        case MetaName.SectionUNKNOWN1:
            //        case MetaName.SectionUNKNOWN5://occlusion vertex data container
            //        case MetaName.SectionUNKNOWN7://occlusion related?
            //            break;
            //        case (MetaName)17: //vertex data - occlusion related - SectionUNKNOWN5
            //            break;
            //        case (MetaName)33: //what is this? maybe lodlights related
            //            break;
            //        default:
            //            break;
            //    }
            //}



            //MetaTypes.ParseMetaData(Meta);

            //string shortname = resentry.Name.Substring(0, resentry.Name.LastIndexOf('.'));
            //uint namehash = JenkHash.GenHash(shortname);



            //CLightAttrDefs = MetaTypes.GetTypedDataArray<CLightAttrDef>(Meta, MetaName.CLightAttrDef);
            //if (CLightAttrDefs != null)
            //{ }


            //var unk5s = MetaTypes.GetTypedDataArray<SectionUNKNOWN5>(Meta, MetaName.SectionUNKNOWN5);
            //if (unk5s != null) //used in occlusion ymaps
            //{
            //    foreach (var unk5 in unk5s)
            //    {
            //        if ((unk5.verts.Ptr > 0) && (unk5.verts.Ptr <= (ulong)Meta.DataBlocks.Length))
            //        {
            //            var indicesoffset = unk5.Unk_853977995;
            //            var datablock = Meta.DataBlocks[((int)unk5.verts.Ptr) - 1];
            //            if (datablock != null)
            //            { }//vertex data... occlusion mesh?
            //        }
            //    }
            //}

            //var unk7s = MetaTypes.GetTypedDataArray<SectionUNKNOWN7>(Meta, MetaName.SectionUNKNOWN7);
            //if (unk7s != null)
            //{ } //used in occlusion ymaps

            //var unk10s = MetaTypes.GetTypedDataArray<SectionUNKNOWN10>(Meta, MetaName.SectionUNKNOWN10);
            //if (unk10s != null)
            //{ } //entity pointer array..

            //CDoors = MetaTypes.GetTypedDataArray<CExtensionDefDoor>(Meta, MetaName.CExtensionDefDoor);
            //if (CDoors != null)
            //{ } //needs work - doors can be different types? not enough bytes for one

            //CExtLightEffects = MetaTypes.GetTypedDataArray<CExtensionDefLightEffect>(Meta, MetaName.CExtensionDefLightEffect);
            //if (CExtLightEffects != null)
            //{ }

            //CSpawnOverrides = MetaTypes.GetTypedDataArray<CExtensionDefSpawnPointOverride>(Meta, MetaName.CExtensionDefSpawnPointOverride);
            //if (CSpawnOverrides != null)
            //{ }

            #endregion
        }
Ejemplo n.º 29
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            RpfFileEntry = entry;
            Name         = entry.Name;
            FilePath     = Name;


            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry != null)
            {
                ResourceDataReader rd = new ResourceDataReader(resentry, data);

                Meta = rd.ReadBlock <Meta>();

                var rootblock = Meta.GetRootBlock();
                if (rootblock != null)
                {
                    if (rootblock.StructureNameHash == MetaName.CScenarioPointRegion)
                    {
                        LoadScenarioPointRegion(Meta, rootblock);
                    }
                }

                Loaded = true;
                return;
            }


            MemoryStream ms = new MemoryStream(data);

            if (RbfFile.IsRBF(ms))
            {
                Rbf = new RbfFile();
                var rbfstruct = Rbf.Load(ms);

                if (rbfstruct.Name == "CMapParentTxds")
                {
                    LoadMapParentTxds(rbfstruct);
                }



                Loaded = true;
                return;
            }
            if (PsoFile.IsPSO(ms))
            {
                Pso = new PsoFile();
                Pso.Load(ms);

                //PsoTypes.EnsurePsoTypes(Pso);

                var root = PsoTypes.GetRootEntry(Pso);
                if (root != null)
                {
                    if (root.NameHash == MetaName.CScenarioPointManifest)
                    {
                        LoadScenarioPointManifest(Pso);
                    }
                }


                Loaded = true;
                return;
            }
            else
            {
            }
        }
Ejemplo n.º 30
0
        public void Load(byte[] data, RpfFileEntry entry)
        {
            Name         = entry.Name;
            RpfFileEntry = entry;

            RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;

            if (resentry == null)
            {
                throw new Exception("File entry wasn't a resource! (is it binary data?)");
            }

            ResourceDataReader rd = new ResourceDataReader(resentry, data);


            Nav = rd.ReadBlock <NavMesh>();


            if ((Nav != null) && (Nav.SectorTree != null))
            {
                if (Nav.Vertices != null)
                {
                    Vector3 posoffset = Nav.SectorTree.AABBMin.XYZ();
                    Vector3 aabbsize  = Nav.AABBSize;

                    var verts = Nav.Vertices.GetFullList();
                    Vertices = new List <Vector3>(verts.Count);
                    for (int i = 0; i < verts.Count; i++)
                    {
                        var ov = verts[i].ToVector3();
                        Vertices.Add(posoffset + ov * aabbsize);
                    }
                }
                if (Nav.Indices != null)
                {
                    Indices = Nav.Indices.GetFullList();
                }
                if (Nav.Polys != null)
                {
                    var polys = Nav.Polys.GetFullList();
                    Polys = new List <YnvPoly>(polys.Count);
                    for (int i = 0; i < polys.Count; i++)
                    {
                        YnvPoly poly = new YnvPoly();
                        poly.Init(this, polys[i]);
                        poly.Index = i;
                        Polys.Add(poly);


                        //calc poly center.
                        if ((Indices == null) || (Vertices == null))
                        {
                            continue;
                        }
                        var vc      = Vertices.Count;
                        var ic      = poly._RawData.IndexCount;
                        var startid = poly._RawData.IndexID;
                        var endid   = startid + ic;
                        if (startid >= Indices.Count)
                        {
                            continue;
                        }
                        if (endid > Indices.Count)
                        {
                            continue;
                        }
                        Vector3 pcenter = Vector3.Zero;
                        float   pcount  = 0.0f;
                        for (int id = startid; id < endid; id++)
                        {
                            var ind = Indices[id];
                            if (ind >= vc)
                            {
                                continue;
                            }

                            pcenter += Vertices[ind];
                            pcount  += 1.0f;
                        }
                        poly.Position = pcenter * (1.0f / pcount);
                    }
                }
            }



            UpdateAllNodePositions();

            UpdateTriangleVertices();


            Loaded     = true;
            LoadQueued = true;
        }