// ---- 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();
        }
Beispiel #2
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();
            }
        }