NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Auxiliary

Classes

struct  nnl::model::TriangleGroup
 Represents a group of triangles associated with specific bones. More...

Macros

#define NNL_UVANIM_MAX_DUR   1000
 The maximum duration of a texture coordinate animation.

Enumerations

enum  nnl::model::GeCmd : u32 {
  nnl::model::kReturn = 0x0B'00'00'00 , nnl::model::kSetVertexType = 0x12'00'00'00 , nnl::model::kSetBaseAddress = 0x10'00'00'00 , nnl::model::kSetVramAddress = 0x01'00'00'00 ,
  nnl::model::kDrawPrimitives = 0x04'00'00'00
}
 Enumeration of essential rendering commands for the library. More...
enum  nnl::model::HumanoidRigTarget : BoneTarget
 Enum representing parts of a generic humanoid rig. More...

Functions

std::vector< STrianglennl::model::ExtractTriangles (const SubMesh &submesh, bool skip_degenerate=true)
 Extracts triangles from a given submesh.
std::vector< TriangleGroupnnl::model::GroupTrianglesByBones (const std::vector< u32 > &indices, const std::vector< SVertex > &vertices, u32 max_num_triangles=std::numeric_limits< u16 >::max()/3, bool join_bone_sets=true)
 Groups triangles by their associated bones.
BBox nnl::model::GenerateBBox (const SMesh &mesh, glm::mat4 transform=glm::mat4(1.0f))
 Generates an axis-aligned bounding box (AABB) for the given mesh.
Mesh nnl::model::Convert (SMesh &&smesh, const ConvertParam &param={})
 Converts a simplified representation of a mesh to the in-game format.
SMesh nnl::model::Convert (const Mesh &mesh)
 Converts a mesh from the in-game format to a simplified representation.
ConvertParam nnl::model::GenerateConvertParam (const Mesh &mesh)
 Generates a conversion parameter for SMesh to get a similar in-game Mesh when converting back to it.
std::vector< ConvertParamnnl::model::GenerateConvertParam (const Model &model)
 Generates a vector of conversion parameters for the entire model to achieve a similar in-game representation.
std::vector< Bonennl::model::Convert (const SSkeleton &skeleton)
 Converts a skeleton represented as a tree into a vector of bones.
void nnl::model::SetBoneNames (SSkeleton &skeleton, const std::vector< std::map< BoneTarget, BoneIndex > > &bone_target_tables, bool is_character=true)
 Assigns meaningful names to bones in a skeleton.
std::vector< std::map< BoneTarget, BoneIndex > > nnl::model::GenerateBoneTargetTables (const SSkeleton &skeleton)
 Generates bone target tables from bone names of the skeleton.
SSkeleton nnl::model::Convert (const std::vector< Bone > &bones)
 Converts a vector of bones into a simple tree-like skeleton representation.
std::map< BoneIndex, glm::mat4 > nnl::model::GenerateInverseMatrixBoneTable (const SModel &smodel)
 Generates a map of bone indices and inverse matrices.
UVAnimation nnl::model::Convert (const SUVChannel &suv_anim_channel)
 Converts a simple UV animation channel to an in-game UVAnimation config.
SUVChannel nnl::model::Convert (const UVAnimation &uv_anim)
 Converts an in-game UVAnimation config to a simple UV animation channel.
Material nnl::model::Convert (const SMaterial &smat)
 Converts SMaterial to Material.
SMaterial nnl::model::Convert (const Material &mat)
 Converts Material to SMaterial.

Variables

constexpr std::array< std::string_view, 30 > nnl::model::bone_target_names
 An array that associates a generic bone id with a name.

Detailed Description


Class Documentation

◆ nnl::model::TriangleGroup

struct nnl::model::TriangleGroup

Represents a group of triangles associated with specific bones.

This type consists of unique bone IDs and a vector of triangle indices.

See also
nnl::model::GroupTrianglesByBones

Public Attributes

utl::StaticSet< BoneIndex, kMaxNumBonePerPrimbones
 Unique bones.
std::vector< u32indices
 Triangles associated with the bones.

Member Data Documentation

◆ bones

utl::StaticSet<BoneIndex, kMaxNumBonePerPrim> nnl::model::TriangleGroup::bones

Unique bones.

◆ indices

std::vector<u32> nnl::model::TriangleGroup::indices

Triangles associated with the bones.

Macro Definition Documentation

◆ NNL_UVANIM_MAX_DUR

#define NNL_UVANIM_MAX_DUR   1000

The maximum duration of a texture coordinate animation.

This macro defines the maximum duration of a UV animation when converted from the in-game format to a more generalized format. The default value typically allows for seamless looping of animations within that timeframe. However, it can be changed as needed.

See also
nnl::model::UVAnimation
nnl::SUVAnimation

Enumeration Type Documentation

◆ GeCmd

Enumeration of essential rendering commands for the library.

This enum defines a few rendering commands used by the Graphics Engine (GE).

Each command is represented by a 32-bit value, where the first byte indicates the command, and the remaining bytes store its arguments.

Enumerator
kReturn 

Marks the end of the display list.

kSetVertexType 

Sets the vertex format. Indicates the rendering modes, the attributes used, their formats

See also
nnl::vertexde::fmt
kSetBaseAddress 

Sets the base address; The command must be present in a display list. Arguments are filled dynamically by the game engine.

kSetVramAddress 

Sets the address for vertex data; The command must be present in a display list. Arguments are filled dynamically by the game engine.

kDrawPrimitives 

Command to draw primitives based on the current vertex data. Expects a primitve type (8 bits) and a number of elements as its arguments (last 16 bits). Number of elements is a number of vertices or indices.

See also
nnl::model::PrimitiveType

◆ HumanoidRigTarget

Enum representing parts of a generic humanoid rig.

This enum defines generic identifiers for different parts of a humanoid rig. These identifiers can be used by the games to access specific bones in a skeleton for procedural animation and effect attachment.

See also
nnl::model::BoneTarget
nnl::model::Model::bone_target_tables

Function Documentation

◆ Convert() [1/8]

SMaterial nnl::model::Convert ( const Material & mat)

Converts Material to SMaterial.

Parameters
mat
Returns
Material

◆ Convert() [2/8]

SMesh nnl::model::Convert ( const Mesh & mesh)

Converts a mesh from the in-game format to a simplified representation.

Parameters
meshThe mesh to be converted
Returns
The converted mesh.

◆ Convert() [3/8]

Material nnl::model::Convert ( const SMaterial & smat)

Converts SMaterial to Material.

Parameters
smat
Returns
Material

◆ Convert() [4/8]

std::vector< Bone > nnl::model::Convert ( const SSkeleton & skeleton)

Converts a skeleton represented as a tree into a vector of bones.

This function takes an SSkeleton and converts it into a vector of Bone structures.

Parameters
skeletonThe input skeleton.
Returns
A vector of Bone structures representing the converted skeleton.

◆ Convert() [5/8]

SSkeleton nnl::model::Convert ( const std::vector< Bone > & bones)

Converts a vector of bones into a simple tree-like skeleton representation.

This function transforms a vector of Bone structures into an SSkeleton object, organizing the bones into a hierarchical structure.

Parameters
bonesA vector of Bone structures to be converted into a skeleton.
Returns
An SSkeleton that represents the hierarchical skeleton structure.

◆ Convert() [6/8]

UVAnimation nnl::model::Convert ( const SUVChannel & suv_anim_channel)

Converts a simple UV animation channel to an in-game UVAnimation config.

Parameters
suv_anim_channel
Returns
UVAnimaion
Note
SUVChannel represents a generic texture coordinate animation. Only a few types of animation can be detected and converted into a UVAnimation config.

◆ Convert() [7/8]

SUVChannel nnl::model::Convert ( const UVAnimation & uv_anim)

Converts an in-game UVAnimation config to a simple UV animation channel.

Parameters
uv_anim
Returns
SUVChannel

◆ Convert() [8/8]

Mesh nnl::model::Convert ( SMesh && smesh,
const ConvertParam & param = {} )

Converts a simplified representation of a mesh to the in-game format.

Parameters
smeshThe source mesh to be converted.
paramThe parameters that dictate how the conversion should be performed.
Returns
The converted mesh.
Note
Use std::move when passing an existing object.

◆ ExtractTriangles()

std::vector< STriangle > nnl::model::ExtractTriangles ( const SubMesh & submesh,
bool skip_degenerate = true )

Extracts triangles from a given submesh.

This function processes the given submesh, which can be in multiple formats, to extract its triangles into a simpler representation.

Parameters
submeshThe submesh from which to extract triangles.
skip_degenerateA boolean flag indicating whether to skip 0 area triangles.
Returns
A list of triangles

◆ GenerateBBox()

BBox nnl::model::GenerateBBox ( const SMesh & mesh,
glm::mat4 transform = glm::mat4(1.0f) )

Generates an axis-aligned bounding box (AABB) for the given mesh.

This function computes the bounding box, and applies the provided transformation matrix to it. The resulting bounding box is represented as a BBox object.

Parameters
meshThe mesh for which to generate the bounding box.
transformA transformation matrix to be applied to the bbox.
Returns
The generated BBox object.

◆ GenerateBoneTargetTables()

std::vector< std::map< BoneTarget, BoneIndex > > nnl::model::GenerateBoneTargetTables ( const SSkeleton & skeleton)

Generates bone target tables from bone names of the skeleton.

This function creates a vector of tables that associate bone targets with concrete bone indices based on the bone names of the provided SSkeleton.

Parameters
skeletonThe input SSkeleton from which the bone target tables will be generated.
Returns
A vector of tables linking bone targets to bone indices.
See also
nnl::model::BoneTarget
nnl::model::SetBoneNames

◆ GenerateConvertParam() [1/2]

ConvertParam nnl::model::GenerateConvertParam ( const Mesh & mesh)

Generates a conversion parameter for SMesh to get a similar in-game Mesh when converting back to it.

Parameters
meshThe source mesh in the in-game format from which to generate conversion parameters.
Returns
A ConvertParam object.

◆ GenerateConvertParam() [2/2]

std::vector< ConvertParam > nnl::model::GenerateConvertParam ( const Model & model)

Generates a vector of conversion parameters for the entire model to achieve a similar in-game representation.

This function attempts to create a collection of ConvertParam objects that would result in a similar in-game model when converting from a source model (SModel) back to the in-game format (Model).

Parameters
modelThe source model from which to generate conversion parameters.
Returns
A vector of ConvertParam objects

◆ GenerateInverseMatrixBoneTable()

std::map< BoneIndex, glm::mat4 > nnl::model::GenerateInverseMatrixBoneTable ( const SModel & smodel)

Generates a map of bone indices and inverse matrices.

This function creates a map of bone indices and their corresponding inverse matrices. Note that an entry in this table can be omitted if there is no meshes attached to the corresponding bone.

Parameters
smodelThe input SModel containing meshes and a skeleton.
Returns
A map where each entry consists of a bone index and its corresponding inverse matrix.
See also
nnl::model::Model::inverse_matrix_bone_table

◆ GroupTrianglesByBones()

std::vector< TriangleGroup > nnl::model::GroupTrianglesByBones ( const std::vector< u32 > & indices,
const std::vector< SVertex > & vertices,
u32 max_num_triangles = std::numeric_limits< u16 >::max()/3,
bool join_bone_sets = true )

Groups triangles by their associated bones.

This function slices triangles into groups based on the bones that influence them. These groups are used to create SubMeshes.

Parameters
indicesA vector of triangle indices to be grouped.
verticesA vector of vertices associated with the triangles.
join_bone_setsWhether to join different bone sets into larger ones. This may reduce the number of draw calls but increase the size of an asset.
max_num_trianglesThe maximum number of triangles allowed in a group. The choice of this number depends on the index type and the primitive type a SubMesh uses.
Returns
A vector of TriangleGroup objects.

◆ SetBoneNames()

void nnl::model::SetBoneNames ( SSkeleton & skeleton,
const std::vector< std::map< BoneTarget, BoneIndex > > & bone_target_tables,
bool is_character = true )

Assigns meaningful names to bones in a skeleton.

This function assigns more meaningful names to the bones in the provided SSkeleton based on the specified bone_target_tables.

The new names can also be used to recreate the source bone_target_tables.

Note
A single bone may be associated with multiple BoneTarget's in which case an underscore (_) is used to separate them. Those targets may also belong to different tables in which case a vertical bar (|) is used to split them.
Parameters
skeletonAn SSkeleton whose bones will be renamed.
bone_target_tablesTables that associate bone targets with concrete bone indices. This information is used to determine the appropriate names for each bone.
is_characterA flag indicating whether to use a humanoid bone naming convention. If false, bone target names will consist of the prefix VFX followed by a target id.
See also
nnl::model::BoneTarget
nnl::model::GenerateBoneTargetTables
nnl::model::HumanoidRigTarget
nnl::model::bone_target_names

Variable Documentation

◆ bone_target_names

std::array<std::string_view, 30> nnl::model::bone_target_names
constexpr
Initial value:
{
"Root", "Hips", "Spine", "Spine1", "Neck", "Head",
"LeftShoulder", "LeftArm", "LeftForeArm", "LeftHand", "RightShoulder", "RightArm",
"RightForeArm", "RightHand", "LeftUpLeg", "LeftLeg", "LeftFoot", "RightUpLeg",
"RightLeg", "RightFoot", "BodyPart20", "BodyPart21", "BodyPart22", "BodyPart23",
"BodyPart24", "BodyPart25", "BodyPart26", "BodyPart27", "BodyPart28", "BodyPart29"}

An array that associates a generic bone id with a name.

See also
nnl::model::BoneTarget
nnl::model::GenerateBoneTargetTables
nnl::model::SetBoneNames
nnl::model::HumanoidRigTarget