Esempio n. 1
0
        // TODO: Methods to access ShaderParam variable values.

        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name  = loader.LoadString();
            Flags = loader.ReadEnum <MaterialFlags>(true);
            ushort idx                    = loader.ReadUInt16();
            ushort numRenderInfo          = loader.ReadUInt16();
            byte   numSampler             = loader.ReadByte();
            byte   numTextureRef          = loader.ReadByte();
            ushort numShaderParam         = loader.ReadUInt16();
            ushort numShaderParamVolatile = loader.ReadUInt16();
            ushort sizParamSource         = loader.ReadUInt16();
            ushort sizParamRaw            = loader.ReadUInt16();
            ushort numUserData            = loader.ReadUInt16();

            RenderInfos  = loader.LoadDict <RenderInfo>();
            RenderState  = loader.Load <RenderState>();
            ShaderAssign = loader.Load <ShaderAssign>();
            TextureRefs  = loader.LoadList <TextureRef>(numTextureRef);
            uint ofsSamplerList = loader.ReadOffset(); // Only use dict.

            Samplers = loader.LoadDict <Sampler>();
            uint ofsShaderParamList = loader.ReadOffset(); // Only use dict.

            ShaderParams    = loader.LoadDict <ShaderParam>();
            ShaderParamData = loader.LoadCustom(() => loader.ReadBytes(sizParamSource));
            UserData        = loader.LoadDict <UserData>();
            VolatileFlags   = loader.LoadCustom(() => loader.ReadBytes((int)Math.Ceiling(numShaderParam / 8f)));
            uint userPointer = loader.ReadUInt32();
        }
Esempio n. 2
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            Name = loader.LoadString();
            ushort count = loader.ReadUInt16();

            Type = loader.ReadEnum <UserDataType>(true);
            loader.Seek(1);
            switch (Type)
            {
            case UserDataType.Int32:
                _value = loader.ReadInt32s(count);
                break;

            case UserDataType.Single:
                _value = loader.ReadSingles(count);
                break;

            case UserDataType.String:
                _value = loader.LoadStrings(count, Encoding.ASCII);
                break;

            case UserDataType.WString:
                _value = loader.LoadStrings(count, Encoding.Unicode);
                break;

            case UserDataType.Byte:
                _value = loader.ReadBytes(count);
                break;
            }
        }
Esempio n. 3
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.LightAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Flags = loader.ReadEnum <LightAnimFlags>(true);
                ushort numUserData = loader.ReadUInt16();
                FrameCount = loader.ReadInt32();
                byte numCurve = loader.ReadByte();
                LightTypeIndex        = loader.ReadSByte();
                DistanceAttnFuncIndex = loader.ReadSByte();
                AngleAttnFuncIndex    = loader.ReadSByte();
                BakedSize             = loader.ReadUInt32();
                Name                 = loader.LoadString();
                LightTypeName        = loader.LoadString();
                DistanceAttnFuncName = loader.LoadString();
                AngleAttnFuncName    = loader.LoadString();
                Curves               = loader.LoadList <AnimCurve>(numCurve);
                BaseData             = loader.LoadCustom(() => new LightAnimData(loader, AnimatedFields));
                UserData             = loader.LoadDict <UserData>();
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResFile"/> class from the file with the given
 /// <paramref name="fileName"/>.
 /// </summary>
 /// <param name="fileName">The name of the file to load the data from.</param>
 public ResFile(string fileName)
 {
     using (ResFileLoader loader = new ResFileLoader(this, fileName))
     {
         loader.Execute();
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResFile"/> class from the given <paramref name="stream"/> which
 /// is optionally left open.
 /// </summary>
 /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
 /// <param name="leaveOpen"><c>true</c> to leave the stream open after reading, otherwise <c>false</c>.</param>
 public ResFile(Stream stream, bool leaveOpen = false)
 {
     using (ResFileLoader loader = new ResFileLoader(this, stream, leaveOpen))
     {
         loader.Execute();
     }
 }
Esempio n. 6
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader, UserDataType Type, int count)
        {
            switch (Type)
            {
            case UserDataType.Int32:
                _value = loader.ReadInt32s(count);
                break;

            case UserDataType.Single:
                _value = loader.ReadSingles(count);
                break;

            case UserDataType.String:
                _value = loader.LoadStrings(count, Encoding.ASCII);
                break;

            case UserDataType.WString:
                _value = loader.LoadStrings(count, Encoding.Unicode);
                break;

            case UserDataType.Byte:
                _value = loader.ReadBytes(count);
                break;
            }
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            CurveIndex   = loader.ReadSByte();
            SubBindIndex = loader.ReadSByte();
            loader.Seek(2);
            Name = loader.LoadString();
        }
Esempio n. 8
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name   = loader.LoadString();
            Path   = loader.LoadString();
            _flags = loader.ReadUInt16();
            ushort numUserData = loader.ReadUInt16();

            FrameCount = loader.ReadInt32();
            ushort numAnim  = loader.ReadUInt16();
            ushort numCurve = loader.ReadUInt16();

            BakedSize    = loader.ReadUInt32();
            BindModel    = loader.Load <Model>();
            BindIndices  = loader.LoadCustom(() => loader.ReadUInt16s(numAnim));
            Names        = loader.LoadCustom(() => loader.LoadStrings(numAnim)); // Offset to name list.
            Curves       = loader.LoadList <AnimCurve>(numCurve);
            BaseDataList = loader.LoadCustom(() =>
            {
                bool[] baseData = new bool[numAnim];
                int i           = 0;
                while (i < numAnim)
                {
                    byte b = loader.ReadByte();
                    for (int j = 0; j < 8 && i < numAnim; j++)
                    {
                        baseData[i++] = b.GetBit(j);
                    }
                }
                return(baseData);
            });
            UserData = loader.LoadDict <UserData>();
        }
Esempio n. 9
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            _flags         = loader.ReadUInt32();
            PolygonControl = new PolygonControl()
            {
                Value = loader.ReadUInt32()
            };
            DepthControl = new DepthControl()
            {
                Value = loader.ReadUInt32()
            };
            AlphaControl = new AlphaControl()
            {
                Value = loader.ReadUInt32()
            };
            AlphaRefValue = loader.ReadSingle();
            ColorControl  = new ColorControl()
            {
                Value = loader.ReadUInt32()
            };
            BlendTarget  = loader.ReadUInt32();
            BlendControl = new BlendControl()
            {
                Value = loader.ReadUInt32()
            };
            BlendColor = loader.ReadVector4F();
        }
Esempio n. 10
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            ShaderArchiveName = loader.LoadString();
            ShadingModelName  = loader.LoadString();

            if (loader.IsSwitch)
            {
                AttribAssigns  = loader.LoadDictValues <ResString>();
                SamplerAssigns = loader.LoadDictValues <ResString>();
                ShaderOptions  = loader.LoadDictValues <ResString>();
                Revision       = loader.ReadUInt32();
                byte   numAttribAssign  = loader.ReadByte();
                byte   numSamplerAssign = loader.ReadByte();
                ushort numShaderOption  = loader.ReadUInt16();
            }
            else
            {
                Revision = loader.ReadUInt32();
                byte   numAttribAssign  = loader.ReadByte();
                byte   numSamplerAssign = loader.ReadByte();
                ushort numShaderOption  = loader.ReadUInt16();
                AttribAssigns  = loader.LoadDict <ResString>();
                SamplerAssigns = loader.LoadDict <ResString>();
                ShaderOptions  = loader.LoadDict <ResString>();
            }
        }
 public void Import(string FileName, ResFile ResFile)
 {
     using (ResFileLoader loader = new ResFileLoader(this, ResFile, FileName))
     {
         loader.ImportSection();
     }
 }
Esempio n. 12
0
        void IResData.Load(ResFileLoader loader)
        {
            uint ofsData = loader.ReadOffset();
            uint sizData = loader.ReadSize();

            Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData), ofsData);
        }
Esempio n. 13
0
        // TODO: Methods to retrieve the strongly-typed shader param value.

        // ---- METHODS ------------C:\Users\Nathan\Documents\GitHub\NintenTools.Bfres-master\NintenTools.Bfres\src\Syroot.NintenTools.Bfres\ExternalFile\------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            Type = loader.ReadEnum <ShaderParamType>(true);
            byte sizData = loader.ReadByte();

            if (sizData != (byte)DataSize && sizData > DataSize)
            {
                UsePadding    = true;
                PaddingLength = sizData - (byte)DataSize;
            }

            DataOffset = loader.ReadUInt16();
            offset     = loader.ReadInt32(); // Uniform variable offset.
            if (loader.ResFile.Version >= 0x03040000)
            {
                callbackPointer = loader.ReadUInt32();
                DependedIndex   = loader.ReadUInt16();
                DependIndex     = loader.ReadUInt16();
            }
            else if (loader.ResFile.Version >= 0x03030000 &&
                     loader.ResFile.Version < 0x03040000)
            {
                callbackPointer = loader.ReadUInt32();
                DependedIndex   = loader.ReadUInt16();
                DependIndex     = loader.ReadUInt16();
                uint FMATOffset = loader.ReadUInt32(); //Why does this have this????
            }
            Name = loader.LoadString();
        }
Esempio n. 14
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.ModelParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Name     = loader.LoadString();
                Path     = loader.LoadString();
                Skeleton = loader.Load <Skeleton>();
                uint ofsVertexBufferList = loader.ReadOffset();
                Shapes    = loader.LoadDict <Shape>();
                Materials = loader.LoadDict <Material>();
                UserData  = loader.LoadDict <UserData>();
                ushort numVertexBuffer  = loader.ReadUInt16();
                ushort numShape         = loader.ReadUInt16();
                ushort numMaterial      = loader.ReadUInt16();
                ushort numUserData      = loader.ReadUInt16();
                uint   totalVertexCount = loader.ReadUInt32();

                if (loader.ResFile.Version >= 0x03030000)
                {
                    uint userPointer = loader.ReadUInt32();
                }

                VertexBuffers = loader.LoadList <VertexBuffer>(numVertexBuffer, ofsVertexBufferList);
            }
        }
Esempio n. 15
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        public void Import(string FileName, VertexBuffer vertexBuffer, ResFile ResFile)
        {
            using (ResFileLoader loader = new ResFileLoader(this, ResFile, FileName))
            {
                loader.ImportSection(vertexBuffer);
            }
        }
Esempio n. 16
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                if (loader.ResFile.VersionMajor2 == 9)
                {
                    _flags = loader.ReadUInt32();
                }
                else
                {
                    ((Switch.Core.ResFileSwitchLoader)loader).LoadHeaderBlock();
                }

                long BoneDictOffset  = loader.ReadOffset();
                long BoneArrayOffset = loader.ReadOffset();
                Bones = loader.LoadDictValues <Bone>(BoneDictOffset, BoneArrayOffset);

                uint MatrixToBoneListOffset     = loader.ReadOffset();
                uint InverseModelMatricesOffset = loader.ReadOffset();

                if (loader.ResFile.VersionMajor2 == 8)
                {
                    loader.Seek(16);
                }
                if (loader.ResFile.VersionMajor2 == 9)
                {
                    loader.Seek(8);
                }

                long userPointer = loader.ReadInt64();
                if (loader.ResFile.VersionMajor2 != 9)
                {
                    _flags = loader.ReadUInt32();
                }
                ushort numBone         = loader.ReadUInt16();
                ushort numSmoothMatrix = loader.ReadUInt16();
                ushort numRigidMatrix  = loader.ReadUInt16();
                loader.Seek(6);

                MatrixToBoneList     = loader.LoadCustom(() => loader.ReadUInt16s((numSmoothMatrix + numRigidMatrix)), MatrixToBoneListOffset);
                InverseModelMatrices = loader.LoadCustom(() => loader.ReadMatrix3x4s(numSmoothMatrix), InverseModelMatricesOffset)?.ToList();
            }
            else
            {
                _flags = loader.ReadUInt32();
                ushort numBone         = loader.ReadUInt16();
                ushort numSmoothMatrix = loader.ReadUInt16();
                ushort numRigidMatrix  = loader.ReadUInt16();
                loader.Seek(2);
                Bones = loader.LoadDict <Bone>();
                uint ofsBoneList = loader.ReadOffset(); // Only load dict.
                MatrixToBoneList = loader.LoadCustom(() => loader.ReadUInt16s((numSmoothMatrix + numRigidMatrix)));
                if (loader.ResFile.Version >= 0x03040000)
                {
                    InverseModelMatrices = loader.LoadCustom(() => loader.ReadMatrix3x4s(numSmoothMatrix))?.ToList();
                }
                uint userPointer = loader.ReadUInt32();
            }
        }
Esempio n. 17
0
        public static void Load(ResFileLoader loader, ResFile resFile)
        {
            loader.CheckSignature("FRES");
            resFile.Version = loader.ReadUInt32();
            resFile.SetVersionInfo(resFile.Version);
            resFile.ByteOrder = loader.ReadByteOrder();
            ushort sizHeader = loader.ReadUInt16();
            uint   sizFile   = loader.ReadUInt32();

            resFile.Alignment = loader.ReadUInt32();
            resFile.Name      = loader.LoadString();
            uint sizStringPool = loader.ReadUInt32();
            uint ofsStringPool = loader.ReadOffset();

            resFile.Models = loader.LoadDict <Model>();
            var textures = loader.LoadDict <Texture>();

            resFile.SkeletalAnims       = loader.LoadDict <SkeletalAnim>();
            resFile.ShaderParamAnims    = loader.LoadDict <MaterialAnim>();
            resFile.ColorAnims          = loader.LoadDict <MaterialAnim>();
            resFile.TexSrtAnims         = loader.LoadDict <MaterialAnim>();
            resFile.TexPatternAnims     = loader.LoadDict <MaterialAnim>();
            resFile.BoneVisibilityAnims = loader.LoadDict <VisibilityAnim>();
            loader.LoadDict <VisibilityAnim>();
            resFile.ShapeAnims = loader.LoadDict <ShapeAnim>();

            resFile.Textures = new ResDict <TextureShared>();
            foreach (var tex in textures)
            {
                resFile.Textures.Add(tex.Key, tex.Value);
            }

            if (loader.ResFile.Version >= 0x02040000)
            {
                resFile.SceneAnims    = loader.LoadDict <SceneAnim>();
                resFile.ExternalFiles = loader.LoadDict <ExternalFile>();
                ushort numModel              = loader.ReadUInt16();
                ushort numTexture            = loader.ReadUInt16();
                ushort numSkeletalAnim       = loader.ReadUInt16();
                ushort numShaderParamAnim    = loader.ReadUInt16();
                ushort numColorAnim          = loader.ReadUInt16();
                ushort numTexSrtAnim         = loader.ReadUInt16();
                ushort numTexPatternAnim     = loader.ReadUInt16();
                ushort numBoneVisibilityAnim = loader.ReadUInt16();
                ushort numMatVisibilityAnim  = loader.ReadUInt16();
                ushort numShapeAnim          = loader.ReadUInt16();
                ushort numSceneAnim          = loader.ReadUInt16();
                ushort numExternalFile       = loader.ReadUInt16();
                uint   userPointer           = loader.ReadUInt32();
            }
            else //Note very old versions have no counts and is mostly unkown atm
            {
                uint userPointer  = loader.ReadUInt32();
                uint userPointer2 = loader.ReadUInt32();

                resFile.SceneAnims    = loader.LoadDict <SceneAnim>();
                resFile.ExternalFiles = loader.LoadDict <ExternalFile>();
            }
        }
Esempio n. 18
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            unk = loader.ReadUInt32();
            uint Size = loader.ReadUInt32();

            BufferOffset = loader.ReadInt64();
            byte[] padding = loader.ReadBytes(16);
        }
Esempio n. 19
0
        // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------

        internal BoneAnimData(ResFileLoader loader, BoneAnimFlagsBase flags)
        {
            Flags     = 0; // Never in files.
            Scale     = flags.HasFlag(BoneAnimFlagsBase.Scale) ? loader.ReadVector3F() : Vector3F.Zero;
            Rotate    = flags.HasFlag(BoneAnimFlagsBase.Rotate) ? loader.ReadVector4F() : Vector4F.Zero;
            Padding   = 0; // Never in files.
            Translate = flags.HasFlag(BoneAnimFlagsBase.Translate) ? loader.ReadVector3F() : Vector3F.Zero;
        }
Esempio n. 20
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            Name        = loader.LoadString();
            BufferIndex = loader.ReadByte();
            loader.Seek(1);
            Offset = loader.ReadUInt16();
            Format = loader.ReadEnum <GX2AttribFormat>(true);
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            LeftChildIndex  = loader.ReadUInt16();
            RightChildIndex = loader.ReadUInt16();
            Unknown         = loader.ReadUInt16();
            NextSibling     = loader.ReadUInt16();
            SubMeshIndex    = loader.ReadUInt16();
            SubMeshCount    = loader.ReadUInt16();
        }
Esempio n. 22
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.ResFile.Version >= 0x02040000)
            {
                uint ofsData = loader.ReadOffset();
                uint sizData = loader.ReadUInt32();
                Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData), ofsData);
            }
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            BeginCurve      = loader.ReadUInt16();
            FloatCurveCount = loader.ReadUInt16();
            IntCurveCount   = loader.ReadUInt16();
            BeginConstant   = loader.ReadUInt16();
            ConstantCount   = loader.ReadUInt16();
            SubBindIndex    = loader.ReadUInt16();
            Name            = loader.LoadString();
        }
Esempio n. 24
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            TexSampler = new TexSampler(loader.ReadUInt32s(3));
            uint handle = loader.ReadUInt32();

            Name = loader.LoadString();
            byte idx = loader.ReadByte();

            loader.Seek(3);
        }
Esempio n. 25
0
        // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------

        internal CameraAnimData(ResFileLoader loader)
        {
            ClipNear    = loader.ReadSingle();
            ClipFar     = loader.ReadSingle();
            AspectRatio = loader.ReadSingle();
            FieldOfView = loader.ReadSingle();
            Position    = loader.ReadVector3F();
            Rotation    = loader.ReadVector3F();
            Twist       = loader.ReadSingle();
        }
Esempio n. 26
0
 private Node ReadNode(ResFileLoader loader)
 {
     return(new Node()
     {
         Reference = loader.ReadUInt32(),
         IdxLeft = loader.ReadUInt16(),
         IdxRight = loader.ReadUInt16(),
         Key = loader.LoadString(),
     });
 }
Esempio n. 27
0
        // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------

        internal LightAnimData(ResFileLoader loader, LightAnimField flags)
        {
            Enable       = flags.HasFlag(LightAnimField.Enable) ? loader.ReadInt32() : 0;
            Position     = flags.HasFlag(LightAnimField.Position) ? loader.ReadVector3F() : Vector3F.Zero;
            Rotation     = flags.HasFlag(LightAnimField.Rotation) ? loader.ReadVector3F() : Vector3F.Zero;
            DistanceAttn = flags.HasFlag(LightAnimField.DistanceAttn) ? loader.ReadVector2F() : Vector2F.Zero;
            AngleAttn    = flags.HasFlag(LightAnimField.AngleAttn) ? loader.ReadVector2F() : Vector2F.Zero;
            Color0       = flags.HasFlag(LightAnimField.Color0) ? loader.ReadVector3F() : Vector3F.Zero;
            Color1       = flags.HasFlag(LightAnimField.Color1) ? loader.ReadVector3F() : Vector3F.Zero;
        }
Esempio n. 28
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.VisibilityAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Name   = loader.LoadString();
                Path   = loader.LoadString();
                _flags = loader.ReadUInt16();
                ushort numAnim  = 0;
                ushort numCurve = 0;
                if (loader.ResFile.Version >= 0x03040000)
                {
                    ushort numUserData = loader.ReadUInt16();
                    FrameCount = loader.ReadInt32();
                    numAnim    = loader.ReadUInt16();
                    numCurve   = loader.ReadUInt16();
                    BakedSize  = loader.ReadUInt32();
                }
                else
                {
                    FrameCount = loader.ReadInt16();
                    numAnim    = loader.ReadUInt16();
                    numCurve   = loader.ReadUInt16();
                    ushort numUserData = loader.ReadUInt16();
                    BakedSize = loader.ReadUInt32();
                    int padding2 = loader.ReadInt16();
                }
                BindModel     = loader.Load <Model>();
                BindIndices   = loader.LoadCustom(() => loader.ReadUInt16s(numAnim));
                Names         = loader.LoadCustom(() => loader.LoadStrings(numAnim)); // Offset to name list.
                Curves        = loader.LoadList <AnimCurve>(numCurve);
                baseDataBytes = new List <byte>();
                BaseDataList  = loader.LoadCustom(() =>
                {
                    bool[] baseData = new bool[numAnim];
                    int i           = 0;
                    while (i < numAnim)
                    {
                        byte b = loader.ReadByte();
                        baseDataBytes.Add(b);
                        for (int j = 0; j < 8 && i < numAnim; j++)
                        {
                            baseData[i] = b.GetBit(j);
                        }
                        i++;
                    }
                    return(baseData);
                });
                UserData = loader.LoadDict <UserData>();
            }
        }
Esempio n. 29
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name = loader.LoadString();
                long   DataOffset = loader.ReadOffset();
                ushort count      = loader.ReadUInt16();
                Type = loader.ReadEnum <RenderInfoType>(true);
                loader.Seek(5);

                switch (Type)
                {
                case RenderInfoType.Int32:
                    _value = loader.LoadCustom(() => loader.ReadInt32s(count), (uint)DataOffset);
                    break;

                case RenderInfoType.Single:
                    _value = loader.LoadCustom(() => loader.ReadSingles(count), (uint)DataOffset);
                    break;

                case RenderInfoType.String:
                    if (DataOffset == 0)     //Some games have empty data offset and no strings
                    {
                        _value = new string[0];
                    }
                    else
                    {
                        _value = loader.LoadCustom(() => loader.LoadStrings(count), (uint)DataOffset);
                    }
                    break;
                }
            }
            else
            {
                ushort count = loader.ReadUInt16();
                Type = loader.ReadEnum <RenderInfoType>(true);
                loader.Seek(1);
                Name = loader.LoadString();
                switch (Type)
                {
                case RenderInfoType.Int32:
                    _value = loader.ReadInt32s(count);
                    break;

                case RenderInfoType.Single:
                    _value = loader.ReadSingles(count);
                    break;

                case RenderInfoType.String:
                    _value = loader.LoadStrings(count);
                    break;
                }
            }
        }
Esempio n. 30
0
        // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------

        public void Import(string FileName, ResFile ResFile)
        {
            if (FileName.EndsWith(".json"))
            {
                Helpers.SkeletalAnimHelper.FromJson(this, File.ReadAllText(FileName));
            }
            else
            {
                ResFileLoader.ImportSection(FileName, this, ResFile);
            }
        }