|
NSUNI/NSLAR Library a250670
|
Provides data structures and functions for managing essential components of a 3D model. More...
Classes | |
| struct | nnl::SVertex |
| Represents a simple vertex with a fixed set of attributes. More... | |
| struct | nnl::STriangle |
| Represents a triangle defined by three vertices. More... | |
| struct | nnl::SMesh |
| Represents a simple mesh. More... | |
| struct | nnl::SBone |
| Represents a bone/joint in a skeletal hierarchy of a 3D model. More... | |
| struct | nnl::SSkeleton |
| Represents the skeleton of a 3D model. More... | |
| struct | nnl::SMaterial |
| Represents a simple material with various properties for 3D rendering. More... | |
| struct | nnl::SAttachment |
| Represents a node attached to a bone. More... | |
| struct | nnl::SModel |
| Represents a simple model. More... | |
Enumerations | |
| enum class | nnl::SBlendMode : u8 { nnl::SBlendMode::kOpaque = 0b00000 , nnl::SBlendMode::kAlpha = 0b00001 , nnl::SBlendMode::kClip = 0b00010 , nnl::SBlendMode::kAdd = 0b00100 , nnl::SBlendMode::kSub = 0b01000 } |
| Enumeration of blending modes for materials. More... | |
| enum class | nnl::STextureProjection { nnl::STextureProjection::kUV = 0 , nnl::STextureProjection::kMatrix = 1 , nnl::STextureProjection::kEnvironment = 2 } |
| Enumeration of projection modes for textures. More... | |
Variables | |
| constexpr std::size_t | nnl::kMaxNumBoneWeight = 8 |
| Maximum number of bone weights and indices in SVertex. | |
Provides data structures and functions for managing essential components of a 3D model.
This file defines structures for the essential components of 3D models. These structures facilitate the conversion of 3D model data between various common exchange formats (such as FBX and glTF) and in-game formats.
| struct nnl::SVertex |
Represents a simple vertex with a fixed set of attributes.
This structure encapsulates the essential attributes of a vertex. It is used for exporting and importing vertex data to and from common exchange formats. It can also be utilized for converting vertex data to vertex buffers supported by the GE.
Public Member Functions | |
| void | Transform (const glm::mat4 &transform) |
| Transforms the vertex using a transformation matrix. | |
| bool | HasAlpha () const |
| Checks if the alpha component of the vertex color is less than ~1.0. | |
| bool | IsApproxEqual (const SVertex &rhs) const |
| Compares this vertex with another one for approximate equality. | |
| void | NormalizeWeights () |
| Normalizes the weights of the vertex so they add up to 1.0. | |
| void | QuantWeights (unsigned int steps=128) |
| Quantizes the weights to the specified number of steps. | |
| void | SortWeights () |
| Sorts vertex weights by influence, placing the highest values first. | |
| void | LimitWeights (unsigned int max_weights=3) |
| Limits the number of bones a vertex refers to by removing the least influential weights. | |
| void | ResetWeights () |
| Resets the vertex bone indices and weights to their default value. | |
| void | ResetNormals () |
| Resets the vertex normal to its default value. | |
| void | ResetUVs () |
| Resets the texture coordinates to the default value. | |
| void | ResetColors () |
| Resets the vertex color to its default value. | |
Public Attributes | |
| glm::vec3 | position {0.0f} |
| The position of the vertex in 3D space. | |
| glm::vec3 | normal {0.0f, 1.0f, 0.0f} |
| A vertex normal. | |
| glm::vec2 | uv {0.0f} |
| Texture coordinates. | |
| glm::vec4 | color {1.0f, 1.0f, 1.0f, 1.0f} |
| Vertex color (RGBA) | |
| std::array< u16, kMaxNumBoneWeight > | bones {0} |
| Bone indices. | |
| std::array< float, kMaxNumBoneWeight > | weights {1.0f} |
Friends | |
| SVertex | operator* (const glm::mat4 &transform, SVertex vertex) |
| Multiplication operator for transforming the vertex by a matrix. | |
| bool nnl::SVertex::HasAlpha | ( | ) | const |
Checks if the alpha component of the vertex color is less than ~1.0.
| bool nnl::SVertex::IsApproxEqual | ( | const SVertex & | rhs | ) | const |
Compares this vertex with another one for approximate equality.
| rhs | The vertex to compare against. |
| void nnl::SVertex::LimitWeights | ( | unsigned int | max_weights = 3 | ) |
Limits the number of bones a vertex refers to by removing the least influential weights.
| max_weights | The maximum number of weights to retain. |
| void nnl::SVertex::NormalizeWeights | ( | ) |
Normalizes the weights of the vertex so they add up to 1.0.
| void nnl::SVertex::QuantWeights | ( | unsigned int | steps = 128 | ) |
Quantizes the weights to the specified number of steps.
| steps | The number of quantization steps (default is 128). |
| void nnl::SVertex::ResetColors | ( | ) |
Resets the vertex color to its default value.
| void nnl::SVertex::ResetNormals | ( | ) |
Resets the vertex normal to its default value.
| void nnl::SVertex::ResetUVs | ( | ) |
Resets the texture coordinates to the default value.
| void nnl::SVertex::ResetWeights | ( | ) |
Resets the vertex bone indices and weights to their default value.
| void nnl::SVertex::SortWeights | ( | ) |
Sorts vertex weights by influence, placing the highest values first.
| void nnl::SVertex::Transform | ( | const glm::mat4 & | transform | ) |
Transforms the vertex using a transformation matrix.
This method applies the specified transformation matrix to positions and normals.
| transform | The transformation matrix to apply to the vertex. |
Multiplication operator for transforming the vertex by a matrix.
This operator allows for the correct transformation of a vertex's position and normal vector using a 4x4 SRT matrix.
| transform | The transformation matrix. |
| vertex | The vertex to transform. |
| std::array<u16, kMaxNumBoneWeight> nnl::SVertex::bones {0} |
Bone indices.
| glm::vec4 nnl::SVertex::color {1.0f, 1.0f, 1.0f, 1.0f} |
Vertex color (RGBA)
| glm::vec3 nnl::SVertex::normal {0.0f, 1.0f, 0.0f} |
A vertex normal.
| glm::vec3 nnl::SVertex::position {0.0f} |
The position of the vertex in 3D space.
| glm::vec2 nnl::SVertex::uv {0.0f} |
Texture coordinates.
| std::array<float, kMaxNumBoneWeight> nnl::SVertex::weights {1.0f} |
Bone weights. This array must contain at least 1 positive weight.
| struct nnl::STriangle |
Represents a triangle defined by three vertices.
This structure represents a basic triangle defined by three vertices. Its purpose is to simplify the conversion process between various triangle formats such as triangle lists, strips, or fans.
Public Member Functions | |
| const SVertex & | operator[] (std::size_t index) const |
| Accesses a vertex of the triangle by index. | |
| SVertex & | operator[] (std::size_t index) |
| Accesses a vertex of the triangle by index. | |
| bool | IsDegenerate () const |
| Checks if the triangle has no area. | |
| void | ReverseWindingOrder () |
| Changes the winding order of the triangle. | |
Public Attributes | |
| std::array< SVertex, 3 > | vertices |
| The vertices that define the triangle. | |
| bool nnl::STriangle::IsDegenerate | ( | ) | const |
Checks if the triangle has no area.
A triangle is considered degenerate by this function if its area is equal to 0.
| SVertex & nnl::STriangle::operator[] | ( | std::size_t | index | ) |
Accesses a vertex of the triangle by index.
| index | The index of the vertex to access (0, 1, or 2). |
| const SVertex & nnl::STriangle::operator[] | ( | std::size_t | index | ) | const |
Accesses a vertex of the triangle by index.
| index | The index of the vertex to access (0, 1, or 2). |
| void nnl::STriangle::ReverseWindingOrder | ( | ) |
Changes the winding order of the triangle.
| std::array<SVertex, 3> nnl::STriangle::vertices |
The vertices that define the triangle.
| struct nnl::SMesh |
Represents a simple mesh.
This structure defines a simple mesh representation. It acts as an intermediary between common exchange formats (such as glTF and FBX), and in-game formats.
Public Member Functions | |
| void | Join (const SMesh &smesh) |
| Joins another mesh into this mesh. | |
| glm::vec3 | CalculateCenter () const |
| Finds the center of the mesh. | |
| void | ReverseWindingOrder () |
| Reverses the winding order of the mesh's triangles. | |
| void | Transform (const glm::mat4 &transform) |
| Transforms the mesh using a transformation matrix. | |
| void | TransformUV (const glm::mat3 &transform) |
| Transforms the UV coordinates of the mesh using a transformation matrix. | |
| void | RemoveDuplicateVertices () |
| Removes duplicate vertices from the mesh. | |
| void | GenerateSmoothNormals () |
| Generates smooth normals for the mesh. | |
| void | GenerateFlatNormals () |
| Generates flat normals for the mesh. | |
| std::pair< glm::vec3, glm::vec3 > | FindMinMax () const |
| Finds the minimum and maximum points of the mesh. | |
| std::pair< glm::vec2, glm::vec2 > | FindMinMaxUV () const |
| Finds the minimum and maximum UV coordinates of the mesh. | |
| bool | IsAffectedByFewBones () const |
| Checks if the mesh is influenced by at least 2 bones. | |
| bool | HasAlphaVertex () const |
| Checks if the mesh has any transparent vertex colors. | |
| void | NormalizeWeights () |
| Normalizes the weights of the vertices. | |
| void | NormalizeNormals () |
| Normalizes the normals of the vertices. | |
| void | QuantWeights (unsigned int steps=128) |
| Quantizes the vertex weights to a specified number of steps. | |
| void | SortWeights () |
| Sorts vertex weights by influence, placing the highest values first. | |
| void | LimitWeightsPerVertex (unsigned int max_weights=3) |
| Limits the number of weights per vertex. | |
| void | LimitWeightsPerTriangle (unsigned int max_weights=8) |
| Limits the number of unique bone influences per triangle. | |
| void | ResetWeights () |
| Removes all weights. | |
| void | ResetNormals () |
| Resets all vertex normals to the default value. | |
| void | ResetUVs () |
| Resets all texture coordinates to the default value. | |
| void | ResetColors () |
| Resets all vertex colors to the default value. | |
Static Public Member Functions | |
| static SMesh | FromTriangles (const std::vector< STriangle > &triangles) |
| Creates a mesh from a triangle list. | |
| 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. | |
Public Attributes | |
| std::string | name |
| An optional name for the mesh. | |
| std::vector< u32 > | indices |
| The vertex indices that define the triangles. | |
| std::vector< SVertex > | vertices |
| The vertex data for the mesh. | |
| std::size_t | material_id = 0 |
| The ID of the material associated with the mesh. | |
| std::map< std::size_t, std::vector< std::size_t > > | material_variants |
| std::size_t | mesh_group = 0 |
| bool | uses_uv = false |
| Indicates whether the mesh uses texture coordinates. | |
| bool | uses_normal = false |
| Indicates whether the mesh uses vertex normals. | |
| bool | uses_color = false |
| Indicates whether the mesh uses vertex colors. | |
| SValue | extras |
| Any additional data for custom use. | |
| glm::vec3 nnl::SMesh::CalculateCenter | ( | ) | const |
Finds the center of the mesh.
This method calculates the center point of the mesh by averaging the positions of all vertices.
| std::pair< glm::vec3, glm::vec3 > nnl::SMesh::FindMinMax | ( | ) | const |
Finds the minimum and maximum points of the mesh.
This method calculates the minimum and maximum xyz coordinates of the vertices in the mesh.
| std::pair< glm::vec2, glm::vec2 > nnl::SMesh::FindMinMaxUV | ( | ) | const |
Finds the minimum and maximum UV coordinates of the mesh.
This method calculates the minimum and maximum UV coordinates of the vertices in the mesh.
Creates a mesh from a triangle list.
| triangles | The triangles to construct the mesh from. |
| void nnl::SMesh::GenerateFlatNormals | ( | ) |
Generates flat normals for the mesh.
This method calculates flat normals and duplicates vertex data to achieve faceted appearance. It also sets uses_normal to true.
| void nnl::SMesh::GenerateSmoothNormals | ( | ) |
Generates smooth normals for the mesh.
This method calculates smooth normals for smooth shading. It also sets uses_normal to true.
| bool nnl::SMesh::HasAlphaVertex | ( | ) | const |
Checks if the mesh has any transparent vertex colors.
| bool nnl::SMesh::IsAffectedByFewBones | ( | ) | const |
Checks if the mesh is influenced by at least 2 bones.
| void nnl::SMesh::Join | ( | const SMesh & | smesh | ) |
Joins another mesh into this mesh.
This method combines the vertex and index data of the provided mesh with this mesh.
| smesh | The mesh to join with this mesh. |
| void nnl::SMesh::LimitWeightsPerTriangle | ( | unsigned int | max_weights = 8 | ) |
Limits the number of unique bone influences per triangle.
This method restricts the number of unique bones that influence vertices of a triangle to a specified maximum. This may be useful for further conversion of vertices to vertex buffers used by the GE.
| max_weights | The maximum number of weights per triangle. |
| void nnl::SMesh::LimitWeightsPerVertex | ( | unsigned int | max_weights = 3 | ) |
Limits the number of weights per vertex.
This method restricts the number of bone weights that can influence each vertex to a specified maximum. This may be useful for further conversion of vertices to vertex buffers used by the GE.
| max_weights | The maximum number of weights per vertex. |
| void nnl::SMesh::NormalizeNormals | ( | ) |
Normalizes the normals of the vertices.
This method adjusts the vertex normals so that their length is 1.0f.
| void nnl::SMesh::NormalizeWeights | ( | ) |
Normalizes the weights of the vertices.
This method adjusts the vertex weights so that they sum to 1.0f.
| void nnl::SMesh::QuantWeights | ( | unsigned int | steps = 128 | ) |
Quantizes the vertex weights to a specified number of steps.
This method reduces the precision of the vertex weights by quantizing them to a specified number of discrete steps, making sure they still add up to 1.0. This may be used for further conversion of weights to fixed-point integers.
| steps | The number of quantization steps. |
| void nnl::SMesh::RemoveDuplicateVertices | ( | ) |
Removes duplicate vertices from the mesh.
This method removes duplicate vertices and updates the indices.
|
static |
Removes duplicate or unused vertices from the vertex data.
| indices | A vector of indices referencing the vertices. |
| vertices | A vector of vertices. |
| void nnl::SMesh::ResetColors | ( | ) |
Resets all vertex colors to the default value.
| void nnl::SMesh::ResetNormals | ( | ) |
Resets all vertex normals to the default value.
| void nnl::SMesh::ResetUVs | ( | ) |
Resets all texture coordinates to the default value.
| void nnl::SMesh::ResetWeights | ( | ) |
Removes all weights.
| void nnl::SMesh::ReverseWindingOrder | ( | ) |
Reverses the winding order of the mesh's triangles.
This method changes the order of the vertices in each triangle, which affects the front-facing direction for rendering.
| void nnl::SMesh::SortWeights | ( | ) |
Sorts vertex weights by influence, placing the highest values first.
| void nnl::SMesh::Transform | ( | const glm::mat4 & | transform | ) |
Transforms the mesh using a transformation matrix.
This method applies the specified transformation matrix to all vertices in the mesh, modifying their positions and normals.
| transform | The transformation matrix to apply to the mesh. |
| void nnl::SMesh::TransformUV | ( | const glm::mat3 & | transform | ) |
Transforms the UV coordinates of the mesh using a transformation matrix.
This method applies the specified SRT matrix to the UV coordinates of all vertices in the mesh.
| transform | The transformation matrix to apply. |
| SValue nnl::SMesh::extras |
Any additional data for custom use.
| std::vector<u32> nnl::SMesh::indices |
The vertex indices that define the triangles.
| std::size_t nnl::SMesh::material_id = 0 |
The ID of the material associated with the mesh.
| std::map<std::size_t, std::vector<std::size_t> > nnl::SMesh::material_variants |
This map associates replacement material IDs with the variants they are used in.
| std::size_t nnl::SMesh::mesh_group = 0 |
Indicates the group to which this mesh belongs. It may be used for organizing meshes or animating their visibility.
| std::string nnl::SMesh::name |
An optional name for the mesh.
| bool nnl::SMesh::uses_color = false |
Indicates whether the mesh uses vertex colors.
| bool nnl::SMesh::uses_normal = false |
Indicates whether the mesh uses vertex normals.
| bool nnl::SMesh::uses_uv = false |
Indicates whether the mesh uses texture coordinates.
| std::vector<SVertex> nnl::SMesh::vertices |
The vertex data for the mesh.
| struct nnl::SBone |
Represents a bone/joint in a skeletal hierarchy of a 3D model.
This structure represents a bone and its children within a skeletal hierarchy, with their transformations defined in relation to their parent bones.
Public Member Functions | |
| glm::mat4 | GetTransform () const |
| Calculates the local transformation matrix of the bone from the SRT properties. | |
| void | SetTransform (const glm::mat4 &transform) |
| Sets the local SRT properties of the bone. | |
Public Attributes | |
| std::string | name |
| An optional name for the bone. | |
| glm::vec3 | scale {1.0f, 1.0f, 1.0f} |
| The local scale of the bone. | |
| glm::quat | rotation {1.0f, 0.0f, 0.0f, 0.0f} |
| The local rotation of the bone. | |
| glm::vec3 | translation {0.0f, 0.0f, 0.0f} |
| The local translation of the bone. | |
| glm::mat4 | inverse {1.0f} |
| The inverse bind matrix of the bone. | |
| std::vector< SBone > | children |
| The children of this bone. | |
| glm::mat4 nnl::SBone::GetTransform | ( | ) | const |
Calculates the local transformation matrix of the bone from the SRT properties.
| void nnl::SBone::SetTransform | ( | const glm::mat4 & | transform | ) |
Sets the local SRT properties of the bone.
This method decomposes the matrix and sets the local SRT properties.
| transform | The local transformation matrix. |
| std::vector<SBone> nnl::SBone::children |
The children of this bone.
| glm::mat4 nnl::SBone::inverse {1.0f} |
The inverse bind matrix of the bone.
| std::string nnl::SBone::name |
An optional name for the bone.
| glm::quat nnl::SBone::rotation {1.0f, 0.0f, 0.0f, 0.0f} |
The local rotation of the bone.
| glm::vec3 nnl::SBone::scale {1.0f, 1.0f, 1.0f} |
The local scale of the bone.
| glm::vec3 nnl::SBone::translation {0.0f, 0.0f, 0.0f} |
The local translation of the bone.
| struct nnl::SSkeleton |
Represents the skeleton of a 3D model.
Public Member Functions | |
| std::vector< glm::mat4 > | GetGlobalMatrices () const |
| Retrieves the global matrices. | |
| std::vector< glm::mat4 > | GetSkinningMatrices () const |
| Retrieves the skinning matrices for transforming vertices in model space. | |
| void | UpdateInverseMatrices () |
| Updates the inverse matrices from local bone transformations. | |
| std::vector< std::reference_wrapper< const SBone > > | GetBoneRefs () const |
| Retrieves a flat array of references to the bones of the skeleton. | |
| std::vector< std::reference_wrapper< SBone > > | GetBoneRefs () |
| Retrieves a flat array of references to the bones of the skeleton. | |
Public Attributes | |
| std::vector< SBone > | roots |
| std::vector< std::reference_wrapper< SBone > > nnl::SSkeleton::GetBoneRefs | ( | ) |
Retrieves a flat array of references to the bones of the skeleton.
This function traverses the bone hierarchy using pre-order traversal and collects references to each bone.
| std::vector< std::reference_wrapper< const SBone > > nnl::SSkeleton::GetBoneRefs | ( | ) | const |
Retrieves a flat array of references to the bones of the skeleton.
This function traverses the bone hierarchy using pre-order traversal and collects references to each bone.
| std::vector< glm::mat4 > nnl::SSkeleton::GetGlobalMatrices | ( | ) | const |
Retrieves the global matrices.
This function computes accumulated transformations for each bone at their location in the hierarchy.
| std::vector< glm::mat4 > nnl::SSkeleton::GetSkinningMatrices | ( | ) | const |
Retrieves the skinning matrices for transforming vertices in model space.
This function calculates the global matrices and combines them with the inverse matrices to obtain the skinning transformations, which can be further weighted to determine the appropriate transformations for individual vertices in model space.
| void nnl::SSkeleton::UpdateInverseMatrices | ( | ) |
Updates the inverse matrices from local bone transformations.
This function recalculates the inverse matrices for all bones, ensuring they are consistent with the current local transformations.
| std::vector<SBone> nnl::SSkeleton::roots |
This vector contains all the top-level bones that make up the skeleton's hierarchy.
| struct nnl::SMaterial |
Represents a simple material with various properties for 3D rendering.
This structure contains properties defining the appearance of a material that is typical for the Phong reflection model.
Public Member Functions | |
| bool | operator== (const SMaterial &rhs) const |
| Compares two materials for equality. | |
Public Attributes | |
| std::string | name |
| An optional name for the material. | |
| glm::vec3 | specular {0.0f} |
| The specular color of the material. | |
| glm::vec3 | diffuse {1.0f} |
| The diffuse color of the material. | |
| glm::vec3 | ambient {0.5f} |
| The ambient color of the material. | |
| glm::vec3 | emissive {0.0f} |
| The emissive color of the material. | |
| float | opacity = 1.0f |
| The opacity of the material. [0.0, 1.0]. | |
| float | specular_power = 50.0f |
| int | texture_id = -1 |
| bool | lit = false |
| u16 | vfx_group_id = 0 |
| The visual effects group of the material. | |
| SBlendMode | alpha_mode = SBlendMode::kOpaque |
| STextureProjection | projection_mode = STextureProjection::kUV |
| SValue | extras |
| bool nnl::SMaterial::operator== | ( | const SMaterial & | rhs | ) | const |
Compares two materials for equality.
| rhs | The other SMaterial instance to compare against. |
| SBlendMode nnl::SMaterial::alpha_mode = SBlendMode::kOpaque |
Controls how the material is blended with previously drawn fragments
| glm::vec3 nnl::SMaterial::ambient {0.5f} |
The ambient color of the material.
| glm::vec3 nnl::SMaterial::diffuse {1.0f} |
The diffuse color of the material.
| glm::vec3 nnl::SMaterial::emissive {0.0f} |
The emissive color of the material.
| SValue nnl::SMaterial::extras |
Custom additional properties for the material.
| bool nnl::SMaterial::lit = false |
Indicates whether the material also uses the diffuse, specular, and emissive components in addition to the static ambient color, a texture, and vertex colors.
| std::string nnl::SMaterial::name |
An optional name for the material.
| float nnl::SMaterial::opacity = 1.0f |
The opacity of the material. [0.0, 1.0].
| STextureProjection nnl::SMaterial::projection_mode = STextureProjection::kUV |
Controls how textures are projected onto meshes.
| glm::vec3 nnl::SMaterial::specular {0.0f} |
The specular color of the material.
| float nnl::SMaterial::specular_power = 50.0f |
This value determines the intensity and size of specular highlights.
| int nnl::SMaterial::texture_id = -1 |
The ID of the texture associated with the material. -1 indicates no texture.
| u16 nnl::SMaterial::vfx_group_id = 0 |
The visual effects group of the material.
| struct nnl::SAttachment |
Represents a node attached to a bone.
Public Attributes | |
| std::string | name = "" |
| An optional name for the attachment. | |
| std::size_t | id = 0 |
| The id of the struct. | |
| std::size_t | bone = 0 |
| The parent bone. | |
| glm::vec3 | scale {1.0f, 1.0f, 1.0f} |
| Scale transformation. | |
| glm::quat | rotation {1.0f, 0.0f, 0.0f, 0.0f} |
| Rotation transformation. | |
| glm::vec3 | translation {0.0f, 0.0f, 0.0f} |
| Translation transformation. | |
| std::size_t nnl::SAttachment::bone = 0 |
The parent bone.
| std::size_t nnl::SAttachment::id = 0 |
The id of the struct.
| std::string nnl::SAttachment::name = "" |
An optional name for the attachment.
| glm::quat nnl::SAttachment::rotation {1.0f, 0.0f, 0.0f, 0.0f} |
Rotation transformation.
| glm::vec3 nnl::SAttachment::scale {1.0f, 1.0f, 1.0f} |
Scale transformation.
| glm::vec3 nnl::SAttachment::translation {0.0f, 0.0f, 0.0f} |
Translation transformation.
| struct nnl::SModel |
Represents a simple model.
This structure defines essential components of a 3D model. It acts as an intermediary between common exchange formats (such as glTF and FBX) and game-specific formats, supporting features that exist (in one way or another) in different formats.
Public Member Functions | |
| glm::vec3 | CalculateCenter () const |
| Finds the center of the model. | |
| bool | TryBakeBindShape () |
| Bakes bind shape transforms from the inverse matrices into the model. | |
| void | Transform (const glm::mat4 &matrix) |
| Transforms the model using a transformation matrix. | |
| void | TransformUV (const glm::mat3 &matrix) |
| Transforms the UV coordinates of the model using a transformation matrix. | |
| void | RemoveDuplicateMaterials () |
| Removes duplicate materials from the model. | |
| void | GenerateSmoothNormals () |
| Generates smooth normals for the meshes. | |
| void | GenerateFlatNormals () |
| Generates flat normals for the meshes. | |
| std::pair< glm::vec3, glm::vec3 > | FindMinMax () const |
| Finds the minimum and maximum points of the model. | |
| glm::mat4 | Normalize () |
| Normalizes the model to fit within the range of -1.0 to 1.0. | |
| std::vector< std::pair< glm::vec2, glm::vec2 > > | NormalizeUV () |
| Normalizes the UV coordinates of the model. | |
| void | NormalizeWeights () |
| Normalizes the weights of the vertices. | |
| void | NormalizeNormals () |
| Normalizes the normals of the vertices. | |
| void | QuantWeights (unsigned int steps=128) |
| Quantizes the vertex weights to a specified number of steps. | |
| void | SortWeights () |
| Sorts vertex weights by influence, placing the highest values first. | |
| void | LimitWeightsPerVertex (unsigned int max_weights=3) |
| Limits the number of weights per vertex. | |
| void | LimitWeightsPerTriangle (unsigned int max_weights=8) |
| Limits the number of weights per triangle. | |
| void | ResetWeights () |
| Removes all weights. | |
| void | ResetNormals () |
| Resets all vertex normals to the default value. | |
| void | ResetUVs () |
| Resets all texture coordinates to the default value. | |
| void | ResetColors () |
| Resets all vertex colors to the default value. | |
Public Attributes | |
| SSkeleton | skeleton |
| std::vector< SAttachment > | attachments |
| A vector of attachments associated with the model. | |
| std::vector< SMesh > | meshes |
| A vector of meshes that make up the model. | |
| std::vector< SMaterial > | materials |
| A vector of materials used by the meshes. | |
| std::vector< std::string > | material_variants |
| std::vector< SUVAnimation > | uv_animations |
| glm::vec3 nnl::SModel::CalculateCenter | ( | ) | const |
Finds the center of the model.
This method calculates the center point of the mesh by averaging the positions of all mesh vertices.
| std::pair< glm::vec3, glm::vec3 > nnl::SModel::FindMinMax | ( | ) | const |
Finds the minimum and maximum points of the model.
This method finds the minimum and maximum xyz coordinates of the vertices in the model.
| void nnl::SModel::GenerateFlatNormals | ( | ) |
Generates flat normals for the meshes.
This method calculates face normals and duplicates vertex data to achive faceted appearance.
| void nnl::SModel::GenerateSmoothNormals | ( | ) |
Generates smooth normals for the meshes.
This method calculates smooth normals for smooth shading.
| void nnl::SModel::LimitWeightsPerTriangle | ( | unsigned int | max_weights = 8 | ) |
Limits the number of weights per triangle.
This method restricts the number of bone weights that can influence vertices of a triangle to a specified maximum. This may be useful for further conversion of vertices to vertex buffers used by the GE.
| max_weights | The maximum number of weights per triangle. |
| void nnl::SModel::LimitWeightsPerVertex | ( | unsigned int | max_weights = 3 | ) |
Limits the number of weights per vertex.
This method restricts the number of bone weights that can influence each vertex to a specified maximum. This may be useful for further conversion of vertices to vertex buffers used by the GE.
| max_weights | The maximum number of weights per vertex. |
| glm::mat4 nnl::SModel::Normalize | ( | ) |
Normalizes the model to fit within the range of -1.0 to 1.0.
This function changes the model's vertices to ensure they fit within the range of -1.0 to 1.0. It also modifies the inverse matrices so they undo the scaling. This normalization may be useful for converting positions to fixed-point integers.
| void nnl::SModel::NormalizeNormals | ( | ) |
Normalizes the normals of the vertices.
This method adjusts the vertex normals so that their length is 1.0f.
| std::vector< std::pair< glm::vec2, glm::vec2 > > nnl::SModel::NormalizeUV | ( | ) |
Normalizes the UV coordinates of the model.
This function rescales the UV coordinates to ensure they fit within the range of 0.0 to 1.0. Each mesh group is normalized independently. This normalization may be useful for converting texture coordinates to fixed-point integers.
| void nnl::SModel::NormalizeWeights | ( | ) |
Normalizes the weights of the vertices.
This method adjusts the vertex weights so that they sum to 1.0f.
| void nnl::SModel::QuantWeights | ( | unsigned int | steps = 128 | ) |
Quantizes the vertex weights to a specified number of steps.
This method reduces the precision of the vertex weights by quantizing them to a specified number of discrete steps, making sure they still add up to 1.0. This may be used for further conversion of weights to fixed-point integers.
| steps | The number of quantization steps. |
| void nnl::SModel::RemoveDuplicateMaterials | ( | ) |
Removes duplicate materials from the model.
This function removes any materials that are identical, which may improve the performance.
| void nnl::SModel::ResetColors | ( | ) |
Resets all vertex colors to the default value.
| void nnl::SModel::ResetNormals | ( | ) |
Resets all vertex normals to the default value.
| void nnl::SModel::ResetUVs | ( | ) |
Resets all texture coordinates to the default value.
| void nnl::SModel::ResetWeights | ( | ) |
Removes all weights.
| void nnl::SModel::SortWeights | ( | ) |
Sorts vertex weights by influence, placing the highest values first.
| void nnl::SModel::Transform | ( | const glm::mat4 & | matrix | ) |
Transforms the model using a transformation matrix.
This method applies the specified transformation matrix to all vertices in the model, modifying their positions and normals.
| matrix | The transformation matrix to apply. |
| void nnl::SModel::TransformUV | ( | const glm::mat3 & | matrix | ) |
Transforms the UV coordinates of the model using a transformation matrix.
This method applies the specified SRT matrix to the UV coordinates of all vertices in the model.
| matrix | The transformation matrix to apply. |
| bool nnl::SModel::TryBakeBindShape | ( | ) |
Bakes bind shape transforms from the inverse matrices into the model.
This method applies "bind shape matrices" that may be contained in inverse bind matrices to mesh vertices. If some matrices are non-invertible, it returns false.
Inverse matrices often include a scaling matrix to revert the model to its original proportions after normalization to the range of [-1.0, 1.0].
| std::vector<SAttachment> nnl::SModel::attachments |
A vector of attachments associated with the model.
| std::vector<std::string> nnl::SModel::material_variants |
Represents material variants similar to those found in the glTF format. When a specific variant is active, the material of a mesh changes to the corresponding material specified in the mesh's variant mapping.
| std::vector<SMaterial> nnl::SModel::materials |
A vector of materials used by the meshes.
| std::vector<SMesh> nnl::SModel::meshes |
A vector of meshes that make up the model.
| SSkeleton nnl::SModel::skeleton |
The skeleton associated with the model. It must contain at least 1 bone.
| std::vector<SUVAnimation> nnl::SModel::uv_animations |
A vector of texture coordinate animations for textured materials
|
strong |
Enumeration of blending modes for materials.
|
strong |
Enumeration of projection modes for textures.
| Enumerator | |
|---|---|
| kUV | Standard UV mapping. |
| kMatrix | Matrix-based projection. |
| kEnvironment | Environment mapping projection. |
|
constexpr |
Maximum number of bone weights and indices in SVertex.