예제 #1
0
파일: YmfFile.cs 프로젝트: rt-2/CodeWalker
        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;
            }



            ResourceDataReader rd = new ResourceDataReader(resentry, data);

            Meta = rd.ReadBlock <Meta>();
        }
예제 #2
0
 /// <summary>
 /// Reads the data-block from a stream.
 /// </summary>
 public override void Read(ResourceDataReader reader, params object[] parameters)
 {
     // read structure data
     this.Unknown_0h  = reader.ReadSingle();
     this.Unknown_4h  = reader.ReadSingle();
     this.Unknown_8h  = reader.ReadSingle();
     this.Unknown_Ch  = reader.ReadUInt32();
     this.Unknown_10h = reader.ReadSingle();
     this.Unknown_14h = reader.ReadSingle();
     this.Unknown_18h = reader.ReadSingle();
     this.Unknown_1Ch = reader.ReadUInt32();
     this.Unknown_20h = reader.ReadSingle();
     this.Unknown_24h = reader.ReadSingle();
     this.Unknown_28h = reader.ReadSingle();
     this.Unknown_2Ch = reader.ReadUInt32();
     this.Unknown_30h = reader.ReadSingle();
     this.Unknown_34h = reader.ReadSingle();
     this.Unknown_38h = reader.ReadSingle();
     this.Unknown_3Ch = reader.ReadUInt32();
     this.Unknown_40h = reader.ReadSingle();
     this.Unknown_44h = reader.ReadSingle();
     this.Unknown_48h = reader.ReadSingle();
     this.Unknown_4Ch = reader.ReadUInt32();
     this.Unknown_50h = reader.ReadSingle();
     this.Unknown_54h = reader.ReadSingle();
     this.Unknown_58h = reader.ReadSingle();
     this.Unknown_5Ch = reader.ReadUInt32();
     this.Unknown_60h = reader.ReadSingle();
     this.Unknown_64h = reader.ReadSingle();
     this.Unknown_68h = reader.ReadSingle();
     this.Unknown_6Ch = reader.ReadUInt32();
     this.Unknown_70h = reader.ReadSingle();
     this.Unknown_74h = reader.ReadSingle();
     this.Unknown_78h = reader.ReadSingle();
     this.Unknown_7Ch = reader.ReadUInt32();
     this.Unknown_80h = reader.ReadSingle();
     this.Unknown_84h = reader.ReadSingle();
     this.Unknown_88h = reader.ReadSingle();
     this.Unknown_8Ch = reader.ReadUInt32();
     this.Unknown_90h = reader.ReadSingle();
     this.Unknown_94h = reader.ReadSingle();
     this.Unknown_98h = reader.ReadSingle();
     this.Unknown_9Ch = reader.ReadUInt32();
 }
예제 #3
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            this.EntriesPointer  = reader.ReadUInt64();
            this.EntriesCount    = reader.ReadUInt16();
            this.EntriesCapacity = reader.ReadUInt16();
            reader.Position     += 4;

            //this.Entries = reader.ReadBlockAt<ResourcePointerArray64<T>>(
            //    this.EntriesPointer, // offset
            //    this.EntriesCount
            //);

            data_pointers = reader.ReadUlongsAt(EntriesPointer, EntriesCount);
            data_items    = new T[EntriesCount];
            for (int i = 0; i < EntriesCount; i++)
            {
                data_items[i] = reader.ReadBlockAt <T>(data_pointers[i]);
            }
        }
예제 #4
0
 public override void Read(ResourceDataReader reader, params object[] parameters)
 {
     // read structure data
     this.Time            = reader.ReadUInt32();
     this.VelocityX       = reader.ReadInt16();
     this.VelocityY       = reader.ReadInt16();
     this.VelocityZ       = reader.ReadInt16();
     this.RightX          = (sbyte)reader.ReadByte();
     this.RightY          = (sbyte)reader.ReadByte();
     this.RightZ          = (sbyte)reader.ReadByte();
     this.ForwardX        = (sbyte)reader.ReadByte();
     this.ForwardY        = (sbyte)reader.ReadByte();
     this.ForwardZ        = (sbyte)reader.ReadByte();
     this.SteeringAngle   = (sbyte)reader.ReadByte();
     this.GasPedalPower   = (sbyte)reader.ReadByte();
     this.BrakePedalPower = (sbyte)reader.ReadByte();
     this.HandbrakeUsed   = reader.ReadByte();
     this.Position        = reader.ReadVector3();
 }
예제 #5
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            uint format = Convert.ToUInt32(parameters[0]);
            int  Width  = Convert.ToInt32(parameters[1]);
            int  Height = Convert.ToInt32(parameters[2]);
            int  Levels = Convert.ToInt32(parameters[3]);
            int  Stride = Convert.ToInt32(parameters[4]);

            int fullLength = 0;
            int length     = Stride * Height;

            for (int i = 0; i < Levels; i++)
            {
                fullLength += length;
                length     /= 4;
            }

            FullData = reader.ReadBytes(fullLength);
        }
예제 #6
0
파일: YtdFile.cs 프로젝트: z87/CodeWalker
        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;
            //}
        }
예제 #7
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            AABBMin         = reader.ReadVector4();
            AABBMax         = reader.ReadVector4();
            CellAABB        = reader.ReadStruct <NavMeshAABB>();
            DataPointer     = reader.ReadUInt64();
            SubTree1Pointer = reader.ReadUInt64();
            SubTree2Pointer = reader.ReadUInt64();
            SubTree3Pointer = reader.ReadUInt64();
            SubTree4Pointer = reader.ReadUInt64();
            Unused_54h      = reader.ReadUInt32();
            Unused_58h      = reader.ReadUInt32();
            Unused_5Ch      = reader.ReadUInt32();

            Data     = reader.ReadBlockAt <NavMeshSectorData>(DataPointer);
            SubTree1 = reader.ReadBlockAt <NavMeshSector>(SubTree1Pointer);
            SubTree2 = reader.ReadBlockAt <NavMeshSector>(SubTree2Pointer);
            SubTree3 = reader.ReadBlockAt <NavMeshSector>(SubTree3Pointer);
            SubTree4 = reader.ReadBlockAt <NavMeshSector>(SubTree4Pointer);
        }
예제 #8
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;
        }
예제 #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);


            Bounds = rd.ReadBlock <Bounds>();

            Bounds.OwnerName = entry.Name;

            Loaded = true;
        }
예제 #10
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_40h = reader.ReadUInt32();
            this.Unknown_44h = reader.ReadUInt32();
            this.Unknown_48h = reader.ReadUInt32();
            this.Unknown_4Ch = reader.ReadUInt32();
            this.Width       = reader.ReadUInt16();
            this.Height      = reader.ReadUInt16();
            this.Unknown_54h = reader.ReadUInt16();
            this.Stride      = reader.ReadUInt16();
            this.Format      = (TextureFormat)reader.ReadUInt32();
            this.Unknown_5Ch = reader.ReadByte();
            this.Levels      = reader.ReadByte();
            this.Unknown_5Eh = reader.ReadUInt16();
            this.Unknown_60h = reader.ReadUInt32();
            this.Unknown_64h = reader.ReadUInt32();
            this.Unknown_68h = reader.ReadUInt32();
            this.Unknown_6Ch = reader.ReadUInt32();
            this.DataPointer = reader.ReadUInt64();
            this.Unknown_78h = reader.ReadUInt32();
            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.Data = reader.ReadBlockAt <TextureData>(
                this.DataPointer, // offset
                this.Format,
                this.Width,
                this.Height,
                this.Levels,
                this.Stride
                );
        }
예제 #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
            {
                PtfxList = rd.ReadBlock <ParticleEffectsList>();
                //Drawable.Owner = this;
                //MemoryUsage += Drawable.MemoryUsage; //uses decompressed filesize now...
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
            }


            BuildDrawableDict();
            BuildParticleDict();

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

            Loaded = true;
        }
예제 #12
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            int numElements = Convert.ToInt32(parameters[0]);

            // read structure data
            //data_pointers = new List<ulong>();
            //for (int i = 0; i < numElements; i++)
            //{
            //    data_pointers.Add(reader.ReadUInt64());
            //}

            data_pointers = reader.ReadUlongsAt((ulong)reader.Position, (uint)numElements);


            //foreach (var dp in data_pointers)
            //{
            //    if (dp == 0)
            //    {

            //    }
            //}

            // read reference data
            //data_items = new List<T>();
            //for (int i = 0; i < numElements; i++)
            //{
            //    data_items.Add(
            //        reader.ReadBlockAt<T>(data_pointers[i])
            //        );
            //}

            data_items = new T[numElements];
            for (int i = 0; i < numElements; i++)
            {
                data_items[i] = reader.ReadStructAt <T>((long)data_pointers[i]);
            }
        }
예제 #13
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>();
        }
예제 #14
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            this.Entries = reader.ReadBlock <ResourceSimpleList64 <VehicleRecordEntry> >();
        }
예제 #15
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;
        }
예제 #16
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);
        }
예제 #17
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;
        }
예제 #18
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;
        }
예제 #19
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();
        }
예제 #20
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            base.Read(reader, parameters);

            // read structure data
            this.UsageData   = reader.ReadUInt32();
            this.Unknown_44h = reader.ReadUInt32();
            this.ExtraFlags  = reader.ReadUInt32();
            this.Unknown_4Ch = reader.ReadUInt32();
            this.Width       = reader.ReadUInt16();
            this.Height      = reader.ReadUInt16();
            this.Depth       = reader.ReadUInt16();
            this.Stride      = reader.ReadUInt16();
            this.Format      = (TextureFormat)reader.ReadUInt32();
            this.Unknown_5Ch = reader.ReadByte();
            this.Levels      = reader.ReadByte();
            this.Unknown_5Eh = reader.ReadUInt16();
            this.Unknown_60h = reader.ReadUInt32();
            this.Unknown_64h = reader.ReadUInt32();
            this.Unknown_68h = reader.ReadUInt32();
            this.Unknown_6Ch = reader.ReadUInt32();
            this.DataPointer = reader.ReadUInt64();
            this.Unknown_78h = reader.ReadUInt32();
            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.Data = reader.ReadBlockAt <TextureData>(this.DataPointer, this.Format, this.Width, this.Height, this.Levels, this.Stride);


            switch (Usage)
            {
            case TextureUsage.UNKNOWN:            // = 0,
            case TextureUsage.DEFAULT:            // = 1,
            case TextureUsage.TERRAIN:            // = 2,
            case TextureUsage.CLOUDDENSITY:       // = 3,
            case TextureUsage.CLOUDNORMAL:        // = 4,
            case TextureUsage.CABLE:              // = 5,
            case TextureUsage.FENCE:              // = 6,
            case TextureUsage.SCRIPT:             // = 8,
            case TextureUsage.WATERFLOW:          // = 9,
            case TextureUsage.WATERFOAM:          // = 10,
            case TextureUsage.WATERFOG:           // = 11,
            case TextureUsage.WATEROCEAN:         // = 12,
            case TextureUsage.FOAMOPACITY:        // = 14,
            case TextureUsage.DIFFUSEMIPSHARPEN:  // = 16,
            case TextureUsage.DIFFUSEDARK:        // = 18,
            case TextureUsage.DIFFUSEALPHAOPAQUE: // = 19,
            case TextureUsage.DIFFUSE:            // = 20,
            case TextureUsage.DETAIL:             // = 21,
            case TextureUsage.NORMAL:             // = 22,
            case TextureUsage.SPECULAR:           // = 23,
            case TextureUsage.EMISSIVE:           // = 24,
            case TextureUsage.TINTPALETTE:        // = 25,
            case TextureUsage.SKIPPROCESSING:     // = 26,
                break;

            case TextureUsage.ENVEFF:        // = 7, //unused by V
            case TextureUsage.WATER:         // = 13, //unused by V
            case TextureUsage.FOAM:          // = 15,  //unused by V
            case TextureUsage.DIFFUSEDETAIL: // = 17, //unused by V
            case TextureUsage.DONOTOPTIMIZE: // = 27, //unused by V
            case TextureUsage.TEST:          // = 28,  //unused by V
            case TextureUsage.COUNT:         // = 29, //unused by V
                break;

            default:
                break;
            }

            var uf = UsageFlags;

            if ((uf & TextureUsageFlags.EMBEDDEDSCRIPTRT) > 0) // .ydr embedded script_rt textures, only 3 uses
            {
            }
            if ((uf & TextureUsageFlags.UNK19) > 0)
            {
            }
            if ((uf & TextureUsageFlags.UNK20) > 0)
            {
            }
            if ((uf & TextureUsageFlags.UNK21) > 0)
            {
            }
            if ((uf & TextureUsageFlags.UNK24) == 0)//wtf isthis? only 0 on special resident(?) textures and some reused ones
            {
            }
        }
예제 #21
0
 public abstract IResourceSystemBlock GetType(ResourceDataReader reader, params object[] parameters);
예제 #22
0
 public IResourceBlock CheckForCast(ResourceDataReader reader, params object[] parameters)
 {
     throw new NotImplementedException();
 }
예제 #23
0
 public override void Read(ResourceDataReader reader, params object[] parameters)
 {
     Value = reader.ReadString();
 }
예제 #24
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
        }
예제 #25
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
            {
            }
        }
예제 #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);


            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;
        }
예제 #27
0
파일: YptFile.cs 프로젝트: rt-2/CodeWalker
        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;
        }
예제 #28
0
 public override void Read(ResourceDataReader reader, params object[] parameters)
 {
     Data = reader.ReadBytes(DataLength);
 }
예제 #29
0
 /// <summary>
 /// Reads the data block.
 /// </summary>
 public abstract void Read(ResourceDataReader reader, params object[] parameters);
예제 #30
0
파일: Texture.cs 프로젝트: q4a/CodeWalker
        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.ReadUInt32();
            this.Unknown_24h = reader.ReadUInt32();
            this.NamePointer = reader.ReadUInt64();
            this.Unknown_30h = reader.ReadUInt16();
            this.Unknown_32h = reader.ReadUInt16();
            this.Unknown_34h = reader.ReadUInt32();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();
            this.UsageData   = reader.ReadUInt32();
            this.Unknown_44h = reader.ReadUInt32();
            this.ExtraFlags  = reader.ReadUInt32();
            this.Unknown_4Ch = reader.ReadUInt32();



            // read reference data
            this.Name = reader.ReadStringAt( //BlockAt<string_r>(
                this.NamePointer             // offset
                );

            if (!string.IsNullOrEmpty(Name))
            {
                NameHash = JenkHash.GenHash(Name.ToLowerInvariant());
            }

            //switch (Unknown_32h)
            //{
            //    case 0x20:
            //    case 0x28:
            //    case 0x30:
            //    case 0x38:
            //    case 0x40:
            //    case 0x48:
            //    case 0x80:
            //    case 0x90:
            //    case 0x2://base/shaderparam
            //        break;
            //    default:
            //        break;//no hit
            //}

            //switch (Usage)
            //{
            //    case TextureUsage.UNKNOWN:// = 0,
            //    case TextureUsage.DEFAULT:// = 1,
            //    case TextureUsage.TERRAIN:// = 2,
            //    case TextureUsage.CLOUDDENSITY:// = 3,
            //    case TextureUsage.CLOUDNORMAL:// = 4,
            //    case TextureUsage.CABLE:// = 5,
            //    case TextureUsage.FENCE:// = 6,
            //    case TextureUsage.SCRIPT:// = 8,
            //    case TextureUsage.WATERFLOW:// = 9,
            //    case TextureUsage.WATERFOAM:// = 10,
            //    case TextureUsage.WATERFOG:// = 11,
            //    case TextureUsage.WATEROCEAN:// = 12,
            //    case TextureUsage.FOAMOPACITY:// = 14,
            //    case TextureUsage.DIFFUSEMIPSHARPEN:// = 16,
            //    case TextureUsage.DIFFUSEDARK:// = 18,
            //    case TextureUsage.DIFFUSEALPHAOPAQUE:// = 19,
            //    case TextureUsage.DIFFUSE:// = 20,
            //    case TextureUsage.DETAIL:// = 21,
            //    case TextureUsage.NORMAL:// = 22,
            //    case TextureUsage.SPECULAR:// = 23,
            //    case TextureUsage.EMISSIVE:// = 24,
            //    case TextureUsage.TINTPALETTE:// = 25,
            //    case TextureUsage.SKIPPROCESSING:// = 26,
            //        break;
            //    case TextureUsage.ENVEFF:// = 7, //unused by V
            //    case TextureUsage.WATER:// = 13, //unused by V
            //    case TextureUsage.FOAM:// = 15,  //unused by V
            //    case TextureUsage.DIFFUSEDETAIL:// = 17, //unused by V
            //    case TextureUsage.DONOTOPTIMIZE:// = 27, //unused by V
            //    case TextureUsage.TEST:// = 28,  //unused by V
            //    case TextureUsage.COUNT:// = 29, //unused by V
            //        break;//no hit
            //    default:
            //        break;//no hit
            //}

            //var uf = UsageFlags;
            //if ((uf & TextureUsageFlags.EMBEDDEDSCRIPTRT) > 0) // .ydr embedded script_rt textures, only 3 uses
            //{ }
            //if ((uf & TextureUsageFlags.UNK19) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK20) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK21) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK24) == 0)//wtf isthis? only 0 on special resident(?) textures and some reused ones
            //{ }

            //if (!(this is Texture))
            //{
            //    if (Unknown_32h != 0x2)//base/shaderparam
            //    { }//no hit
            //    if (UsageData != 0)
            //    { }//no hit
            //    if (Unknown_44h != 0)
            //    { }//no hit
            //    if (ExtraFlags != 0)
            //    { }//no hit
            //    if (Unknown_4Ch != 0)
            //    { }//no hit
            //}
        }