65 glm::vec4
color{1.0f, 1.0f, 1.0f, 1.0f};
67 std::array<u16, kMaxNumBoneWeight>
bones{0};
69 std::array<float, kMaxNumBoneWeight>
weights{1.0f};
310 const std::vector<u32>&
indices,
const std::vector<SVertex>&
vertices);
527 std::vector<std::reference_wrapper<const SBone>>
GetBoneRefs()
const;
634 glm::mat4 GetTransform()
const;
636 void SetTransform(
const glm::mat4& transform);
Contains macros for defining flag enums.
Contains macros and definitions for fixed-width types.
std::uint16_t u16
16-bit unsigned integer
Definition fixed_type.hpp:62
std::uint8_t u8
8-bit unsigned integer
Definition fixed_type.hpp:64
#define NNL_DEFINE_ENUM_OPERATORS(ENUMTYPE)
Macro to define bitwise operators for enum types.
Definition enum_flag.hpp:36
#define NNL_FLAG_ENUM
An attribute for defining flag enums.
Definition enum_flag.hpp:28
std::array< float, kMaxNumBoneWeight > weights
Definition smodel.hpp:69
void GenerateSmoothNormals()
Generates smooth normals for the meshes.
std::pair< glm::vec3, glm::vec3 > FindMinMax() const
Finds the minimum and maximum points of the model.
std::vector< std::string > material_variants
Definition smodel.hpp:664
void TransformUV(const glm::mat3 &transform)
Transforms the UV coordinates of the mesh using a transformation matrix.
float specular_power
Definition smodel.hpp:588
std::vector< SVertex > vertices
The vertex data for the mesh.
Definition smodel.hpp:217
glm::mat4 GetTransform() const
Calculates the local transformation matrix of the bone from the SRT properties.
std::vector< std::reference_wrapper< SBone > > GetBoneRefs()
Retrieves a flat array of references to the bones of the skeleton.
void GenerateSmoothNormals()
Generates smooth normals for the mesh.
void QuantWeights(unsigned int steps=128)
Quantizes the vertex weights to a specified number of steps.
void NormalizeWeights()
Normalizes the weights of the vertices.
void SortWeights()
Sorts vertex weights by influence, placing the highest values first.
void ResetColors()
Resets all vertex colors to the default value.
void RemoveDuplicateMaterials()
Removes duplicate materials from the model.
glm::vec3 specular
The specular color of the material.
Definition smodel.hpp:581
std::array< u16, kMaxNumBoneWeight > bones
Bone indices.
Definition smodel.hpp:67
STextureProjection projection_mode
Definition smodel.hpp:604
void ReverseWindingOrder()
Changes the winding order of the triangle.
glm::vec3 normal
A vertex normal.
Definition smodel.hpp:61
void NormalizeNormals()
Normalizes the normals of the vertices.
void ResetColors()
Resets the vertex color to its default value.
bool IsAffectedByFewBones() const
Checks if the mesh is influenced by at least 2 bones.
bool uses_color
Indicates whether the mesh uses vertex colors.
Definition smodel.hpp:231
void NormalizeWeights()
Normalizes the weights of the vertices.
std::size_t mesh_group
Definition smodel.hpp:226
std::vector< std::reference_wrapper< const SBone > > GetBoneRefs() const
Retrieves a flat array of references to the bones of the skeleton.
std::string name
An optional name for the material.
Definition smodel.hpp:579
glm::vec4 color
Vertex color (RGBA)
Definition smodel.hpp:65
bool uses_normal
Indicates whether the mesh uses vertex normals.
Definition smodel.hpp:230
void ResetNormals()
Resets the vertex normal to its default value.
std::vector< SBone > children
The children of this bone.
Definition smodel.hpp:460
void UpdateInverseMatrices()
Updates the inverse matrices from local bone transformations.
bool TryBakeBindShape()
Bakes bind shape transforms from the inverse matrices into the model.
bool operator==(const SMaterial &rhs) const
Compares two materials for equality.
glm::vec3 scale
The local scale of the bone.
Definition smodel.hpp:452
void TransformUV(const glm::mat3 &matrix)
Transforms the UV coordinates of the model using a transformation matrix.
std::string name
An optional name for the mesh.
Definition smodel.hpp:213
SVertex & operator[](std::size_t index)
Accesses a vertex of the triangle by index.
void ResetColors()
Resets all vertex colors to the default value.
void LimitWeightsPerVertex(unsigned int max_weights=3)
Limits the number of weights per vertex.
glm::vec3 diffuse
The diffuse color of the material.
Definition smodel.hpp:582
void GenerateFlatNormals()
Generates flat normals for the meshes.
void Join(const SMesh &smesh)
Joins another mesh into this mesh.
SValue extras
Definition smodel.hpp:607
glm::vec3 ambient
The ambient color of the material.
Definition smodel.hpp:583
const SVertex & operator[](std::size_t index) const
Accesses a vertex of the triangle by index.
glm::vec3 translation
Translation transformation.
Definition smodel.hpp:632
std::vector< SBone > roots
Definition smodel.hpp:486
SValue extras
Any additional data for custom use.
Definition smodel.hpp:233
glm::vec3 position
The position of the vertex in 3D space.
Definition smodel.hpp:59
SBlendMode alpha_mode
Definition smodel.hpp:601
void SetTransform(const glm::mat4 &transform)
Sets the local SRT properties of the bone.
std::vector< SMaterial > materials
A vector of materials used by the meshes.
Definition smodel.hpp:662
std::pair< glm::vec2, glm::vec2 > FindMinMaxUV() const
Finds the minimum and maximum UV coordinates of the mesh.
float opacity
The opacity of the material. [0.0, 1.0].
Definition smodel.hpp:586
void SortWeights()
Sorts vertex weights by influence, placing the highest values first.
static SMesh FromTriangles(const std::vector< STriangle > &triangles)
Creates a mesh from a triangle list.
glm::vec2 uv
Texture coordinates.
Definition smodel.hpp:63
void ResetNormals()
Resets all vertex normals to the default value.
glm::mat4 inverse
The inverse bind matrix of the bone.
Definition smodel.hpp:458
void LimitWeightsPerTriangle(unsigned int max_weights=8)
Limits the number of weights per triangle.
void SortWeights()
Sorts vertex weights by influence, placing the highest values first.
void NormalizeNormals()
Normalizes the normals of the vertices.
void LimitWeightsPerTriangle(unsigned int max_weights=8)
Limits the number of unique bone influences per triangle.
void NormalizeWeights()
Normalizes the weights of the vertex so they add up to 1.0.
void ResetNormals()
Resets all vertex normals to the default value.
void ResetUVs()
Resets all texture coordinates to the default value.
void ResetUVs()
Resets the texture coordinates to the default value.
int texture_id
Definition smodel.hpp:592
void ResetUVs()
Resets all texture coordinates to the default value.
std::size_t bone
The parent bone.
Definition smodel.hpp:628
std::array< SVertex, 3 > vertices
The vertices that define the triangle.
Definition smodel.hpp:163
glm::vec3 CalculateCenter() const
Finds the center of the model.
std::vector< glm::mat4 > GetGlobalMatrices() const
Retrieves the global matrices.
bool uses_uv
Indicates whether the mesh uses texture coordinates.
Definition smodel.hpp:229
std::vector< SAttachment > attachments
A vector of attachments associated with the model.
Definition smodel.hpp:658
std::string name
An optional name for the attachment.
Definition smodel.hpp:625
void RemoveDuplicateVertices()
Removes duplicate vertices from the mesh.
glm::vec3 CalculateCenter() const
Finds the center of the mesh.
void LimitWeightsPerVertex(unsigned int max_weights=3)
Limits the number of weights per vertex.
bool IsApproxEqual(const SVertex &rhs) const
Compares this vertex with another one for approximate equality.
glm::quat rotation
The local rotation of the bone.
Definition smodel.hpp:454
bool HasAlpha() const
Checks if the alpha component of the vertex color is less than ~1.0.
void Transform(const glm::mat4 &transform)
Transforms the mesh using a transformation matrix.
std::size_t material_id
The ID of the material associated with the mesh.
Definition smodel.hpp:219
bool HasAlphaVertex() const
Checks if the mesh has any transparent vertex colors.
glm::vec3 emissive
The emissive color of the material.
Definition smodel.hpp:584
void QuantWeights(unsigned int steps=128)
Quantizes the weights to the specified number of steps.
bool lit
Definition smodel.hpp:595
u16 vfx_group_id
The visual effects group of the material.
Definition smodel.hpp:599
void ResetWeights()
Resets the vertex bone indices and weights to their default value.
void LimitWeights(unsigned int max_weights=3)
Limits the number of bones a vertex refers to by removing the least influential weights.
glm::quat rotation
Rotation transformation.
Definition smodel.hpp:631
std::map< std::size_t, std::vector< std::size_t > > material_variants
Definition smodel.hpp:221
std::pair< glm::vec3, glm::vec3 > FindMinMax() const
Finds the minimum and maximum points of the mesh.
glm::vec3 scale
Scale transformation.
Definition smodel.hpp:630
std::vector< SMesh > meshes
A vector of meshes that make up the model.
Definition smodel.hpp:660
std::vector< u32 > indices
The vertex indices that define the triangles.
Definition smodel.hpp:215
glm::vec3 translation
The local translation of the bone.
Definition smodel.hpp:456
bool IsDegenerate() const
Checks if the triangle has no area.
std::vector< glm::mat4 > GetSkinningMatrices() const
Retrieves the skinning matrices for transforming vertices in model space.
void QuantWeights(unsigned int steps=128)
Quantizes the vertex weights to a specified number of steps.
void ResetWeights()
Removes all weights.
SSkeleton skeleton
Definition smodel.hpp:655
void ReverseWindingOrder()
Reverses the winding order of the mesh's triangles.
void GenerateFlatNormals()
Generates flat normals for the mesh.
void ResetWeights()
Removes all weights.
std::vector< SUVAnimation > uv_animations
Definition smodel.hpp:671
std::string name
An optional name for the bone.
Definition smodel.hpp:450
std::vector< std::pair< glm::vec2, glm::vec2 > > NormalizeUV()
Normalizes the UV coordinates of the model.
static std::pair< std::vector< u32 >, std::vector< SVertex > > RemoveDuplicateVertices(const std::vector< u32 > &indices, const std::vector< SVertex > &vertices)
Removes duplicate or unused vertices from the vertex data.
friend SVertex operator*(const glm::mat4 &transform, SVertex vertex)
Multiplication operator for transforming the vertex by a matrix.
void Transform(const glm::mat4 &transform)
Transforms the vertex using a transformation matrix.
glm::mat4 Normalize()
Normalizes the model to fit within the range of -1.0 to 1.0.
void Transform(const glm::mat4 &matrix)
Transforms the model using a transformation matrix.
Represents a triangle defined by three vertices.
Definition smodel.hpp:162
Represents a simple material with various properties for 3D rendering.
Definition smodel.hpp:578
Represents a bone/joint in a skeletal hierarchy of a 3D model.
Definition smodel.hpp:449
Represents a simple mesh.
Definition smodel.hpp:212
Represents a node attached to a bone.
Definition smodel.hpp:624
Represents a simple model.
Definition smodel.hpp:654
Represents a simple vertex with a fixed set of attributes.
Definition smodel.hpp:58
Represents the skeleton of a 3D model.
Definition smodel.hpp:485
STextureProjection
Enumeration of projection modes for textures.
Definition smodel.hpp:562
SBlendMode
Enumeration of blending modes for materials.
Definition smodel.hpp:541
constexpr std::size_t kMaxNumBoneWeight
Maximum number of bone weights and indices in SVertex.
Definition smodel.hpp:38
@ kMatrix
Matrix-based projection.
Definition smodel.hpp:564
@ kEnvironment
Environment mapping projection.
Definition smodel.hpp:565
@ kUV
Standard UV mapping.
Definition smodel.hpp:563
@ kAlpha
Definition smodel.hpp:543
@ kOpaque
Completely opaque.
Definition smodel.hpp:542
@ kAdd
Additive blending; colors are added to the background.
Definition smodel.hpp:550
@ kClip
Definition smodel.hpp:548
@ kSub
Definition smodel.hpp:551
A class representing JSON-like values (null, bool, numbers, strings, arrays, or objects)
Definition svalue.hpp:41
Definition exception.hpp:56
Provides data structures for representing various animation types and their essential components.
Provides a class for representing "extras" fields for custom metadata.