void OnStart() { asd::Engine::GetFile()->AddRootDirectory(asd::ToAString("Data/Texture.pack").c_str()); for (auto loop = 0; loop < 2; loop++) { //普通に読み込んだバイナリ BinaryReader reader; auto data = GetBinaryData(asd::ToAString("Data/Texture/Surface/Tile_Normal.png")); reader.ReadIn(data.begin(), data.end()); //ファイル機能で読み込んだバイナリ auto staticFile = asd::Engine::GetFile()->CreateStaticFile(asd::ToAString("Surface/Tile_Normal.png").c_str()); auto staticFileData = staticFile->GetBuffer(); int cnt = 0; while (!reader.IsEmpty()) { int8_t byteFromRaw = reader.Get<int8_t>(); int8_t byteFromFile = staticFileData[cnt++]; ASSERT_EQ(byteFromRaw, byteFromFile); } ASSERT_EQ(cnt, staticFileData.size()); } }
void OnStart() { //普通に読み込んだバイナリ BinaryReader reader; auto data = GetBinaryData(asd::ToAString("Data/Texture/Surface/Tile_Normal.png")); reader.ReadIn(data.begin(), data.end()); //ファイル機能で読み込んだバイナリ asd::Engine::GetFile()->AddRootPackage(asd::ToAString("Data/Texture.pack").c_str()); auto streamFile = asd::Engine::GetFile()->CreateStreamFile(asd::ToAString("Surface/Tile_Normal.png").c_str()); std::vector<uint8_t> buffer; streamFile->Read(buffer, streamFile->GetSize()); int cnt = 0; while (!reader.IsEmpty()) { auto byteFromRaw = reader.Get<uint8_t>(); auto byteFromFile = buffer[cnt++]; ASSERT_EQ(byteFromRaw, byteFromFile); } ASSERT_EQ(cnt, buffer.size()); }
AffLoader::AffLoader(std::vector<uint8_t> &data) { BinaryReader reader; reader.ReadIn(data.begin(), data.end()); auto header = AffHeader::Get(reader); auto table = AffIndexTable::Get(reader); auto indexes = table.GetIndexes(); auto fontNum = header.GetFontCount(); for (int16_t i = 0; i < fontNum; ++i) { auto charactor = distance(indexes.begin(), find(indexes.begin(), indexes.end(), i)); result[charactor] = GlyphData::Get(reader, charactor); } }
bool Model_IO::Load(const std::vector<uint8_t>& data, const achar* path) { Meshes.clear(); BinaryReader reader; reader.ReadIn(data.begin(), data.end()); // ヘッダーチェック uint8_t header_true [] = "MDL"; for (int32_t i = 0; i < 4; i++) { auto h = reader.Get<uint8_t>(); if (header_true[i] != h) return false; } // バージョン int32_t version = reader.Get<int32_t>(); // ボーン LoadDeformer(Deformer_, reader, path, version); // メッシュ LoadMeshes(Meshes, reader, path); // アニメーション int32_t sourceCount = reader.Get<int32_t>(); AnimationSources.resize(sourceCount); for (int32_t i = 0; i < sourceCount; i++) { LoadAnimationSource(AnimationSources[i], reader, path); } int32_t clipCount = reader.Get<int32_t>(); AnimationClips.resize(clipCount); for (int32_t i = 0; i < clipCount; i++) { LoadAnimationClip(AnimationClips[i], reader, path); } return true; }