wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
light.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 // --- MOLT / MOLV / MNLD -----------------------------------------------------
19
20 enum class [[
21 =welder::weld,
22 =welder::doc("The kind of a WMO light (SMOLight.type).")
23 ]] LightType : std::uint8_t {
24 Omni [[=welder::doc("A point light.")]] = 0,
25 Spot [[=welder::doc("A spot light.")]] = 1,
26 Direct [[=welder::doc("A directional light.")]] = 2,
27 Ambient [[=welder::doc("An ambient light.")]] = 3
28 };
30 struct [[
31 =welder::weld,
32 =welder::doc(
33 "One MOLT light. Not rendered by classic-era clients, but baked "
34 "into vertex colors by the exporter.")
35 ]] SMOLight {
36 [[=welder::doc("The light kind; a LightType value.")]]
37 std::uint8_t type = 0;
38
39 [[=welder::doc("Whether attenuation applies.")]]
40 std::uint8_t useAtten = 0;
41
43 [[=welder::mark::exclude]] std::array<std::uint8_t, 2> pad{};
44
45 [[=welder::doc("Light color.")]]
47
48 [[=welder::doc("Position in model space.")]]
50
51 [[=welder::doc("Intensity.")]]
52 float intensity = 0;
53
54 [[=welder::doc("Orientation; spot/direct lights only.")]]
56
57 [[=welder::doc("Attenuation start distance.")]]
58 float attenStart = 0;
59
60 [[=welder::doc("Attenuation end distance.")]]
61 float attenEnd = 0;
62 };
63
64 static_assert(sizeof(SMOLight) == 0x30);
65
66 struct [[
67 =welder::weld,
68 =welder::doc(R"(
69 One MOLV entry (9.1+): a directional-gradient extension to a MOLT
70 light. Multiple entries may extend the same light.)")
72 struct [[=welder::doc(
73 "One directional gradient sample: a direction (usually axis-"
74 "aligned) and its value.")]] Gradient {
75 [[=welder::doc("Gradient direction; usually either xy or z, remainder 0.")
76 ]]
77 C3Vector direction{};
78
79 [[=welder::doc("Gradient value.")]]
80 float value = 0;
81 };
83 [[=welder::doc("The six gradient samples.")]]
84 std::array<Gradient, 6> gradients{};
85
87 [[=welder::mark::exclude]] std::array<std::uint8_t, 3> pad{};
88
89 [[=welder::doc("The MOLT light this entry extends.")]]
90 std::uint8_t lightIndex = 0;
91 };
92
93 static_assert(sizeof(LightExtension) == 0x64);
94
95 struct [[
96 =welder::weld,
97 =welder::doc(R"(
98 One MNLD entry (9.0+): a Shadowlands dynamic light - point or spot -
99 used for everything from torch fires to window-light projection.)")
100 ]] NewLight {
101 [[=welder::doc("0 = point light (sphere), 1 = spot light (cone).")]]
102 std::int32_t type = 0;
103
104 [[=welder::doc("Index of this light in the MNLD array.")]]
105 std::int32_t lightIndex = 0;
106
107 [[=welder::doc("0x1: blend outer and inner color; 0x2: casts shadows.")]]
108 std::int32_t flags = 0;
109
110 [[=welder::doc("The doodad set this light belongs to.")]]
111 std::int32_t doodadSet = 0;
112
113 [[=welder::doc("Inner color.")]]
115
116 [[=welder::doc("Position in the WMO.")]]
118
119 [[=welder::doc("Euler rotation in radians; rotates the light (spot) or its "
120 "cookie (point).")]]
122
123 [[=welder::doc("Attenuation start distance.")]]
124 float attenStart = 0;
125
126 [[=welder::doc("Attenuation end distance.")]]
127 float attenEnd = 0;
128
129 [[=welder::doc("Light intensity.")]]
130 float intensity = 0;
131
132 [[=welder::doc("Outer color; used with flag 0x1.")]]
134
135 [[=welder::doc(
136 "Gradient start distance for inner/outer blending (flag 0x1).")]]
137 float blendStart = 0;
138
139 [[=welder::doc("Gradient end distance for inner/outer blending (flag 0x1).")
140 ]]
141 float blendEnd = 0;
142
144 [[=welder::mark::exclude]] std::array<std::uint8_t, 4> gap1{};
145
146 [[=welder::doc("Flickering intensity.")]]
147 float flickerIntensity = 0;
148
149 [[=welder::doc("Flickering speed.")]]
150 float flickerSpeed = 0;
151
152 [[=welder::doc("0 = off, 1 = sine curve, 2 = noise curve, 3 = noise step.")]
153 ]
154 std::int32_t flickerMode = 0;
155
156 [[=welder::doc("Unknown; only zeros observed.")]]
157 C3Vector unknown1{};
158
160 [[=welder::mark::exclude]] std::array<std::uint8_t, 4> gap2{};
161
162 [[=welder::doc("FileDataID of the light cookie texture (a cube map for "
163 "point lights).")]]
164 std::uint32_t lightCookieFdid = 0;
165
167 [[=welder::mark::exclude]] std::array<std::uint8_t, 20> gap3{};
168
169 [[=welder::doc("Falloff exponent for spot lights.")]]
170 float falloff = 0;
171
172 [[=welder::doc("Start of the spot drop-off gradient, in radians.")]]
173 float innerAngle = 0;
174
175 [[=welder::doc("End of the spot drop-off gradient, in radians.")]]
176 float outerAngle = 0;
177
178 [[=welder::doc("Scale, as raw IEEE half-float bits; used with flag 0x2.")]]
179 std::uint16_t scaleHalf = 0;
180
181 [[=welder::doc("Intensity multiplier, as raw IEEE half-float bits; 0 is "
182 "corrected to 1 by the client.")]]
183 std::uint16_t intensityMultiplierHalf = 0;
184
186 [[=welder::mark::exclude]] std::array<std::int32_t, 11> unused{};
187 };
188
189 static_assert(sizeof(NewLight) == 0xB8);
190}
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
LightType
The kind of a WMO light (SMOLight.type).
Definition light.hpp:21
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 directional gradient sample: a direction (usually axis-aligned) and its value.
Definition light.hpp:62
C3Vector direction
Gradient direction; usually either xy or z, remainder 0.
Definition light.hpp:64
std::array< Gradient, 6 > gradients
The six gradient samples.
Definition light.hpp:71
std::array< std::uint8_t, 3 > pad
Alignment padding; zero in client files.
Definition light.hpp:74
std::uint8_t lightIndex
The MOLT light this entry extends.
Definition light.hpp:77
float flickerIntensity
Flickering intensity.
Definition light.hpp:126
float blendEnd
Gradient end distance for inner/outer blending (flag 0x1).
Definition light.hpp:120
std::int32_t lightIndex
Index of this light in the MNLD array.
Definition light.hpp:87
std::int32_t type
0 = point light (sphere), 1 = spot light (cone).
Definition light.hpp:84
CImVector outerColor
Outer color; used with flag 0x1.
Definition light.hpp:114
float attenStart
Attenuation start distance.
Definition light.hpp:105
float attenEnd
Attenuation end distance.
Definition light.hpp:108
std::array< std::uint8_t, 4 > gap1
Empty gap in the client layout.
Definition light.hpp:123
C3Vector rotation
Euler rotation in radians; rotates the light (spot) or its cookie (point).
Definition light.hpp:102
float blendStart
Gradient start distance for inner/outer blending (flag 0x1).
Definition light.hpp:117
std::int32_t doodadSet
The doodad set this light belongs to.
Definition light.hpp:93
C3Vector position
Position in the WMO.
Definition light.hpp:99
std::int32_t flags
0x1: blend outer and inner color; 0x2: casts shadows.
Definition light.hpp:90
float attenStart
Attenuation start distance.
Definition light.hpp:52
std::uint8_t useAtten
Whether attenuation applies.
Definition light.hpp:34
std::array< std::uint8_t, 2 > pad
Alignment padding; zero in client files.
Definition light.hpp:37
std::uint8_t type
The light kind; a LightType value.
Definition light.hpp:31
float attenEnd
Attenuation end distance.
Definition light.hpp:55
C3Vector position
Position in model space.
Definition light.hpp:43
C4Quaternion rotation
Orientation; spot/direct lights only.
Definition light.hpp:49
The binary-level math and color primitives shared across WoW file formats (wowdev....