wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
doodad.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <algorithm>
7#include <array>
8#include <cstdint>
9#include <string_view>
10#include <utility>
11
12#include <welder/vocabulary.hpp>
13
16
18 // --- MODS / MODD ------------------------------------------------------------
19
20 struct [[
21 =welder::weld,
22 =welder::doc(R"(
23 One MODS doodad set: a named range of doodad placements. Set 0
24 ("Set_$DefaultGlobal") is additive and always shown; other sets are
25 exclusive alternatives.)")
26 ]] SMODoodadSet {
28 [[=welder::mark::exclude]] std::array<char, 20> nameBytes{};
29
30 [[=welder::doc("First doodad instance in MODD.")]]
31 std::uint32_t startIndex = 0;
32
33 [[=welder::doc("Number of doodad instances in the set.")]]
34 std::uint32_t count = 0;
37 [[=welder::mark::exclude]] std::array<char, 4> pad{};
38
39 [[=welder::getter("name"),
40 =welder::doc("The informational set name.")]]
41 [[nodiscard]]
42 std::string_view name() const {
43 const auto end = std::find(nameBytes.begin(), nameBytes.end(), '\0');
44 return {nameBytes.data(), static_cast<std::size_t>(end - nameBytes.begin())};
45 }
46 };
48 static_assert(sizeof(SMODoodadSet) == 0x20);
49
50 enum class [[
51 =welder::weld,
52 =welder::flags,
53 =welder::doc("Doodad placement flag bits, packed into the high byte of "
54 "SMODoodadDef.name_and_flags.")
55 ]] DoodadFlags : std::uint32_t {
56 NameMask [[=
57 welder::doc("The low 24 bits: the MODN offset / MODI index mask.")]] =
58 0x00FF'FFFF,
59 AcceptProjTex [[=welder::doc("Accept projected textures.")]] = 0x0100'0000,
60 InteriorLighting [[=welder::doc("Use interior lighting.")]] = 0x0200'0000
61 };
62
63 struct [[
64 =welder::weld,
65 =welder::doc("One MODD doodad placement: an M2 instance inside the WMO, "
66 "quaternion-oriented in model space.")
67 ]] SMODoodadDef {
68 [[=welder::doc("Packed 24-bit MODN offset / MODI index plus DoodadFlags "
69 "bits in the high byte.")]]
70 std::uint32_t nameAndFlags = 0;
71
72 [[=welder::doc("Position in WMO model space (Z-up).")]]
74
75 [[=welder::doc("Orientation quaternion.")]]
76 C4Quaternion orientation{};
77
78 [[=welder::doc("Uniform scale factor.")]]
79 float scale = 1;
80
81 [[=welder::doc("Color override (BGRA); alpha below 0xFF is a MOLT index.")]]
82 CImVector color{};
83
84 [[=welder::getter,
85 =welder::doc(
86 "The 24-bit MODN byte offset (or MODI index) of the model name.")]]
87 [[nodiscard]]
88 constexpr std::uint32_t nameIndex() const {
89 return nameAndFlags & std::to_underlying(DoodadFlags::NameMask);
90 }
91 };
92
93 static_assert(sizeof(SMODoodadDef) == 0x28);
94}
Flag-testing convenience for the binary formats' bit-mask enums.
WMO root-file chunk binary structs (MOHD, MOMT, lights, doodads, fog, ambient volumes) and their flag...
Definition doodad.hpp:17
DoodadFlags
Doodad placement flag bits, packed into the high byte of SMODoodadDef.name_and_flags.
Definition doodad.hpp:44
@ AcceptProjTex
Accept projected textures.
Definition doodad.hpp:47
@ NameMask
The low 24 bits: the MODN offset / MODI index mask.
Definition doodad.hpp:45
A 3D float vector — the workhorse: positions, normals, rotations-as-Euler-degrees in placements.
Definition types.hpp:49
A color stored as b, g, r, a bytes — the client's immediate-mode vertex color layout (WMO MOCV,...
Definition types.hpp:178
One MODD doodad placement: an M2 instance inside the WMO, quaternion-oriented in model space.
Definition doodad.hpp:52
C4Quaternion orientation
Orientation quaternion.
Definition doodad.hpp:60
C3Vector position
Position in WMO model space (Z-up).
Definition doodad.hpp:57
constexpr std::uint32_t nameIndex() const
The 24-bit MODN byte offset (or MODI index) of the model name.
Definition doodad.hpp:70
CImVector color
Color override (BGRA); alpha below 0xFF is a MOLT index.
Definition doodad.hpp:66
std::uint32_t nameAndFlags
Packed 24-bit MODN offset / MODI index plus DoodadFlags bits in the high byte.
Definition doodad.hpp:54
std::array< char, 4 > pad
Alignment padding; zero in client files.
Definition doodad.hpp:31
std::uint32_t startIndex
First doodad instance in MODD.
Definition doodad.hpp:25
std::array< char, 20 > nameBytes
The raw fixed-size name field; read through name().
Definition doodad.hpp:22
std::string_view name() const
The informational set name.
Definition doodad.hpp:35
std::uint32_t count
Number of doodad instances in the set.
Definition doodad.hpp:28
The binary-level math and color primitives shared across WoW file formats (wowdev....