diff --git a/docs/eu07m-format.md b/docs/eu07m-format.md index 82bea787c..b8075d7a5 100644 --- a/docs/eu07m-format.md +++ b/docs/eu07m-format.md @@ -1,4 +1,4 @@ -# The EU07M model format (`.eu07m`) +# The EU07M model format (`.r3a`) The successor of E3D: a fully binary model format. A file is read with almost no processing, straight into the buffers of OpenGL 4.6 and Vulkan 1.4. It carries TRS nodes, skinning, typed components and metadata of nodes and vertex groups, and it extends without @@ -196,7 +196,7 @@ of the game, the folders of a family are 7% to 38% of their size with their shar in each of those streams in that order, then its indices. Its id is 128 bits: two FNV-1a 64 of its bytes, with the seeds `0xcbf29ce484222325` and `0x84222325cbf29ce4`. A primitive can be kept in the store only when its vertex and index ranges are its own. -- **The store** of the family is `geometry.eu07mpack` in the folder of the models: a 32 B header (magic `EU7P`, `u16` major 1, +- **The store** of the family is `geometry.r3p` in the folder of the models: a 32 B header (magic `EU7P`, `u16` major 1, `u16` minor 0, `u32` block count, `u32` flags, `u64` offset of the index, 8 B of zeroes), the blocks one after another, each packed with zstd when it saves an eighth, and the index: entries of 40 B (`u64 × 2` id, `u64` offset, `u32` size in the file, `u32` size unpacked, `u32` flags (0x1 zstd), `u32` 0), sorted by the id. @@ -260,7 +260,7 @@ component; `0xFFFFFFFF` = none. ## Conversion from E3D and T3D -`eu07 -eu07m convert [dynamic]` loads the model with the existing loader (as `-e3d` does) and writes +`eu07 -eu07m convert [dynamic]` loads the model with the existing loader (as `-e3d` does) and writes it as EU07M: - A submodel becomes a node. The order of the children and the names stay, so `GetFromName`, the `.mmd` and the events work as @@ -275,13 +275,13 @@ it as EU07M: game makes of it, not from its `.t3d`. - A replaceable skin `-k` drawn in the translucent pass (bit k−1 of the E3D flags) has the `translucent` flag in `MATL`. -The other commands: `eu07 -eu07m dump ` (the content as text, clips included) and `eu07 -eu07m validate ` +The other commands: `eu07 -eu07m dump ` (the content as text, clips included) and `eu07 -eu07m validate ` (a check of the file with the hash of its content). ## In the game -With `modelformat eu07m` in `eu07.ini`, a model with an `.eu07m` file beside its `.e3d` / `.t3d` (or alone) is loaded from it -(`TModel3d::LoadFromEU07M`). The default `modelformat legacy` leaves `.eu07m` files alone. +With `modelformat r3a` in `eu07.ini`, a model with an `.r3a` file beside its `.e3d` / `.t3d` (or alone) is loaded from it +(`TModel3d::LoadFromEU07M`). The default `modelformat legacy` leaves `.r3a` files alone. - **The Vulkan renderer** keeps the streams of an EU07M model as they lie in the file: positions (12 B), attributes from `VATT` (16 B), user data and indices, each in a buffer of its own in the bank (`vertex_kind::scene_compact`). The shaders read the @@ -397,5 +397,5 @@ own. It applies to EU07M and E3D models alike. ## Backward compatibility -E3D and T3D are read as before. An `.eu07m` file is loaded only when it exists, behind the switch `modelformat eu07m` in -`eu07.ini`. The current release doesn't read `.eu07m`. +E3D and T3D are read as before. An `.r3a` file is loaded only when it exists, behind the switch `modelformat r3a` in +`eu07.ini`. The current release doesn't read `.r3a`. diff --git a/model/MdlMngr.cpp b/model/MdlMngr.cpp index 4ced75029..ce3198d1a 100644 --- a/model/MdlMngr.cpp +++ b/model/MdlMngr.cpp @@ -167,8 +167,8 @@ TModelsManager::find_on_disk( std::string const &Name ) { std::vector extensions { { ".e3d" }, { ".t3d" } }; if( Global.modelformat_eu07m ) { - // a model may come as an .eu07m alone - extensions.emplace_back( ".eu07m" ); + // a model may come as an .r3a alone + extensions.emplace_back( ".r3a" ); } for( auto const &extension : extensions ) { diff --git a/model/Model3d.cpp b/model/Model3d.cpp index f5dbef139..414f900b1 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -1831,7 +1831,7 @@ glm::vec3 TSubModel::offset(float const Geometrytestoffsetthreshold) const namespace { -// modelformat eu07m: an .eu07m older than the .e3d / .t3d it was made from isn't used, the model was changed after it was +// modelformat r3a: an .r3a older than the .e3d / .t3d it was made from isn't used, the model was changed after it was // converted (the hash of the source in its header would need the source read whole to be compared) bool eu07m_up_to_date(std::string const &Eu07m, std::initializer_list const Sources) { @@ -1953,10 +1953,10 @@ bool TModel3d::LoadFromFile(std::string const &FileName, bool dynamic) Init(); assign_lod_ranges(Root, name); } - else if (auto const eu07mfile{Global.modelformat_eu07m ? FileCased(name + ".eu07m") : std::string{}}; + else if (auto const eu07mfile{Global.modelformat_eu07m ? FileCased(name + ".r3a") : std::string{}}; (false == eu07mfile.empty()) && eu07m_up_to_date(eu07mfile, {binaryfile, textfile}) && LoadFromEU07M(eu07mfile, dynamic)) { - // modelformat eu07m: the .eu07m made from the model takes its place; one which doesn't load leaves the .e3d / .t3d to go on + // modelformat r3a: the .r3a made from the model takes its place; one which doesn't load leaves the .e3d / .t3d to go on asBinary = ""; Init(); assign_lod_ranges(Root, name); diff --git a/model/eu07m/eu07m_convert.cpp b/model/eu07m/eu07m_convert.cpp index 6b5b358a4..32ad96609 100644 --- a/model/eu07m/eu07m_convert.cpp +++ b/model/eu07m/eu07m_convert.cpp @@ -317,7 +317,7 @@ bool load_source(std::string const &Input, bool const Dynamic, TModel3d &Source, auto const start{std::chrono::steady_clock::now()}; if (extension_of(Input) == ".e3d") Source.LoadFromBinFile(Input, Dynamic); - else if (extension_of(Input) == ".eu07m") + else if (extension_of(Input) == ".r3a") Source.LoadFromEU07M(Input, Dynamic); else Source.LoadFromTextFile(Input, Dynamic); @@ -478,7 +478,7 @@ void model_diff::geometry(TSubModel const &Left, TSubModel const &Right) { int command_diff(int const Argc, char *Argv[]) { if (Argc < 5) { - std::cerr << "usage: -eu07m diff [dynamic 0|1]\n"; + std::cerr << "usage: -eu07m diff [dynamic 0|1]\n"; return 2; } if (false == start_tools(Argc, Argv)) @@ -503,7 +503,7 @@ int command_diff(int const Argc, char *Argv[]) { int command_convert(int const Argc, char *Argv[]) { if (Argc < 5) { - std::cerr << "usage: -eu07m convert [dynamic 0|1] [convertmodels flags]\n"; + std::cerr << "usage: -eu07m convert [dynamic 0|1] [convertmodels flags]\n"; return 2; } std::string const input{Argv[3]}; @@ -545,7 +545,7 @@ int command_convert(int const Argc, char *Argv[]) { int command_read(int const Argc, char *Argv[], bool const Dump) { if (Argc < 4) { - std::cerr << std::format("usage: -eu07m {} \n", Dump ? "dump" : "validate"); + std::cerr << std::format("usage: -eu07m {} \n", Dump ? "dump" : "validate"); return 2; } auto const file{read_whole_file(Argv[3])}; diff --git a/model/eu07m/eu07m_format.h b/model/eu07m/eu07m_format.h index 3cc4a4bf5..bfd2c605c 100644 --- a/model/eu07m/eu07m_format.h +++ b/model/eu07m/eu07m_format.h @@ -377,7 +377,7 @@ struct packed_rotation { }; static_assert(sizeof(packed_rotation) == 8); -// the geometry of a primitive kept in the geometry store of the family of the model (geometry.eu07mpack beside the file) instead of +// the geometry of a primitive kept in the geometry store of the family of the model (geometry.r3p beside the file) instead of // in the file: its vertices in every vertex stream of the file and its indices. the writer leaves its ranges out of the streams of the // file, and the reader puts the block of the store back in their place, so the model in memory always has its whole streams struct geometry_reference_record { diff --git a/model/eu07m/eu07m_pack.cpp b/model/eu07m/eu07m_pack.cpp index 3e366e5c3..cae70653e 100644 --- a/model/eu07m/eu07m_pack.cpp +++ b/model/eu07m/eu07m_pack.cpp @@ -73,7 +73,7 @@ bool write_file(std::filesystem::path const &Path, std::span Da bool is_model(std::filesystem::directory_entry const &Entry) { auto extension{Entry.path().extension().string()}; std::ranges::transform(extension, extension.begin(), [](unsigned char const Letter) { return static_cast(std::tolower(Letter)); }); - return Entry.is_regular_file() && extension == ".eu07m"; + return Entry.is_regular_file() && extension == ".r3a"; } // the models of the folder read whole, with the store there is; false when one can't be read diff --git a/model/eu07m/eu07m_pack.h b/model/eu07m/eu07m_pack.h index 232372857..9851988fa 100644 --- a/model/eu07m/eu07m_pack.h +++ b/model/eu07m/eu07m_pack.h @@ -28,7 +28,7 @@ struct pack_result { }; // the geometry of the primitives of at least MinBytes which occur more than once in the models of the folder moved to its store -// (geometry.eu07mpack), made anew from all of them; the models are written again referring to it. every model is read back and +// (geometry.r3p), made anew from all of them; the models are written again referring to it. every model is read back and // compared with what it was before it's replaced. what was done goes to Log pack_result pack_folder(std::filesystem::path const &Folder, std::size_t MinBytes, std::ostream &Log); // the models of the folder written again with their whole geometry; the store is left for the user to delete diff --git a/model/eu07m/eu07m_store.h b/model/eu07m/eu07m_store.h index b094d090a..f06f4ba97 100644 --- a/model/eu07m/eu07m_store.h +++ b/model/eu07m/eu07m_store.h @@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/. #pragma once // the geometry shared by the models of a family (the variants of a vehicle): blocks of the geometry of primitives kept once in the -// store of the folder (geometry.eu07mpack) and referred to by the models (GREF) instead of being repeated in each of them +// store of the folder (geometry.r3p) and referred to by the models (GREF) instead of being repeated in each of them #include "model/eu07m/eu07m_model.h" @@ -26,7 +26,7 @@ namespace eu07m { using block_id = std::array; // the name of the store in the folder of the models -constexpr char const *store_file_name{"geometry.eu07mpack"}; +constexpr char const *store_file_name{"geometry.r3p"}; // the streams a block carries, in this order after its header namespace block_streams { diff --git a/tests/unit/test_gref.cpp b/tests/unit/test_gref.cpp index f70fc3150..6662e1db6 100644 --- a/tests/unit/test_gref.cpp +++ b/tests/unit/test_gref.cpp @@ -177,9 +177,9 @@ TEST_CASE("gref: a folder packed and unpacked") { auto const a{variant(40, 0.f, 1.f)}; auto const b{variant(40, 0.f, 2.f)}; auto const c{variant(40, 5.f, 3.f)}; - save(folder / "a.eu07m", eu07m::write(a)); - save(folder / "b.eu07m", eu07m::write(b)); - save(folder / "c.eu07m", eu07m::write(c)); + save(folder / "a.r3a", eu07m::write(a)); + save(folder / "b.r3a", eu07m::write(b)); + save(folder / "c.r3a", eu07m::write(c)); std::ostringstream log; auto const packed{eu07m::pack_folder(folder, 4096, log)}; @@ -195,7 +195,7 @@ TEST_CASE("gref: a folder packed and unpacked") { REQUIRE(store.open(folder / eu07m::store_file_name, error)); eu07m::read_options options; options.blocks = memory_source(store); - for (auto const &[name, original] : {std::pair{"a.eu07m", &a}, std::pair{"b.eu07m", &b}, std::pair{"c.eu07m", &c}}) { + for (auto const &[name, original] : {std::pair{"a.r3a", &a}, std::pair{"b.r3a", &b}, std::pair{"c.r3a", &c}}) { eu07m::model read; REQUIRE(eu07m::read(load(folder / name), read, options).ok); CHECK(same_streams(read, *original)); @@ -207,7 +207,7 @@ TEST_CASE("gref: a folder packed and unpacked") { auto const unpacked{eu07m::unpack_folder(folder, log)}; REQUIRE(unpacked.ok); eu07m::model whole; - REQUIRE(eu07m::read(load(folder / "b.eu07m"), whole, {}).ok); + REQUIRE(eu07m::read(load(folder / "b.r3a"), whole, {}).ok); CHECK(whole.geometry_references.empty()); CHECK(same_streams(whole, b)); std::filesystem::remove_all(folder); diff --git a/tests/unit/test_skinning.cpp b/tests/unit/test_skinning.cpp index 498c335d2..8d32644f3 100644 --- a/tests/unit/test_skinning.cpp +++ b/tests/unit/test_skinning.cpp @@ -216,7 +216,7 @@ TEST_CASE("skinning: the skinned tube is a valid EU07M file") { CHECK(read.weights.size() == read.positions.size()); CHECK(read.primitives[0].skin == 0); // kept in the scratch folder for a look in the game - auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "skinned_tube.eu07m"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "skinned_tube.r3a"}; std::ofstream output{path, std::ios::binary}; output.write(reinterpret_cast(file.data()), static_cast(file.size())); CHECK(output.good()); @@ -243,7 +243,7 @@ TEST_CASE("skinning: the tube bent by a clip of its own") { } CHECK(eu07m::validate(model, 16).empty()); auto const file{eu07m::write(model, {true, 9})}; - auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "clip_tube.eu07m"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "clip_tube.r3a"}; std::ofstream output{path, std::ios::binary}; output.write(reinterpret_cast(file.data()), static_cast(file.size())); CHECK(output.good()); @@ -292,7 +292,7 @@ TEST_CASE("skinning: the tube moved by channels") { model.add_component(eu07m::component::channel, eu07m::target_kind::model, 0, eu07m::payload_writer{}.put(phase).put(toclip).data()); CHECK(eu07m::validate(model, 16).empty()); auto const file{eu07m::write(model, {true, 9})}; - auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "channel_tube.eu07m"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "channel_tube.r3a"}; std::ofstream output{path, std::ios::binary}; output.write(reinterpret_cast(file.data()), static_cast(file.size())); CHECK(output.good()); diff --git a/utilities/Globals.cpp b/utilities/Globals.cpp index 0ebb66791..f8f1040a6 100644 --- a/utilities/Globals.cpp +++ b/utilities/Globals.cpp @@ -1001,10 +1001,10 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string& if (token == "modelformat") { - // eu07m: a model with an .eu07m file beside its .e3d / .t3d is loaded from it; legacy: the .eu07m files are left alone + // r3a: a model with an .r3a file beside its .e3d / .t3d is loaded from it; legacy: the .r3a files are left alone std::string value; ParseOne(Parser, value, 1); - modelformat_eu07m = value == "eu07m"; + modelformat_eu07m = value == "r3a"; return true; } @@ -2700,7 +2700,7 @@ global_settings::export_as_text( std::ostream &Output ) const { export_as_text( Output, "hiddenevents", iHiddenEvents ); export_as_text( Output, "pause", ( iPause & 1 ) != 0 ); export_as_text(Output, "priorityLoadText3D", priorityLoadText3D); - export_as_text(Output, "modelformat", std::string{modelformat_eu07m ? "eu07m" : "legacy"}); + export_as_text(Output, "modelformat", std::string{modelformat_eu07m ? "r3a" : "legacy"}); export_as_text( Output, "lang", asLang ); export_as_text( Output, "python.updatetime", PythonScreenUpdateRate ); Output diff --git a/utilities/Globals.h b/utilities/Globals.h index 52b0db797..331540f7b 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -121,7 +121,7 @@ struct global_settings { int file_binary_terrain_skipped{0}; // number of terrain includes left out by the parser during the current scenery load // logs bool priorityLoadText3D{false}; // ladowanie T3D priorytetowo - bool modelformat_eu07m{false}; // modelformat eu07m: models are loaded from their .eu07m files where there are some + bool modelformat_eu07m{false}; // modelformat r3a: models are loaded from their .r3a files where there are some int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów bool MultipleLogs{ false }; bool crashdump_full{ false }; // crash dump with the whole memory of the process instead of the small one