76constexpr u32 kColor = 2;
78constexpr u32 kNormal = 5;
80constexpr u32 kPosition = 7;
82constexpr u32 kWeight = 9;
84constexpr u32 kIndex = 11;
86constexpr u32 kWeightNum = 14;
88constexpr u32 kMorphNum = 18;
90constexpr u32 kThrough = 23;
101constexpr u32 kUV = 0b0'00'000'0'000'0'00'00'00'00'000'11;
103constexpr u32 kColor = 0b0'00'000'0'000'0'00'00'00'00'111'00;
105constexpr u32 kNormal = 0b0'00'000'0'000'0'00'00'00'11'000'00;
107constexpr u32 kPosition = 0b0'00'000'0'000'0'00'00'11'00'000'00;
109constexpr u32 kWeight = 0b0'00'000'0'000'0'00'11'00'00'000'00;
111constexpr u32 kIndex = 0b0'00'000'0'000'0'11'00'00'00'000'00;
113constexpr u32 kWeightNum = 0b0'00'000'0'111'0'00'00'00'00'000'00;
115constexpr u32 kMorphNum = 0b0'00'111'0'000'0'00'00'00'00'000'00;
117constexpr u32 kThrough = 0b1'00'000'0'000'0'00'00'00'00'000'00;
261 return ((weight_num - 1) << fmt_shift::kWeightNum);
285 return ((morph_num - 1) << fmt_shift::kMorphNum);
309std::vector<SVertex>
Decode(
BufferView vertex_buffer,
u32 vertex_format, std::array<u16, 8> bone_indices = {0});
326Buffer Encode(
const std::vector<SVertex>& vertices,
u32 vertex_format, std::array<u16, 8> bone_indices = {0});
351inline u32 GetThrough(
u32 vertex_format) {
return (vertex_format & fmt_mask::kThrough) >> fmt_shift::kThrough; }
379 return GetWeightFormat(vertex_format) != 0 ? ((vertex_format & fmt_mask::kWeightNum) >> fmt_shift::kWeightNum) + 1
390inline u32 GetUVFormat(
u32 vertex_format) {
return (vertex_format & fmt_mask::kUV) >> fmt_shift::kUV; }
414inline u32 GetColorFormat(
u32 vertex_format) {
return (vertex_format & fmt_mask::kColor) >> fmt_shift::kColor; }
464 return (vertex_format & fmt_mask::kPosition) >> fmt_shift::kPosition;
496 return ((vertex_format & fmt_mask::kMorphNum) >> fmt_shift::kMorphNum) + 1;
508inline u32 GetIndexFormat(
u32 vertex_format) {
return (vertex_format & fmt_mask::kIndex) >> fmt_shift::kIndex; }
847 u32 offset_weights = 0;
849 u32 offset_color = 0;
850 u32 offset_normal = 0;
851 u32 offset_position = 0;
Defines macros for Design-by-Contract verification.
Contains macros and definitions for fixed-width types.
#define NNL_EXPECTS_DBG(precondition)
Debug-only precondition check.
Definition contract.hpp:59
std::uint32_t u32
32-bit unsigned integer
Definition fixed_type.hpp:60
Structure representing the layout of a vertex.
Definition vertexde.hpp:846
bool Is16Normal(u32 vertex_format)
Checks if the vertex format uses 16-bit normal components.
Definition vertexde.hpp:755
u32 GetColorSize(u32 vertex_format)
Retrieves the byte size of a vertex color from the vertex format.
Definition vertexde.hpp:421
u32 GetUVNum(u32 vertex_format)
Retrieves the number of UV components.
Definition vertexde.hpp:404
bool Is8Position(u32 vertex_format)
Checks if the vertex format uses 8-bit positions.
Definition vertexde.hpp:789
u32 GetColorNum(u32 vertex_format)
Retrieves the number of colors.
Definition vertexde.hpp:427
constexpr std::array< u32, 8 > format_sizes
Maps format codes to attribute sizes.
Definition vertexde.hpp:340
u32 GetColorFormat(u32 vertex_format)
Retrieves the color format code from the vertex format.
Definition vertexde.hpp:414
bool HasUV(u32 vertex_format)
Checks if the vertex format includes UV information.
Definition vertexde.hpp:532
bool IsIndexed(u32 vertex_format)
Checks if the vertex format uses indexed drawing.
Definition vertexde.hpp:569
u32 GetNormalFormat(u32 vertex_format)
Retrieves the normal format code from the vertex format.
Definition vertexde.hpp:437
bool Is8Indices(u32 vertex_format)
Checks if the vertex format uses 8-bit indices.
Definition vertexde.hpp:590
u32 GetWeightSize(u32 vertex_format)
Retrieves the byte size of a weight component from the vertex format.
Definition vertexde.hpp:370
bool IsThrough(u32 vertex_format)
Checks if the vertex format uses Through Mode (2D drawing).
Definition vertexde.hpp:580
u32 GetIndexSize(u32 vertex_format)
Retrieves the byte size of a single index from the vertex format.
Definition vertexde.hpp:516
bool IsFixedWeights(u32 vertex_format)
Checks if the vertex format uses fixed-point weights.
Definition vertexde.hpp:650
u32 GetUVFormat(u32 vertex_format)
Retrieves the UV format code from the vertex format.
Definition vertexde.hpp:390
u32 GetIndexFormat(u32 vertex_format)
Retrieves the index format code from the vertex format.
Definition vertexde.hpp:508
u32 GetUVSize(u32 vertex_format)
Retrieves the byte size of a UV component from the vertex format.
Definition vertexde.hpp:398
bool IsFixedNormal(u32 vertex_format)
Checks if the vertex format uses fixed-point normals.
Definition vertexde.hpp:777
bool HasPosition(u32 vertex_format)
Checks if the vertex format includes position information.
Definition vertexde.hpp:557
u32 GetPositionNum(u32 vertex_format)
Retrieves the number of position components.
Definition vertexde.hpp:485
bool Is4444Color(u32 vertex_format)
Checks if the vertex format uses 4444 vertex colors.
Definition vertexde.hpp:719
u32 GetPositionSize(u32 vertex_format)
Retrieves the byte size of a position component from the vertex format.
Definition vertexde.hpp:475
bool Is32Position(u32 vertex_format)
Checks if the vertex format uses float positions.
Definition vertexde.hpp:813
u32 GetMorphNum(u32 vertex_format)
Retrieves the number of morph targets from the vertex format.
Definition vertexde.hpp:495
u32 GetNormalSize(u32 vertex_format)
Retrieves the byte size of a normal component from the vertex format.
Definition vertexde.hpp:445
bool IsFixedUV(u32 vertex_format)
Checks if the vertex format uses fixed-point UV components.
Definition vertexde.hpp:692
u32 GetWeightNum(u32 vertex_format)
Retrieves the number of weight components from the vertex format.
Definition vertexde.hpp:378
bool Is8Weights(u32 vertex_format)
Checks if the vertex format uses 8-bit weights.
Definition vertexde.hpp:613
u32 GetThrough(u32 vertex_format)
Retrieves the Through Mode status from the vertex format.
Definition vertexde.hpp:351
u32 GetNormalNum(u32 vertex_format)
Retrieves the number of normal components from the vertex format.
Definition vertexde.hpp:453
bool Is8888Color(u32 vertex_format)
Checks if the vertex format uses 8888 vertex colors.
Definition vertexde.hpp:728
bool Is16Weights(u32 vertex_format)
Checks if the vertex format uses 16-bit weights.
Definition vertexde.hpp:625
bool HasWeights(u32 vertex_format)
Checks if the vertex format includes weight information.
Definition vertexde.hpp:525
bool IsFixedPosition(u32 vertex_format)
Checks if the vertex format uses fixed-point positions.
Definition vertexde.hpp:825
bool Is32Weights(u32 vertex_format)
Checks if the vertex format uses float weights.
Definition vertexde.hpp:638
bool Is32Normal(u32 vertex_format)
Checks if the vertex format uses float normals.
Definition vertexde.hpp:767
bool Is32UV(u32 vertex_format)
Checks if the vertex format uses float UVs.
Definition vertexde.hpp:682
bool Is565Color(u32 vertex_format)
Checks if the vertex format uses 565 vertex colors.
Definition vertexde.hpp:701
bool Is16UV(u32 vertex_format)
Checks if the vertex format uses 16-bit UVs.
Definition vertexde.hpp:672
bool Is16Indices(u32 vertex_format)
Checks if the vertex format uses 16-bit indices.
Definition vertexde.hpp:599
bool HasNormal(u32 vertex_format)
Checks if the vertex format includes normal information.
Definition vertexde.hpp:548
u32 GetPositionFormat(u32 vertex_format)
Retrieves the position format code from the vertex format.
Definition vertexde.hpp:463
bool Is8UV(u32 vertex_format)
Checks if the vertex format uses 8-bit UVs.
Definition vertexde.hpp:662
bool Is5551Color(u32 vertex_format)
Checks if the vertex format uses 5551 vertex colors.
Definition vertexde.hpp:710
VertexLayout GetLayout(u32 vertex_format)
Retrieves the layout of a vertex based on its format.
u32 GetWeightFormat(u32 vertex_format)
Retrieves the weight format code from the vertex format.
Definition vertexde.hpp:361
bool HasColor(u32 vertex_format)
Checks if the vertex format includes color information.
Definition vertexde.hpp:540
bool Is8Normal(u32 vertex_format)
Checks if the vertex format uses 8-bit normals.
Definition vertexde.hpp:743
bool Is16Position(u32 vertex_format)
Checks if the vertex format uses 16-bit positions.
Definition vertexde.hpp:801
std::string GetDescription(u32 vertex_format)
Generates a textual description of the vertex format.
std::vector< SVertex > Decode(BufferView vertex_buffer, u32 vertex_format, std::array< u16, 8 > bone_indices={0})
Extracts vertex data from a buffer and converts it to a simple representation.
Buffer Encode(const std::vector< SVertex > &vertices, u32 vertex_format, std::array< u16, 8 > bone_indices={0})
Converts vertex data from a simple representation to a binary vertex buffer.
Provides classes for reading and writing binary data to and from various sources.
This namespace defines constants that represent fundamental format codes.
constexpr u32 k8888
4 byte color
Definition vertexde.hpp:62
constexpr u32 k565
2 byte color
Definition vertexde.hpp:59
constexpr u32 k8
1 byte component
Definition vertexde.hpp:55
constexpr u32 k32
4 byte component
Definition vertexde.hpp:57
constexpr u32 k0
no component
Definition vertexde.hpp:53
constexpr u32 k4444
2 byte color
Definition vertexde.hpp:61
constexpr u32 k5551
2 byte color
Definition vertexde.hpp:60
constexpr u32 k16
2 byte component
Definition vertexde.hpp:56
This namespace contains constants representing bit masks for parts of the vertex format.
This namespace contains constants representing shift values that are applied to format codes to creat...
This namespace contains constants and functions for defining the vertex format.
constexpr u32 kIndex16
unsigned 16-bit indices (in index buffers)
Definition vertexde.hpp:227
constexpr u32 kMorphNum(u32 morph_num)
Generates a constant that encodes the number of morph targets.
Definition vertexde.hpp:283
constexpr u32 kPosition16
16-bit fixed-point vertex coordinates (signed).
Definition vertexde.hpp:193
constexpr u32 kPosition32
floating-point vertex coordinates.
Definition vertexde.hpp:197
constexpr u32 kWeight16
16-bit fixed-point bone weights (unsigned).
Definition vertexde.hpp:207
constexpr u32 kNormal32
floating-point vertex normal.
Definition vertexde.hpp:185
constexpr u32 kWeight32
floating-point bone weights.
Definition vertexde.hpp:212
constexpr u32 kUV16
16-bit fixed-point texture coordinates (unsigned)
Definition vertexde.hpp:153
constexpr u32 kIndex8
unsigned 8-bit indices (in index buffers)
Definition vertexde.hpp:221
constexpr u32 kWeightNum(u32 weight_num)
Generates a constant that encodes the number of weights.
Definition vertexde.hpp:259
constexpr u32 kNormal16
16-bit fixed-point vertex normal (signed).
Definition vertexde.hpp:181
constexpr u32 kColor5551
2-byte color format. 1 bit for the alpha channel.
Definition vertexde.hpp:165
constexpr u32 kUV8
8-bit fixed-point texture coordinates (unsigned)
Definition vertexde.hpp:149
constexpr u32 kColor4444
2-byte color format. 4 bits per channel.
Definition vertexde.hpp:169
constexpr u32 kWeight8
8-bit fixed-point bone weights (unsigned).
Definition vertexde.hpp:202
constexpr u32 kUV32
floating-point texture coordinates
Definition vertexde.hpp:157
constexpr u32 kThrough
Indicates whether the 2D drawing mode is used.
Definition vertexde.hpp:242
constexpr u32 kColor8888
4-byte color format. 8 bits per channel.
Definition vertexde.hpp:173
constexpr u32 kColor565
2-byte color format. No alpha channel.
Definition vertexde.hpp:161
constexpr u32 kNormal8
8-bit fixed-point vertex normal (signed).
Definition vertexde.hpp:177
constexpr u32 kPosition8
8-bit fixed-point vertex coordinates (signed).
Definition vertexde.hpp:189
Contains functions that facilitate conversion of vertex data.
Definition vertexde.hpp:34
Definition exception.hpp:56
Provides data structures and functions for managing essential components of a 3D model.