Exemplo n.º 1
0
        public static Formats.Meshes.MeshObject ParseMeshObject(this SsbhParser parser)
        {
            var result = new Formats.Meshes.MeshObject();

            result.Name                         = parser.ReadOffsetReadString();
            result.SubIndex                     = parser.ReadInt64();
            result.ParentBoneName               = parser.ReadOffsetReadString();
            result.VertexCount                  = parser.ReadInt32();
            result.IndexCount                   = parser.ReadInt32();
            result.Unk2                         = parser.ReadUInt32();
            result.VertexOffset                 = parser.ReadInt32();
            result.VertexOffset2                = parser.ReadInt32();
            result.FinalBufferOffset            = parser.ReadInt32();
            result.BufferIndex                  = parser.ReadInt32();
            result.Stride                       = parser.ReadInt32();
            result.Stride2                      = parser.ReadInt32();
            result.Unk6                         = parser.ReadInt32();
            result.Unk7                         = parser.ReadInt32();
            result.ElementOffset                = parser.ReadUInt32();
            result.Unk8                         = parser.ReadInt32();
            result.DrawElementType              = (Formats.Meshes.DrawElementType)parser.ReadInt32();
            result.RiggingType                  = (Formats.Meshes.RiggingType)parser.ReadInt32();
            result.Unk11                        = parser.ReadInt32();
            result.Unk12                        = parser.ReadInt32();
            result.BoundingSphereCenter         = parser.ReadVector3();
            result.BoundingSphereRadius         = parser.ReadSingle();
            result.BoundingBoxMin               = parser.ReadVector3();
            result.BoundingBoxMax               = parser.ReadVector3();
            result.OrientedBoundingBoxCenter    = parser.ReadVector3();
            result.OrientedBoundingBoxTransform = parser.ReadMatrix3x3();
            result.OrientedBoundingBoxSize      = parser.ReadVector3();
            {
                // TODO: Extract this code to a method?
                long absoluteOffset   = parser.ReadRelativeGetAbsoluteOffset();
                long elementCount     = parser.ReadInt64();
                long previousPosition = parser.Position;
                parser.Seek(absoluteOffset);


                result.Attributes = new Formats.Meshes.MeshAttribute[elementCount];
                for (int i = 0; i < elementCount; i++)
                {
                    result.Attributes[i] = parser.ParseMeshAttribute();
                }

                parser.Seek(previousPosition);
            }
            return(result);
        }