wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
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
14
#include <
wowlib/formats/common/flags.hpp
>
15
#include <
wowlib/formats/common/types.hpp
>
16
17
namespace
wowlib::formats::wmo::root::chunks
{
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;
35
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
};
47
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)."
)]]
73
C3Vector
position
{};
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
}
flags.hpp
Flag-testing convenience for the binary formats' bit-mask enums.
wowlib::formats::wmo::root::chunks
WMO root-file chunk binary structs (MOHD, MOMT, lights, doodads, fog, ambient volumes) and their flag...
Definition
doodad.hpp:17
wowlib::formats::wmo::root::chunks::DoodadFlags
DoodadFlags
Doodad placement flag bits, packed into the high byte of SMODoodadDef.name_and_flags.
Definition
doodad.hpp:44
wowlib::formats::wmo::root::chunks::DoodadFlags::InteriorLighting
@ InteriorLighting
Use interior lighting.
Definition
doodad.hpp:48
wowlib::formats::wmo::root::chunks::DoodadFlags::AcceptProjTex
@ AcceptProjTex
Accept projected textures.
Definition
doodad.hpp:47
wowlib::formats::wmo::root::chunks::DoodadFlags::NameMask
@ NameMask
The low 24 bits: the MODN offset / MODI index mask.
Definition
doodad.hpp:45
wowlib::formats::common::C3Vector
A 3D float vector — the workhorse: positions, normals, rotations-as-Euler-degrees in placements.
Definition
types.hpp:49
wowlib::formats::common::C4Quaternion
Definition
types.hpp:86
wowlib::formats::common::CImVector
A color stored as b, g, r, a bytes — the client's immediate-mode vertex color layout (WMO MOCV,...
Definition
types.hpp:178
wowlib::formats::wmo::root::chunks::SMODoodadDef
One MODD doodad placement: an M2 instance inside the WMO, quaternion-oriented in model space.
Definition
doodad.hpp:52
wowlib::formats::wmo::root::chunks::SMODoodadDef::scale
float scale
Uniform scale factor.
Definition
doodad.hpp:63
wowlib::formats::wmo::root::chunks::SMODoodadDef::orientation
C4Quaternion orientation
Orientation quaternion.
Definition
doodad.hpp:60
wowlib::formats::wmo::root::chunks::SMODoodadDef::position
C3Vector position
Position in WMO model space (Z-up).
Definition
doodad.hpp:57
wowlib::formats::wmo::root::chunks::SMODoodadDef::nameIndex
constexpr std::uint32_t nameIndex() const
The 24-bit MODN byte offset (or MODI index) of the model name.
Definition
doodad.hpp:70
wowlib::formats::wmo::root::chunks::SMODoodadDef::color
CImVector color
Color override (BGRA); alpha below 0xFF is a MOLT index.
Definition
doodad.hpp:66
wowlib::formats::wmo::root::chunks::SMODoodadDef::nameAndFlags
std::uint32_t nameAndFlags
Packed 24-bit MODN offset / MODI index plus DoodadFlags bits in the high byte.
Definition
doodad.hpp:54
wowlib::formats::wmo::root::chunks::SMODoodadSet
Definition
doodad.hpp:20
wowlib::formats::wmo::root::chunks::SMODoodadSet::pad
std::array< char, 4 > pad
Alignment padding; zero in client files.
Definition
doodad.hpp:31
wowlib::formats::wmo::root::chunks::SMODoodadSet::startIndex
std::uint32_t startIndex
First doodad instance in MODD.
Definition
doodad.hpp:25
wowlib::formats::wmo::root::chunks::SMODoodadSet::nameBytes
std::array< char, 20 > nameBytes
The raw fixed-size name field; read through name().
Definition
doodad.hpp:22
wowlib::formats::wmo::root::chunks::SMODoodadSet::name
std::string_view name() const
The informational set name.
Definition
doodad.hpp:35
wowlib::formats::wmo::root::chunks::SMODoodadSet::count
std::uint32_t count
Number of doodad instances in the set.
Definition
doodad.hpp:28
types.hpp
The binary-level math and color primitives shared across WoW file formats (wowdev....
src
wowlib
formats
wmo
root
chunks
doodad.hpp
Generated by
1.17.0