Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo 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>();
            }
        }
Ejemplo n.º 4
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>();
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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>();
            }
        }
Ejemplo n.º 7
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>();
            }
        }
Ejemplo n.º 8
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Version = loader.ReadUInt32();
            SetVersionInfo(Version);

            ByteOrder = loader.ReadEnum <ByteOrder>(true);
            ushort sizHeader = loader.ReadUInt16();
            uint   sizFile   = loader.ReadUInt32();

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

            Models              = loader.LoadDict <Model>();
            Textures            = loader.LoadDict <Texture>();
            SkeletalAnims       = loader.LoadDict <SkeletalAnim>();
            ShaderParamAnims    = loader.LoadDict <ShaderParamAnim>();
            ColorAnims          = loader.LoadDict <ShaderParamAnim>();
            TexSrtAnims         = loader.LoadDict <ShaderParamAnim>();
            TexPatternAnims     = loader.LoadDict <TexPatternAnim>();
            BoneVisibilityAnims = loader.LoadDict <VisibilityAnim>();
            MatVisibilityAnims  = loader.LoadDict <VisibilityAnim>();
            ShapeAnims          = loader.LoadDict <ShapeAnim>();

            if (loader.ResFile.Version >= 0x02040000)
            {
                SceneAnims    = loader.LoadDict <SceneAnim>();
                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();

                SceneAnims    = loader.LoadDict <SceneAnim>();
                ExternalFiles = loader.LoadDict <ExternalFile>();
            }
        }
Ejemplo n.º 9
0
        // ---- 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>();
        }
Ejemplo n.º 10
0
        void IResData.Load(ResFileLoader loader)
        {
            if (loader.ResFile.Version >= 0x02040000)
            {
                loader.CheckSignature(_signature);
                Name  = loader.LoadString();
                Path  = loader.LoadString();
                Flags = loader.ReadEnum <ShaderParamAnimFlags>(true);

                ushort numMatAnim = 0;
                if (loader.ResFile.Version >= 0x03040000)
                {
                    FrameCount = loader.ReadInt32();
                    numMatAnim = loader.ReadUInt16();
                    ushort numUserData  = loader.ReadUInt16();
                    int    numParamAnim = loader.ReadInt32();
                    int    numCurve     = loader.ReadInt32();
                    BakedSize = loader.ReadUInt32();
                }
                else
                {
                    FrameCount = loader.ReadUInt16();
                    numMatAnim = loader.ReadUInt16();
                    unk        = loader.ReadUInt32();
                    int numCurve = loader.ReadInt32();
                    BakedSize = loader.ReadUInt32();
                    int padding2 = loader.ReadInt32();
                }
                BindModel           = loader.Load <Model>();
                BindIndices         = loader.LoadCustom(() => loader.ReadUInt16s(numMatAnim));
                ShaderParamMatAnims = loader.LoadList <ShaderParamMatAnim>(numMatAnim);
                UserData            = loader.LoadDict <UserData>();
            }
            else
            {
                Flags      = loader.ReadEnum <ShaderParamAnimFlags>(true);
                FrameCount = loader.ReadInt16();
                ushort numMatAnim  = loader.ReadUInt16();
                ushort numUserData = loader.ReadUInt16();
                ushort unk         = loader.ReadUInt16();
                BakedSize           = loader.ReadUInt32();
                Name                = loader.LoadString();
                Path                = loader.LoadString();
                BindModel           = loader.Load <Model>();
                BindIndices         = loader.LoadCustom(() => loader.ReadUInt16s(numMatAnim));
                ShaderParamMatAnims = loader.LoadList <ShaderParamMatAnim>(numMatAnim);
            }
        }
Ejemplo n.º 11
0
        // ---- 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();
        }
Ejemplo n.º 12
0
        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            byte   numVertexAttrib = loader.ReadByte();
            byte   numBuffer       = loader.ReadByte();
            ushort idx             = loader.ReadUInt16();
            uint   vertexCount     = loader.ReadUInt32();

            VertexSkinCount = loader.ReadByte();
            loader.Seek(3);
            uint ofsVertexAttribList = loader.ReadOffset(); // Only load dict.

            Attributes = loader.LoadDict <VertexAttrib>();
            Buffers    = loader.LoadList <Buffer>(numBuffer);
            uint userPointer = loader.ReadUInt32();
        }
Ejemplo n.º 13
0
        // ---- 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>();
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 15
0
        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Flags = loader.ReadEnum <CameraAnimFlags>(true);
            loader.Seek(2);
            FrameCount = loader.ReadInt32();
            byte numCurve = loader.ReadByte();

            loader.Seek(1);
            ushort numUserData = loader.ReadUInt16();

            BakedSize = loader.ReadUInt32();
            Name      = loader.LoadString();
            Curves    = loader.LoadList <AnimCurve>(numCurve);
            BaseData  = loader.LoadCustom(() => new CameraAnimData(loader));
            UserData  = loader.LoadDict <UserData>();
        }
Ejemplo n.º 16
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>();
            }
        }
Ejemplo n.º 17
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Dim      = loader.ReadEnum <GX2SurfaceDim>(true);
            Width    = loader.ReadUInt32();
            Height   = loader.ReadUInt32();
            Depth    = loader.ReadUInt32();
            MipCount = loader.ReadUInt32();
            Format   = loader.ReadEnum <GX2SurfaceFormat>(true);
            AAMode   = loader.ReadEnum <GX2AAMode>(true);
            Use      = loader.ReadEnum <GX2SurfaceUse>(true);
            uint sizData      = loader.ReadUInt32();
            uint imagePointer = loader.ReadUInt32();
            uint sizMipData   = loader.ReadUInt32();
            uint mipPointer   = loader.ReadUInt32();

            TileMode       = loader.ReadEnum <GX2TileMode>(true);
            Swizzle        = loader.ReadUInt32();
            Alignment      = loader.ReadUInt32();
            Pitch          = loader.ReadUInt32();
            MipOffsets     = loader.ReadUInt32s(13);
            ViewMipFirst   = loader.ReadUInt32();
            ViewMipCount   = loader.ReadUInt32();
            ViewSliceFirst = loader.ReadUInt32();
            ViewSliceCount = loader.ReadUInt32();
            CompSelR       = loader.ReadEnum <GX2CompSel>(true);
            CompSelG       = loader.ReadEnum <GX2CompSel>(true);
            CompSelB       = loader.ReadEnum <GX2CompSel>(true);
            CompSelA       = loader.ReadEnum <GX2CompSel>(true);
            Regs           = loader.ReadUInt32s(5);
            uint handle = loader.ReadUInt32();

            ArrayLength = loader.ReadUInt32(); // Possibly just a byte.
            Name        = loader.LoadString();
            Path        = loader.LoadString();
            Data        = loader.LoadCustom(() => loader.ReadBytes((int)sizData));
            MipData     = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData));
            UserData    = loader.LoadDict <UserData>();
            ushort numUserData = loader.ReadUInt16();

            loader.Seek(2);
        }
Ejemplo n.º 18
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name  = loader.LoadString();
            Path  = loader.LoadString();
            Flags = loader.ReadEnum <ShapeAnimFlags>(true);
            ushort numUserData = loader.ReadUInt16();

            FrameCount = loader.ReadInt32();
            ushort numVertexShapeAnim = loader.ReadUInt16();
            ushort numKeyShapeAnim    = loader.ReadUInt16();
            ushort numCurve           = loader.ReadUInt16();

            loader.Seek(2);
            BakedSize        = loader.ReadUInt32();
            BindModel        = loader.Load <Model>();
            BindIndices      = loader.LoadCustom(() => loader.ReadUInt16s(numVertexShapeAnim));
            VertexShapeAnims = loader.LoadList <VertexShapeAnim>(numVertexShapeAnim);
            UserData         = loader.LoadDict <UserData>();
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
 void IResData.Load(ResFileLoader loader)
 {
     loader.CheckSignature(_signature);
     if (loader.IsSwitch)
     {
         Switch.VertexBufferParser.Load((Switch.Core.ResFileSwitchLoader)loader, this);
     }
     else
     {
         byte   numVertexAttrib = loader.ReadByte();
         byte   numBuffer       = loader.ReadByte();
         ushort idx             = loader.ReadUInt16();
         uint   vertexCount     = loader.ReadUInt32();
         VertexSkinCount = loader.ReadByte();
         loader.Seek(3);
         uint ofsVertexAttribList = loader.ReadOffset(); // Only load dict.
         Attributes = loader.LoadDict <VertexAttrib>();
         Buffers    = loader.LoadList <Buffer>(numBuffer);
         uint userPointer = loader.ReadUInt32();
     }
 }
Ejemplo n.º 21
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>();
            }
        }
Ejemplo n.º 22
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name  = loader.LoadString();
            Path  = loader.LoadString();
            Flags = loader.ReadEnum <TexPatternAnimFlags>(true);
            ushort numUserData = loader.ReadUInt16();

            FrameCount = loader.ReadInt32();
            ushort numTextureRef = loader.ReadUInt16();
            ushort numMatAnim    = loader.ReadUInt16();
            int    numPatAnim    = loader.ReadInt32();
            int    numCurve      = loader.ReadInt32();

            BakedSize          = loader.ReadUInt32();
            BindModel          = loader.Load <Model>();
            BindIndices        = loader.LoadCustom(() => loader.ReadUInt16s(numMatAnim));
            TexPatternMatAnims = loader.LoadList <TexPatternMatAnim>(numMatAnim);
            TextureRefs        = loader.LoadDict <TextureRef>();
            UserData           = loader.LoadDict <UserData>();
        }
Ejemplo n.º 23
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Version   = loader.ReadUInt32();
            ByteOrder = loader.ReadEnum <ByteOrder>(true);
            ushort sizHeader = loader.ReadUInt16();
            uint   sizFile   = loader.ReadUInt32();

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

            Models              = loader.LoadDict <Model>();
            Textures            = loader.LoadDict <Texture>();
            SkeletalAnims       = loader.LoadDict <SkeletalAnim>();
            ShaderParamAnims    = loader.LoadDict <ShaderParamAnim>();
            ColorAnims          = loader.LoadDict <ShaderParamAnim>();
            TexSrtAnims         = loader.LoadDict <ShaderParamAnim>();
            TexPatternAnims     = loader.LoadDict <TexPatternAnim>();
            BoneVisibilityAnims = loader.LoadDict <VisibilityAnim>();
            MatVisibilityAnims  = loader.LoadDict <VisibilityAnim>();
            ShapeAnims          = loader.LoadDict <ShapeAnim>();
            SceneAnims          = loader.LoadDict <SceneAnim>();
            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();
        }
Ejemplo n.º 24
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.CameraAnimParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Flags = loader.ReadEnum <CameraAnimFlags>(false);
                loader.Seek(2);
                FrameCount = loader.ReadInt32();
                byte numCurve = loader.ReadByte();
                loader.Seek(1);
                ushort numUserData = loader.ReadUInt16();
                BakedSize = loader.ReadUInt32();
                Name      = loader.LoadString();
                Curves    = loader.LoadList <AnimCurve>(numCurve);
                BaseData  = loader.LoadCustom(() => new CameraAnimData(loader));
                UserData  = loader.LoadDict <UserData>();
            }
        }
Ejemplo n.º 25
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name  = loader.LoadString();
            Flags = loader.ReadEnum <ShapeFlags>(true);
            ushort idx = loader.ReadUInt16();

            MaterialIndex     = loader.ReadUInt16();
            BoneIndex         = loader.ReadUInt16();
            VertexBufferIndex = loader.ReadUInt16();
            ushort numSkinBoneIndex = loader.ReadUInt16();

            VertexSkinCount = loader.ReadByte();
            byte numMesh     = loader.ReadByte();
            byte numKeyShape = loader.ReadByte();

            TargetAttribCount = loader.ReadByte();
            ushort numSubMeshBoundingNodes = loader.ReadUInt16(); // Padding in engine.

            Radius          = loader.ReadSingle();
            VertexBuffer    = loader.Load <VertexBuffer>();
            Meshes          = loader.LoadList <Mesh>(numMesh);
            SkinBoneIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSkinBoneIndex));
            KeyShapes       = loader.LoadDict <KeyShape>();
            // TODO: At least BotW has more data following the Boundings, or that are no boundings at all.
            if (numSubMeshBoundingNodes == 0)
            {
                // Compute the count differently if the node count was padding.
                SubMeshBoundings = loader.LoadCustom(() => loader.ReadBoundings(Meshes[0].SubMeshes.Count + 1));
            }
            else
            {
                SubMeshBoundingNodes   = loader.LoadList <BoundingNode>(numSubMeshBoundingNodes);
                SubMeshBoundings       = loader.LoadCustom(() => loader.ReadBoundings(numSubMeshBoundingNodes));
                SubMeshBoundingIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSubMeshBoundingNodes));
            }
            uint userPointer = loader.ReadUInt32();
        }
Ejemplo n.º 26
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Dim      = loader.ReadEnum <GX2SurfaceDim>(true);
            Width    = loader.ReadUInt32();
            Height   = loader.ReadUInt32();
            Depth    = loader.ReadUInt32();
            MipCount = loader.ReadUInt32();
            Format   = loader.ReadEnum <GX2SurfaceFormat>(true);
            AAMode   = loader.ReadEnum <GX2AAMode>(true);
            Use      = loader.ReadEnum <GX2SurfaceUse>(true);
            uint sizData      = loader.ReadUInt32();
            uint imagePointer = loader.ReadUInt32();
            uint sizMipData   = loader.ReadUInt32();
            uint mipPointer   = loader.ReadUInt32();

            TileMode       = loader.ReadEnum <GX2TileMode>(true);
            Swizzle        = loader.ReadUInt32();
            Alignment      = loader.ReadUInt32();
            Pitch          = loader.ReadUInt32();
            MipOffsets     = loader.ReadUInt32s(13);
            ViewMipFirst   = loader.ReadUInt32();
            ViewMipCount   = loader.ReadUInt32();
            ViewSliceFirst = loader.ReadUInt32();
            ViewSliceCount = loader.ReadUInt32();
            CompSelR       = loader.ReadEnum <GX2CompSel>(true);
            CompSelG       = loader.ReadEnum <GX2CompSel>(true);
            CompSelB       = loader.ReadEnum <GX2CompSel>(true);
            CompSelA       = loader.ReadEnum <GX2CompSel>(true);
            Regs           = loader.ReadUInt32s(5);
            uint handle = loader.ReadUInt32();

            ArrayLength = loader.ReadByte(); // Possibly just a byte.
            loader.Seek(3, System.IO.SeekOrigin.Current);
            Name = loader.LoadString();
            Path = loader.LoadString();

            // Load texture data.
            bool?isMainTextureFile
                = loader.ResFile.Name.Contains(".Tex1") ? new bool?(true)
                : loader.ResFile.Name.Contains(".Tex2") ? new bool?(false)
                : null;

            switch (isMainTextureFile)
            {
            case true:
                Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData));
                loader.ReadOffset();     // MipData not used.
                break;

            case false:
                MipData = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData));
                loader.ReadOffset();     // Data not used.
                break;

            default:
                Data    = loader.LoadCustom(() => loader.ReadBytes((int)sizData));
                MipData = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData));
                break;
            }

            UserData = loader.LoadDict <UserData>();
            ushort numUserData = loader.ReadUInt16();

            loader.Seek(2);
        }
Ejemplo n.º 27
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();
                }

                Name         = loader.LoadString();
                Path         = loader.LoadString();
                BindSkeleton = loader.Load <Skeleton>();
                uint BindIndexArray      = loader.ReadOffset();
                uint BoneAnimArrayOffset = loader.ReadOffset();
                UserData = loader.LoadDictValues <UserData>();
                if (loader.ResFile.VersionMajor2 != 9)
                {
                    _flags = loader.ReadUInt32();
                }

                FrameCount = loader.ReadInt32();
                int numCurve = loader.ReadInt32();
                BakedSize = loader.ReadUInt32();
                ushort numBoneAnim = loader.ReadUInt16();
                ushort numUserData = loader.ReadUInt16();

                if (loader.ResFile.VersionMajor2 != 9)
                {
                    loader.ReadUInt32(); //Padding
                }
                BoneAnims   = loader.LoadList <BoneAnim>(numBoneAnim, BoneAnimArrayOffset).ToList();
                BindIndices = loader.LoadCustom(() => loader.ReadUInt16s(numBoneAnim), BindIndexArray);
            }
            else
            {
                ushort numBoneAnim = 0;
                if (loader.ResFile.Version >= 0x02040000)
                {
                    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));
                }
            }
        }
Ejemplo n.º 28
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            if (loader.IsSwitch)
            {
                Switch.ShapeParser.Read((Switch.Core.ResFileSwitchLoader)loader, this);
            }
            else
            {
                Name  = loader.LoadString();
                Flags = loader.ReadEnum <ShapeFlags>(true);
                ushort idx = loader.ReadUInt16();
                MaterialIndex     = loader.ReadUInt16();
                BoneIndex         = loader.ReadUInt16();
                VertexBufferIndex = loader.ReadUInt16();
                ushort numSkinBoneIndex = loader.ReadUInt16();
                VertexSkinCount = loader.ReadByte();
                byte numMesh     = loader.ReadByte();
                byte numKeyShape = loader.ReadByte();
                TargetAttribCount = loader.ReadByte();
                ushort numSubMeshBoundingNodes = loader.ReadUInt16(); // Padding in engine.

                if (loader.ResFile.Version >= 0x04050000)
                {
                    RadiusArray = loader.LoadCustom(() => loader.ReadSingles(numMesh))?.ToList();
                }
                else
                {
                    RadiusArray = loader.ReadSingles(1).ToList();
                }
                VertexBuffer    = loader.Load <VertexBuffer>();
                Meshes          = loader.LoadList <Mesh>(numMesh).ToList();
                SkinBoneIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSkinBoneIndex))?.ToList();
                KeyShapes       = loader.LoadDict <KeyShape>();

                // TODO: At least BotW has more data following the Boundings, or that are no boundings at all.
                if (numSubMeshBoundingNodes == 0)
                {
                    if (loader.ResFile.Version >= 0x04050000)
                    {
                        numSubMeshBoundingNodes = (ushort)(Meshes.Count + Meshes.Sum(x => x.SubMeshes.Count));
                    }
                    else
                    {
                        numSubMeshBoundingNodes = (ushort)(1 + Meshes[0].SubMeshes.Count + 1);
                    }
                    SubMeshBoundings = loader.LoadCustom(() => loader.ReadBoundings(numSubMeshBoundingNodes))?.ToList();
                }
                else
                {
                    SubMeshBoundingNodes   = loader.LoadList <BoundingNode>(numSubMeshBoundingNodes)?.ToList();
                    SubMeshBoundings       = loader.LoadCustom(() => loader.ReadBoundings(numSubMeshBoundingNodes))?.ToList();
                    SubMeshBoundingIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSubMeshBoundingNodes))?.ToList();
                }

                if (SubMeshBoundingNodes == null)
                {
                    SubMeshBoundingNodes = new List <BoundingNode>();
                }
                if (SubMeshBoundings == null)
                {
                    SubMeshBoundings = new List <Bounding>();
                }
                if (SubMeshBoundingIndices == null)
                {
                    SubMeshBoundingIndices = new List <ushort>();
                }

                uint userPointer = loader.ReadUInt32();
            }
        }
Ejemplo n.º 29
0
        // ---- METHODS ------------------------------------------------------------------------------------------------

        void IResData.Load(ResFileLoader loader)
        {
            loader.CheckSignature(_signature);
            Name  = loader.LoadString();
            Path  = loader.LoadString();
            Flags = loader.ReadEnum <TexPatternAnimFlags>(true);
            ushort numMatAnim    = 0;
            ushort numTextureRef = 0;

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


            BindModel          = loader.Load <Model>();
            BindIndices        = loader.LoadCustom(() => loader.ReadUInt16s(numMatAnim));
            TexPatternMatAnims = loader.LoadList <TexPatternMatAnim>(numMatAnim);
            if (loader.ResFile.Version >= 0x03040000)
            {
                TextureRefs = loader.LoadDict <TextureRef>();
            }
            else
            {
                int TextureCount = 0;
                foreach (var patternAnim in TexPatternMatAnims)
                {
                    foreach (var curve in patternAnim.Curves)
                    {
                        List <uint> frames = new List <uint>();
                        foreach (float key in curve.Keys)
                        {
                            //      Console.WriteLine((uint)key);
                            frames.Add((uint)key);
                        }
                        TextureCount = (short)frames.Max();

                        /*
                         *    for (int i = 0; i < (ushort)curve.Frames.Length; i++)
                         *    {
                         *        if (curve.Scale != 0)
                         *        {
                         *            int test = (int)curve.Keys[i, 0];
                         *            float key = curve.Offset + test * curve.Scale;
                         *            frames.Add((int)key);
                         *        }
                         *        else
                         *        {
                         *            float test = curve.Keys[i, 0];
                         *            int key = curve.Offset + (int)test;
                         *            frames.Add((int)key);
                         *
                         *            int testCeiling = (int)Math.Ceiling(test);
                         *            int testFloor = (int)Math.Floor(test);
                         *            int testRound = (int)Math.Round(test);
                         *
                         *            Console.WriteLine("convert int = {0}", (Decimal10x5)test);
                         *        }
                         *    }*/
                    }
                }
                Console.WriteLine(Name + " Tex Total " + (TextureCount + 1));

                TextureRefNames = loader.LoadList <TextureRef>(numTextureRef);
            }
            UserData = loader.LoadDict <UserData>();
        }