public Extension(SectionHeader header, Stream stream) : base(header, stream) { var sections = new List <SectionData>(); while (stream.Position < stream.Length) { sections.Add(ReadSection <SectionData>(header.GetParent())); } Sections = sections.ToArray(); }
public Skin(SectionHeader header, Stream stream) : base(header, stream) { var reader = new BinaryReader(stream); Int32 boneCount = (Int32)reader.ReadByte(); Int32 boneIdCount = (Int32)reader.ReadByte(); UInt16 weightsPerVertex = reader.ReadUInt16(); byte[] boneIds = reader.ReadBytes(boneIdCount); var vertexCount = header.GetParent <Geometry>().VertexCount; VertexBoneIndices = new SkinBoneIndices[vertexCount]; VertexBoneWeights = new SkinBoneWeights[vertexCount]; for (int i = 0; i < vertexCount; ++i) { VertexBoneIndices[i] = new SkinBoneIndices(reader); } for (int i = 0; i < vertexCount; ++i) { VertexBoneWeights[i] = new SkinBoneWeights(reader); } SkinToBoneMatrices = new Matrix4x4[boneCount]; for (int i = 0; i < boneCount; ++i) { if (boneIdCount == 0) { reader.BaseStream.Seek(4, SeekOrigin.Current); } SkinToBoneMatrices[i] = new Matrix4x4(reader); } UInt32 boneLimit = reader.ReadUInt32(); UInt32 meshCount = reader.ReadUInt32(); UInt32 RLE = reader.ReadUInt32(); if (meshCount > 0) { MeshBoneRemapIndices = reader.ReadBytes((Int32)(boneCount + 2 * (RLE + meshCount))); } }