// 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();
        }
Exemple #2
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);
            }
        }
Exemple #3
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>();
        }
Exemple #4
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>();
            }
        }
Exemple #5
0
 private Node ReadNode(ResFileLoader loader)
 {
     return(new Node()
     {
         Reference = loader.ReadUInt32(),
         IdxLeft = loader.ReadUInt16(),
         IdxRight = loader.ReadUInt16(),
         Key = loader.LoadString(),
     });
 }
Exemple #6
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;
                }
            }
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            ushort numCurve        = loader.ReadUInt16();
            ushort numKeyShapeAnim = loader.ReadUInt16();

            BeginCurve        = loader.ReadInt32();
            BeginKeyShapeAnim = loader.ReadInt32();
            Name = loader.LoadString();
            KeyShapeAnimInfos = loader.LoadList <KeyShapeAnimInfo>(numKeyShapeAnim);
            Curves            = loader.LoadList <AnimCurve>(numCurve);
            BaseDataList      = loader.LoadCustom(() => loader.ReadSingles(numKeyShapeAnim - 1)); // Without base shape.
        }
Exemple #8
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            ushort numPatAnim = loader.ReadUInt16();
            ushort numCurve   = loader.ReadUInt16();

            BeginCurve       = loader.ReadInt32();
            BeginPatAnim     = loader.ReadInt32();
            Name             = loader.LoadString();
            PatternAnimInfos = loader.LoadList <PatternAnimInfo>(numPatAnim);
            Curves           = loader.LoadList <AnimCurve>(numCurve);
            BaseDataList     = loader.LoadCustom(() => loader.ReadUInt16s(numPatAnim));
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            ushort numAnimParam = loader.ReadUInt16();
            ushort numCurve     = loader.ReadUInt16();
            ushort numConstant  = loader.ReadUInt16();

            loader.Seek(2);
            BeginCurve     = loader.ReadInt32();
            BeginParamAnim = loader.ReadInt32();
            Name           = loader.LoadString();
            ParamAnimInfos = loader.LoadList <ParamAnimInfo>(numAnimParam);
            Curves         = loader.LoadList <AnimCurve>(numCurve);
            Constants      = loader.LoadCustom(() => loader.ReadAnimConstants(numConstant));
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

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

            CameraAnims = loader.LoadDict <CameraAnim>();
            LightAnims  = loader.LoadDict <LightAnim>();
            FogAnims    = loader.LoadDict <FogAnim>();
            UserData    = loader.LoadDict <UserData>();
        }
Exemple #11
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;
            }
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            _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)));
            InverseModelMatrices = loader.LoadCustom(() => loader.ReadMatrix3x4s(numSmoothMatrix));
            uint userPointer = loader.ReadUInt32();
        }
Exemple #13
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>();
            }
        }
Exemple #14
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.ResFile.Version >= 0x02040000)
            {
                loader.CheckSignature(_signature);
                Name   = loader.LoadString();
                Path   = loader.LoadString();
                _flags = loader.ReadUInt32();

                if (loader.ResFile.Version >= 0x03040000)
                {
                    FrameCount  = loader.ReadInt32();
                    numBoneAnim = loader.ReadUInt16();
                    ushort numUserData = loader.ReadUInt16();
                    int    numCurve    = loader.ReadInt32();
                    BakedSize = loader.ReadUInt32();
                }
                else
                {
                    FrameCount  = loader.ReadUInt16();
                    numBoneAnim = loader.ReadUInt16();
                    ushort numUserData = loader.ReadUInt16();
                    ushort numCurve    = loader.ReadUInt16();
                    BakedSize = loader.ReadUInt32();
                    loader.Seek(4); //padding
                }

                BoneAnims    = loader.LoadList <BoneAnim>(numBoneAnim).ToList();
                BindSkeleton = loader.Load <Skeleton>();
                BindIndices  = loader.LoadCustom(() => loader.ReadUInt16s(numBoneAnim));
                UserData     = loader.LoadDict <UserData>();
            }
            else
            {
                _flags      = loader.ReadUInt32();
                FrameCount  = loader.ReadUInt16();
                numBoneAnim = loader.ReadUInt16();
                ushort numUserData = loader.ReadUInt16();
                ushort numCurve    = loader.ReadUInt16();
                Name         = loader.LoadString();
                Path         = loader.LoadString();
                BoneAnims    = loader.LoadList <BoneAnim>(numBoneAnim).ToList();
                BindSkeleton = loader.Load <Skeleton>();
                BindIndices  = loader.LoadCustom(() => loader.ReadUInt16s(numBoneAnim));
            }
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name       = loader.LoadString();
            Path       = loader.LoadString();
            _flags     = loader.ReadUInt32();
            FrameCount = loader.ReadInt32();
            ushort numBoneAnim = loader.ReadUInt16();
            ushort numUserData = loader.ReadUInt16();
            int    numCurve    = loader.ReadInt32();

            BakedSize    = loader.ReadUInt32();
            BoneAnims    = loader.LoadList <BoneAnim>(numBoneAnim);
            BindSkeleton = loader.Load <Skeleton>();
            BindIndices  = loader.LoadCustom(() => loader.ReadUInt16s(numBoneAnim));
            UserData     = loader.LoadDict <UserData>();
        }
Exemple #16
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

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

            ParentIndex       = loader.ReadUInt16();
            SmoothMatrixIndex = loader.ReadInt16();
            RigidMatrixIndex  = loader.ReadInt16();
            BillboardIndex    = loader.ReadUInt16();
            ushort numUserData = loader.ReadUInt16();

            _flags   = loader.ReadUInt32();
            Scale    = loader.ReadVector3F();
            Rotation = loader.ReadVector4F();
            Position = loader.ReadVector3F();
            UserData = loader.LoadDict <UserData>();
        }
        // ---- METHODS ------------------------------------------------------------------------------------------------

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

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name       = loader.LoadString();
            Path       = loader.LoadString();
            Flags      = loader.ReadEnum <ShaderParamAnimFlags>(true);
            FrameCount = loader.ReadInt32();
            ushort numMatAnim   = loader.ReadUInt16();
            ushort numUserData  = loader.ReadUInt16();
            int    numParamAnim = loader.ReadInt32();
            int    numCurve     = loader.ReadInt32();

            BakedSize           = loader.ReadUInt32();
            BindModel           = loader.Load <Model>();
            BindIndices         = loader.LoadCustom(() => loader.ReadUInt16s(numMatAnim));
            ShaderParamMatAnims = loader.LoadList <ShaderParamMatAnim>(numMatAnim);
            UserData            = loader.LoadDict <UserData>();
        }
Exemple #20
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name     = loader.LoadString();
                UserData = loader.LoadDictValues <UserData>();
                if (loader.ResFile.VersionMajor2 == 8 || loader.ResFile.VersionMajor2 == 9)
                {
                    loader.Seek(16);
                }

                ushort idx = loader.ReadUInt16();
                ParentIndex       = loader.ReadInt16();
                SmoothMatrixIndex = loader.ReadInt16();
                RigidMatrixIndex  = loader.ReadInt16();
                BillboardIndex    = loader.ReadInt16();
                ushort numUserData = loader.ReadUInt16();
                _flags   = loader.ReadUInt32();
                Scale    = loader.ReadVector3F();
                Rotation = loader.ReadVector4F();
                Position = loader.ReadVector3F();
            }
            else
            {
                Name = loader.LoadString();
                ushort idx = loader.ReadUInt16();
                ParentIndex       = loader.ReadInt16();
                SmoothMatrixIndex = loader.ReadInt16();
                RigidMatrixIndex  = loader.ReadInt16();
                BillboardIndex    = loader.ReadInt16();
                ushort numUserData = loader.ReadUInt16();
                _flags   = loader.ReadUInt32();
                Scale    = loader.ReadVector3F();
                Rotation = loader.ReadVector4F();
                Position = loader.ReadVector3F();
                UserData = loader.LoadDict <UserData>();

                if (loader.ResFile.Version < 0x03040000)
                {
                    InverseMatrix = loader.ReadMatrix3x4();
                }
            }
        }
Exemple #21
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name = loader.LoadString();
                uint   CurveOffset             = loader.ReadOffset();
                uint   BaseDataOffset          = loader.ReadOffset();
                uint   KeyShapeAnimInfosOffset = loader.ReadOffset();
                ushort numCurve        = loader.ReadUInt16();
                ushort numKeyShapeAnim = loader.ReadUInt16();
                BeginCurve        = loader.ReadInt32();
                BeginKeyShapeAnim = loader.ReadInt32();
                loader.Seek(4); //Padding

                KeyShapeAnimInfos = loader.LoadList <KeyShapeAnimInfo>(numKeyShapeAnim, KeyShapeAnimInfosOffset);
                Curves            = loader.LoadList <AnimCurve>(numCurve, CurveOffset);
                BaseDataList      = loader.LoadCustom(() => loader.ReadSingles(numKeyShapeAnim - 1), BaseDataOffset); // Without base shape.
            }
            else
            {
                ushort numCurve;
                ushort numKeyShapeAnim;
                if (loader.ResFile.Version >= 0x03040000)
                {
                    numCurve        = loader.ReadUInt16();
                    numKeyShapeAnim = loader.ReadUInt16();
                }
                else
                {
                    numCurve        = loader.ReadByte();
                    numKeyShapeAnim = loader.ReadByte();
                    unk             = loader.ReadUInt16();
                }

                BeginCurve        = loader.ReadInt32();
                BeginKeyShapeAnim = loader.ReadInt32();
                Name = loader.LoadString();
                KeyShapeAnimInfos = loader.LoadList <KeyShapeAnimInfo>(numKeyShapeAnim);
                Curves            = loader.LoadList <AnimCurve>(numCurve);
                BaseDataList      = loader.LoadCustom(() => loader.ReadSingles(numKeyShapeAnim - 1)); // Without base shape.
            }
        }
Exemple #22
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            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();
            uint   userPointer      = loader.ReadUInt32();

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

        void IResData.Load(ResFileLoader loader)
        {
            uint dataPointer = loader.ReadUInt32();
            uint size        = loader.ReadUInt32();
            uint handle      = loader.ReadUInt32();

            Stride = loader.ReadUInt16();
            ushort numBuffering   = loader.ReadUInt16();
            uint   contextPointer = loader.ReadUInt32();

            Data = loader.LoadCustom(() =>
            {
                byte[][] data = new byte[numBuffering][];
                for (int i = 0; i < numBuffering; i++)
                {
                    data[i] = loader.ReadBytes((int)size);
                }
                return(data);
            });
        }
Exemple #24
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            if (loader.IsSwitch)
            {
                Name             = loader.LoadString();
                loader.ByteOrder = ByteOrder.BigEndian;
                Format           = ConvertToGX2(loader.ReadEnum <SwitchAttribFormat>(true));
                loader.ByteOrder = ByteOrder.LittleEndian;
                loader.Seek(2); //padding
                Offset      = loader.ReadUInt16();
                BufferIndex = (byte)loader.ReadUInt16();
            }
            else
            {
                Name        = loader.LoadString();
                BufferIndex = loader.ReadByte();
                loader.Seek(1);
                Offset = loader.ReadUInt16();
                Format = loader.ReadEnum <GX2AttribFormat>(true);
            }
        }
Exemple #25
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.ResFile.IsPlatformSwitch)
            {
                Switch.SceneAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Name = loader.LoadString();
                Path = loader.LoadString();
                ushort numUserData   = loader.ReadUInt16();
                ushort numCameraAnim = loader.ReadUInt16();
                ushort numLightAnim  = loader.ReadUInt16();
                ushort numFogAnim    = loader.ReadUInt16();
                CameraAnims = loader.LoadDict <CameraAnim>();
                LightAnims  = loader.LoadDict <LightAnim>();
                FogAnims    = loader.LoadDict <FogAnim>();
                UserData    = loader.LoadDict <UserData>();
            }
        }
Exemple #26
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            PrimitiveType = loader.ReadEnum <GX2PrimitiveType>(true);
            IndexFormat   = loader.ReadEnum <GX2IndexFormat>(true);
            uint   indexCount = loader.ReadUInt32();
            ushort numSubMesh = loader.ReadUInt16();

            loader.Seek(2);
            SubMeshes   = loader.LoadList <SubMesh>(numSubMesh);
            IndexBuffer = loader.Load <Buffer>();
            FirstVertex = loader.ReadUInt32();
        }
Exemple #27
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>();
            }
        }
Exemple #28
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();
            }
        }
        // TODO: Methods to retrieve the strongly-typed shader param value.

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

        void IResData.Load(ResFileLoader loader)
        {
            Type = loader.ReadEnum <ShaderParamType>(true);
            if (loader.ResFile.Version >= 0x03030000)
            {
                byte sizData = loader.ReadByte();
                DataOffset = loader.ReadUInt16();
                int  offset          = loader.ReadInt32(); // Uniform variable offset.
                uint callbackPointer = loader.ReadUInt32();
                DependedIndex = loader.ReadUInt16();
                DependIndex   = loader.ReadUInt16();
                Name          = loader.LoadString();
            }
            else
            {
                // GUESS
                loader.Seek(1);
                DataOffset = loader.ReadUInt16();
                int offset = loader.ReadInt32(); // Uniform variable offset.
                Name = loader.LoadString();
            }
        }
Exemple #30
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.ShapeAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Name  = loader.LoadString();
                Path  = loader.LoadString();
                Flags = loader.ReadEnum <ShapeAnimFlags>(true);

                ushort numUserData;
                ushort numVertexShapeAnim;
                ushort numKeyShapeAnim;
                ushort numCurve;
                if (loader.ResFile.Version >= 0x03040000)
                {
                    numUserData        = loader.ReadUInt16();
                    FrameCount         = loader.ReadInt32();
                    numVertexShapeAnim = loader.ReadUInt16();
                    numKeyShapeAnim    = loader.ReadUInt16();
                    numCurve           = loader.ReadUInt16();
                    loader.Seek(2);
                    BakedSize = loader.ReadUInt32();
                }
                else
                {
                    FrameCount         = loader.ReadUInt16();
                    numVertexShapeAnim = loader.ReadUInt16();
                    numKeyShapeAnim    = loader.ReadUInt16();
                    numUserData        = loader.ReadUInt16();
                    numCurve           = loader.ReadUInt16();
                    BakedSize          = loader.ReadUInt32();
                }

                BindModel        = loader.Load <Model>();
                BindIndices      = loader.LoadCustom(() => loader.ReadUInt16s(numVertexShapeAnim));
                VertexShapeAnims = loader.LoadList <VertexShapeAnim>(numVertexShapeAnim);
                UserData         = loader.LoadDict <UserData>();
            }
        }