public override void Read(AssetReader reader) { base.Read(reader); if (IsReadLODData(reader.Version)) { m_LODData = reader.ReadArray <LOD>(); } if (IsReadUse16bitIndices(reader.Version)) { Use16bitIndices = reader.ReadInt32() > 0; } if (IsReadIndexBuffer(reader.Version)) { if (IsReadIndexBufferFirst(reader.Version)) { m_indexBuffer = reader.ReadByteArray(); reader.AlignStream(AlignType.Align4); } } if (IsReadSubMeshes(reader.Version)) { m_subMeshes = reader.ReadArray <SubMesh>(); } if (IsReadBlendShapes(reader.Version)) { Shapes.Read(reader); } if (IsReadBindPosesFirst(reader.Version)) { m_bindPoses = reader.ReadArray <Matrix4x4f>(); } if (IsReadBoneNameHashes(reader.Version)) { m_boneNameHashes = reader.ReadUInt32Array(); RootBoneNameHash = reader.ReadUInt32(); } if (IsReadMeshCompression(reader.Version)) { MeshCompression = (MeshCompression)reader.ReadByte(); } if (IsReadStreamCompression(reader.Version)) { StreamCompression = reader.ReadByte(); } if (IsReadIsReadable(reader.Version)) { IsReadable = reader.ReadBoolean(); KeepVertices = reader.ReadBoolean(); KeepIndices = reader.ReadBoolean(); } if (IsAlign(reader.Version)) { reader.AlignStream(AlignType.Align4); } if (IsReadIndexFormat(reader.Version)) { if (IsReadIndexFormatCondition(reader.Version)) { if (MeshCompression == 0) { IndexFormat = reader.ReadInt32(); } } else { IndexFormat = reader.ReadInt32(); } } if (IsReadIndexBuffer(reader.Version)) { if (!IsReadIndexBufferFirst(reader.Version)) { m_indexBuffer = reader.ReadByteArray(); reader.AlignStream(AlignType.Align4); } } if (IsReadVertices(reader.Version)) { if (IsReadVertexData(reader.Version)) { if (MeshCompression != 0) { m_vertices = reader.ReadArray <Vector3f>(); } } else { m_vertices = reader.ReadArray <Vector3f>(); } } if (IsReadSkin(reader.Version)) { m_skin = reader.ReadArray <BoneWeights4>(); } if (IsReadBindPoses(reader.Version)) { if (!IsReadBindPosesFirst(reader.Version)) { m_bindPoses = reader.ReadArray <Matrix4x4f>(); } } if (IsReadVertexData(reader.Version)) { if (IsReadOnlyVertexData(reader.Version)) { VertexData.Read(reader); } else { if (MeshCompression == 0) { VertexData.Read(reader); } else { m_UV = reader.ReadArray <Vector2f>(); m_UV1 = reader.ReadArray <Vector2f>(); m_tangents = reader.ReadArray <Vector4f>(); m_normals = reader.ReadArray <Vector3f>(); m_colors = reader.ReadArray <ColorRGBA32>(); } } } else { m_UV = reader.ReadArray <Vector2f>(); if (IsReadUV1(reader.Version)) { m_UV1 = reader.ReadArray <Vector2f>(); } if (IsReadTangentSpace(reader.Version)) { m_tangentSpace = reader.ReadArray <Tangent>(); } else { m_tangents = reader.ReadArray <Vector4f>(); m_normals = reader.ReadArray <Vector3f>(); } } if (IsReadAlign(reader.Version)) { reader.AlignStream(AlignType.Align4); } if (IsReadCompressedMesh(reader.Version)) { CompressedMesh.Read(reader); } LocalAABB.Read(reader); if (IsReadColors(reader.Version)) { if (!IsReadVertexData(reader.Version)) { m_colors = reader.ReadArray <ColorRGBA32>(); } } if (IsReadCollisionTriangles(reader.Version)) { m_collisionTriangles = reader.ReadUInt32Array(); CollisionVertexCount = reader.ReadInt32(); } if (IsReadMeshUsageFlags(reader.Version)) { MeshUsageFlags = reader.ReadInt32(); } if (IsReadCollision(reader.Version)) { CollisionData.Read(reader); } if (IsReadMeshMetrics(reader.Version)) { m_meshMetrics = new float[2]; m_meshMetrics[0] = reader.ReadSingle(); m_meshMetrics[1] = reader.ReadSingle(); } }
public override void Read(EndianStream stream) { base.Read(stream); if (IsReadIndicesUsage) { IsUse16bitIndices = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); } if (IsIndexBufferFirst) { m_indexBuffer = stream.ReadByteArray(); stream.AlignStream(AlignType.Align4); } m_subMeshes = stream.ReadArray(() => new SubMesh(AssetsFile)); if (IsReadBlendShapes) { Shapes.Read(stream); if (IsBindPosesFirst) { m_bindPoses = stream.ReadArray <Matrix4x4f>(); m_boneNameHashes = stream.ReadUInt32Array(); RootBoneNameHash = stream.ReadUInt32(); } } if (!IsIndexBufferFirst) { MeshCompression = stream.ReadByte(); if (IsReadBoolFlags) { if (IsReadStreamCompression) { StreamCompression = stream.ReadByte(); } IsReadable = stream.ReadBoolean(); KeepVertices = stream.ReadBoolean(); KeepIndices = stream.ReadBoolean(); } stream.AlignStream(AlignType.Align4); if (IsReadIndexFormat) { IndexFormat = stream.ReadInt32(); } m_indexBuffer = stream.ReadByteArray(); stream.AlignStream(AlignType.Align4); } if (IsReadVertices) { m_vertices = stream.ReadArray <Vector3f>(); m_bindPoses = stream.ReadArray <Matrix4x4f>(); #warning TODO: throw new System.NotImplementedException(); } else { m_skin = stream.ReadArray <BoneWeights4>(); stream.AlignStream(AlignType.Align4); if (!IsBindPosesFirst) { m_bindPoses = stream.ReadArray <Matrix4x4f>(); } VertexData = new VertexData(AssetsFile, MeshCompression); VertexData.Read(stream); CompressedMesh.Read(stream); if (IsReadLocalAABB) { LocalAABB.Read(stream); } MeshUsageFlags = stream.ReadInt32(); if (IsReadCollision) { CollisionData.Read(stream); } } }