diff --git a/docs/eu07m-format.md b/docs/eu07m-format.md index b8075d7a5..20114dd25 100644 --- a/docs/eu07m-format.md +++ b/docs/eu07m-format.md @@ -1,4 +1,4 @@ -# The EU07M model format (`.r3a`) +# The EU07M model format (`.ng3d`) 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.r3p` in the folder of the models: a 32 B header (magic `EU7P`, `u16` major 1, +- **The store** of the family is `geometry.ng3p` 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 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. +With `modelformat ng3d` in `eu07.ini`, a model with an `.ng3d` file beside its `.e3d` / `.t3d` (or alone) is loaded from it +(`TModel3d::LoadFromEU07M`). The default `modelformat legacy` leaves `.ng3d` 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 `.r3a` file is loaded only when it exists, behind the switch `modelformat r3a` in -`eu07.ini`. The current release doesn't read `.r3a`. +E3D and T3D are read as before. An `.ng3d` file is loaded only when it exists, behind the switch `modelformat ng3d` in +`eu07.ini`. The current release doesn't read `.ng3d`. diff --git a/model/MdlMngr.cpp b/model/MdlMngr.cpp index ce3198d1a..44c3a1669 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 .r3a alone - extensions.emplace_back( ".r3a" ); + // a model may come as an .ng3d alone + extensions.emplace_back( ".ng3d" ); } for( auto const &extension : extensions ) { diff --git a/model/Model3d.cpp b/model/Model3d.cpp index 414f900b1..6de5d04c4 100644 --- a/model/Model3d.cpp +++ b/model/Model3d.cpp @@ -1831,7 +1831,7 @@ glm::vec3 TSubModel::offset(float const Geometrytestoffsetthreshold) const namespace { -// modelformat r3a: an .r3a older than the .e3d / .t3d it was made from isn't used, the model was changed after it was +// modelformat ng3d: an .ng3d 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 + ".r3a") : std::string{}}; + else if (auto const eu07mfile{Global.modelformat_eu07m ? FileCased(name + ".ng3d") : std::string{}}; (false == eu07mfile.empty()) && eu07m_up_to_date(eu07mfile, {binaryfile, textfile}) && LoadFromEU07M(eu07mfile, dynamic)) { - // modelformat r3a: the .r3a made from the model takes its place; one which doesn't load leaves the .e3d / .t3d to go on + // modelformat ng3d: the .ng3d 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 32ad96609..e1b4ffdbc 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) == ".r3a") + else if (extension_of(Input) == ".ng3d") 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 bfd2c605c..c5f9fadde 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.r3p beside the file) instead of +// the geometry of a primitive kept in the geometry store of the family of the model (geometry.ng3p 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 cae70653e..54aec561b 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 == ".r3a"; + return Entry.is_regular_file() && extension == ".ng3d"; } // 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 9851988fa..907edba28 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.r3p), made anew from all of them; the models are written again referring to it. every model is read back and +// (geometry.ng3p), 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 f06f4ba97..96ac8d213 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.r3p) and referred to by the models (GREF) instead of being repeated in each of them +// store of the folder (geometry.ng3p) 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.r3p"}; +constexpr char const *store_file_name{"geometry.ng3p"}; // 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 6662e1db6..b2f0aaf2d 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.r3a", eu07m::write(a)); - save(folder / "b.r3a", eu07m::write(b)); - save(folder / "c.r3a", eu07m::write(c)); + save(folder / "a.ng3d", eu07m::write(a)); + save(folder / "b.ng3d", eu07m::write(b)); + save(folder / "c.ng3d", 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.r3a", &a}, std::pair{"b.r3a", &b}, std::pair{"c.r3a", &c}}) { + for (auto const &[name, original] : {std::pair{"a.ng3d", &a}, std::pair{"b.ng3d", &b}, std::pair{"c.ng3d", &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.r3a"), whole, {}).ok); + REQUIRE(eu07m::read(load(folder / "b.ng3d"), 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 8d32644f3..d3cd11aa5 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.r3a"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "skinned_tube.ng3d"}; 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.r3a"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "clip_tube.ng3d"}; 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.r3a"}; + auto const path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / "channel_tube.ng3d"}; 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 f8f1040a6..79c23f691 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") { - // r3a: a model with an .r3a file beside its .e3d / .t3d is loaded from it; legacy: the .r3a files are left alone + // ng3d: a model with an .ng3d file beside its .e3d / .t3d is loaded from it; legacy: the .ng3d files are left alone std::string value; ParseOne(Parser, value, 1); - modelformat_eu07m = value == "r3a"; + modelformat_eu07m = value == "ng3d"; 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 ? "r3a" : "legacy"}); + export_as_text(Output, "modelformat", std::string{modelformat_eu07m ? "ng3d" : "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 331540f7b..305f41d30 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 r3a: models are loaded from their .r3a files where there are some + bool modelformat_eu07m{false}; // modelformat ng3d: models are loaded from their .ng3d 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