public Mesh(AssetCabinet file) : this(file, 0, UnityClassID.Mesh, UnityClassID.Mesh) { file.ReplaceSubfile(-1, this, null); m_Shapes = new BlendShapeData(); m_IsReadable = true; m_KeepVertices = true; m_KeepIndices = true; m_CompressedMesh = new CompressedMesh(); m_LocalAABB = new AABB(); m_MeshUsageFlags = 1; }
public Mesh(AssetCabinet file) : this(file, 0, UnityClassID.Mesh, UnityClassID.Mesh) { file.ReplaceSubfile(-1, this, null); m_Shapes = new BlendShapeData(); if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0) { m_StreamCompression = 1; } m_IsReadable = true; m_KeepVertices = true; m_KeepIndices = true; m_CompressedMesh = new CompressedMesh(file.VersionNumber); m_LocalAABB = new AABB(); m_MeshUsageFlags = 1; if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0) { m_BakedConvexCollisionMesh = new byte[0]; m_BakedTriangleCollisionMesh = new byte[0]; } }
public void LoadFrom(Stream stream) { BinaryReader reader = new BinaryReader(stream); m_Name = reader.ReadNameA4(); int numSubMeshes = reader.ReadInt32(); m_SubMeshes = new List<SubMesh>(numSubMeshes); for (int i = 0; i < numSubMeshes; i++) { m_SubMeshes.Add(new SubMesh(stream)); } m_Shapes = new BlendShapeData(stream); int numBones = reader.ReadInt32(); m_BindPose = new List<Matrix>(numBones); for (int i = 0; i < numBones; i++) { m_BindPose.Add(reader.ReadMatrix()); } int numHashes = reader.ReadInt32(); m_BoneNameHashes = new List<uint>(numHashes); for (int i = 0; i < numHashes; i++) { m_BoneNameHashes.Add(reader.ReadUInt32()); } m_RootBoneNameHash = reader.ReadUInt32(); m_MeshCompression = reader.ReadByte(); m_StreamCompression = reader.ReadByte(); m_IsReadable = reader.ReadBoolean(); m_KeepVertices = reader.ReadBoolean(); m_KeepIndices = reader.ReadBoolean(); reader.BaseStream.Position += 3; int numIndexBytes = reader.ReadInt32(); m_IndexBuffer = reader.ReadBytes(numIndexBytes); if ((numIndexBytes & 3) > 0) { reader.BaseStream.Position += 4 - (numIndexBytes & 3); } int numInfluences = reader.ReadInt32(); m_Skin = new List<BoneInfluence>(numInfluences); for (int i = 0; i < numInfluences; i++) { m_Skin.Add(new BoneInfluence(stream)); } m_VertexData = new VertexData(stream); m_CompressedMesh = new CompressedMesh(stream); m_LocalAABB = new AABB(stream); m_MeshUsageFlags = reader.ReadInt32(); }
public void LoadFrom(Stream stream) { BinaryReader reader = new BinaryReader(stream); m_Name = reader.ReadNameA4(); int numSubMeshes = reader.ReadInt32(); m_SubMeshes = new List <SubMesh>(numSubMeshes); for (int i = 0; i < numSubMeshes; i++) { m_SubMeshes.Add(new SubMesh(stream)); } m_Shapes = new BlendShapeData(stream); int numBones = reader.ReadInt32(); m_BindPose = new List <Matrix>(numBones); for (int i = 0; i < numBones; i++) { m_BindPose.Add(reader.ReadMatrix()); } int numHashes = reader.ReadInt32(); m_BoneNameHashes = new List <uint>(numHashes); for (int i = 0; i < numHashes; i++) { m_BoneNameHashes.Add(reader.ReadUInt32()); } m_RootBoneNameHash = reader.ReadUInt32(); m_MeshCompression = reader.ReadByte(); m_StreamCompression = reader.ReadByte(); m_IsReadable = reader.ReadBoolean(); m_KeepVertices = reader.ReadBoolean(); m_KeepIndices = reader.ReadBoolean(); reader.BaseStream.Position += 3; int numIndexBytes = reader.ReadInt32(); m_IndexBuffer = reader.ReadBytes(numIndexBytes); if ((numIndexBytes & 3) > 0) { reader.BaseStream.Position += 4 - (numIndexBytes & 3); } int numInfluences = reader.ReadInt32(); m_Skin = new List <BoneInfluence>(numInfluences); for (int i = 0; i < numInfluences; i++) { m_Skin.Add(new BoneInfluence(stream)); } m_VertexData = new VertexData(stream); m_CompressedMesh = new CompressedMesh(stream); m_LocalAABB = new AABB(stream); m_MeshUsageFlags = reader.ReadInt32(); }
public void LoadFrom(Stream stream) { BinaryReader reader = new BinaryReader(stream); m_Name = reader.ReadNameA4U8(); int numSubMeshes = reader.ReadInt32(); m_SubMeshes = new List <SubMesh>(numSubMeshes); for (int i = 0; i < numSubMeshes; i++) { m_SubMeshes.Add(new SubMesh(stream)); } m_Shapes = new BlendShapeData(stream); int numBones = reader.ReadInt32(); m_BindPose = new List <Matrix>(numBones); for (int i = 0; i < numBones; i++) { m_BindPose.Add(reader.ReadMatrix()); } int numHashes = reader.ReadInt32(); m_BoneNameHashes = new List <uint>(numHashes); for (int i = 0; i < numHashes; i++) { m_BoneNameHashes.Add(reader.ReadUInt32()); } m_RootBoneNameHash = reader.ReadUInt32(); m_MeshCompression = reader.ReadByte(); if (file.VersionNumber < AssetCabinet.VERSION_5_0_0) { m_StreamCompression = reader.ReadByte(); } else { m_StreamCompression = 1; } m_IsReadable = reader.ReadBoolean(); m_KeepVertices = reader.ReadBoolean(); m_KeepIndices = reader.ReadBoolean(); if (file.VersionNumber < AssetCabinet.VERSION_5_0_0) { reader.BaseStream.Position += 3; } int numIndexBytes = reader.ReadInt32(); m_IndexBuffer = reader.ReadBytes(numIndexBytes); if ((numIndexBytes & 3) > 0) { reader.BaseStream.Position += 4 - (numIndexBytes & 3); } int numInfluences = reader.ReadInt32(); m_Skin = new List <BoneInfluence>(numInfluences); for (int i = 0; i < numInfluences; i++) { m_Skin.Add(new BoneInfluence(stream)); } m_VertexData = new VertexData(stream, m_StreamCompression > 0 || file.VersionNumber >= AssetCabinet.VERSION_5_0_0); m_CompressedMesh = new CompressedMesh(stream, file.VersionNumber); m_LocalAABB = new AABB(stream); m_MeshUsageFlags = reader.ReadInt32(); if (file.VersionNumber >= AssetCabinet.VERSION_5_0_0) { int numMeshBytes = reader.ReadInt32(); m_BakedConvexCollisionMesh = reader.ReadBytes(numMeshBytes); if ((numMeshBytes & 3) > 0) { stream.Position += 4 - (numMeshBytes & 3); } numMeshBytes = reader.ReadInt32(); m_BakedTriangleCollisionMesh = reader.ReadBytes(numMeshBytes); if ((numMeshBytes & 3) > 0) { stream.Position += 4 - (numMeshBytes & 3); } } }