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

Classes

struct  nnl::model::Bone
 Represents a bone/joint in a skeleton. More...
struct  nnl::model::TextureSwap
 Represents a configuration for texture swapping. More...
struct  nnl::model::UVAnimation
 Represents a UV animation configuration. More...
struct  nnl::model::Attachment
 Represents a configuration for attaching an external object to a model. More...
struct  nnl::model::BBox
 Represents a bounding box for objects. More...
struct  nnl::model::Primitive
 Represents the smallest unit of geometry in the hierarchy. More...
struct  nnl::model::SubMesh
 Represents a smaller part of a mesh. More...
struct  nnl::model::Mesh
 This struct defines various properties of a mesh. More...
struct  nnl::model::MeshGroup
 Represents a group of meshes. More...
struct  nnl::model::Material
 Represents the properties of a material. More...
struct  nnl::model::Model
 Represents a 3D model with various components. More...
struct  nnl::model::ConvertParam
 Parameters for converting a simplified mesh to the in-game format. More...

Enumerations

enum class  nnl::model::UVAnimationMode : u16 { nnl::model::UVAnimationMode::kNone = 0 , nnl::model::UVAnimationMode::kContinuousShift = 1 , nnl::model::UVAnimationMode::kRangedShift = 2 , nnl::model::UVAnimationMode::kFramedShift = 3 }
 Specifies the different modes of UV animation for textures. More...
enum class  nnl::model::PrimitiveType : u16
 Enumeration of supported primitive types. More...
enum class  nnl::model::MaterialFeatures : u16 {
  nnl::model::MaterialFeatures::kNone = 0 , nnl::model::MaterialFeatures::kVertexColors = 0b000000001 , nnl::model::MaterialFeatures::kLit = 0b000000010 , nnl::model::MaterialFeatures::kProjectionMapping = 0b000000100 ,
  nnl::model::MaterialFeatures::kAdditiveBlending = 0b000001000 , nnl::model::MaterialFeatures::kSubtractiveBlending = 0b000010000 , nnl::model::MaterialFeatures::kNoDepthWriteDefer = 0b000100000 , nnl::model::MaterialFeatures::kAlphaClip = 0b001000000 ,
  nnl::model::MaterialFeatures::kSkinning = 0b010000000 , nnl::model::MaterialFeatures::kEnvironmentMapping = 0b100000000
}
 Enumeration of material features used in rendering. More...
enum class  nnl::model::CompLvl { nnl::model::CompLvl::kNone = 0 , nnl::model::CompLvl::kMedium = 1 , nnl::model::CompLvl::kMax = 2 }
 Enum representing compression levels for mesh conversion. More...

Functions

Model nnl::model::Convert (SModel &&smodel, const std::vector< ConvertParam > &mesh_params, bool move_with_root=false)
 Converts a simplified model representation to the in-game format.
Model nnl::model::Convert (SModel &&smodel, const ConvertParam &mesh_params={}, bool move_with_root=false)
 Converts a simplified model representation to the in-game format.
SModel nnl::model::Convert (const Model &model)
 Converts a game model to a simplified model representation.
bool nnl::model::IsOfType (BufferView buffer)
 Tests if the provided file is a model.
Model nnl::model::Import (BufferView buffer)
 Parses a binary file and converts it to a structured model.
Buffer nnl::model::Export (const Model &model)
 Converts a model to its binary file representation.

Variables

constexpr std::size_t nnl::model::kMaxNumBonePerPrim = 8
 Maximum number of bones that can influence a single primitive and a single vertex.

Detailed Description


Class Documentation

◆ nnl::model::Bone

struct nnl::model::Bone

Represents a bone/joint in a skeleton.

This struct defines the properties of a bone, as well as its relation to its parent bone in the hierarchy. The transformation properties are relative to the bone's parent. A complete skeleton is represented as an array of such Bone structures (which can be created by performing a preorder traversal of a tree that defines the skeletal hierarchy.)

See also
nnl::model::Model

Public Attributes

i16 parent_index = -1
 An index into the array of bones; -1 means a bone has no parent.
glm::vec3 scale {1.0f}
 The scale transform.
glm::vec3 rotation {0.0f}
glm::vec3 translation {0.0f}
 The translation transform.

Member Data Documentation

◆ parent_index

i16 nnl::model::Bone::parent_index = -1

An index into the array of bones; -1 means a bone has no parent.

◆ rotation

glm::vec3 nnl::model::Bone::rotation {0.0f}

Pitch, Yaw, Roll. Euler angles in degrees. Each value must be in the range [-180, +180]

◆ scale

glm::vec3 nnl::model::Bone::scale {1.0f}

The scale transform.

◆ translation

glm::vec3 nnl::model::Bone::translation {0.0f}

The translation transform.

◆ nnl::model::TextureSwap

struct nnl::model::TextureSwap

Represents a configuration for texture swapping.

This struct defines a texture swap configuration that specifies the original texture index and a new texture index that the original texture can be swapped with.

A texture swap can be activated by an action configuration or from the game's code. Texture swaps are primarily used to imitate facial animations.

See also
nnl::model::Model
nnl::action::ActionConfig

◆ nnl::model::UVAnimation

struct nnl::model::UVAnimation

Represents a UV animation configuration.

This struct defines the properties for UV animation, allowing for various types of texture shifting effects. The behavior of the animation is determined by the specified animation mode, which affects the exact interpretation of num_frames, u_shift, and v_shift.

Note
At least one instance of this structure must be present in a model (the default value for uv_animation_id is 0). The first instance does not animate anything no matter the settings.
See also
nnl::model::UVAnimationMode
nnl::model::Material

Public Attributes

UVAnimationMode animation_mode = UVAnimationMode::kNone
 Defines how shifting occurs.
u16 num_frames = 0
f32 u_shift = 0
f32 v_shift = 0
 Same as u_shift but for the v coordinate.

Member Data Documentation

◆ animation_mode

UVAnimationMode nnl::model::UVAnimation::animation_mode = UVAnimationMode::kNone

Defines how shifting occurs.

◆ num_frames

u16 nnl::model::UVAnimation::num_frames = 0

The number of frames for the animation. When animation_mode is kRangedShift, this denotes the total duration of a cycle. When animation_mode is kFramedShift, shifting occurs every num_frames. Ignored otherwise.

◆ u_shift

f32 nnl::model::UVAnimation::u_shift = 0

When animation_mode is kRangedShift, this denotes the radius of the shape (v_shift should be the same for a circle). In other modes, this value is simply added to texture coordinates as is. This value usually should be in the range (-1.0, 1.0)

◆ v_shift

f32 nnl::model::UVAnimation::v_shift = 0

Same as u_shift but for the v coordinate.

◆ nnl::model::Attachment

struct nnl::model::Attachment

Represents a configuration for attaching an external object to a model.

This structure is used to define the transformation properties of a separate 3D asset attached to a bone. The feature is sometimes used in NSLAR cutscenes.

See also
nnl::model::Model

Public Attributes

BoneIndex bone_id = 0
u16 attachment_id = 0
glm::mat4 transform {1.0f}

Member Data Documentation

◆ attachment_id

u16 nnl::model::Attachment::attachment_id = 0

A number that serves as the identifier for this struct. The game looks for this id.

◆ bone_id

BoneIndex nnl::model::Attachment::bone_id = 0

The index of the bone to which the attachment should be connected.

◆ transform

glm::mat4 nnl::model::Attachment::transform {1.0f}

A transformation matrix for the attachment (relative to the parent bone)

◆ nnl::model::BBox

struct nnl::model::BBox

Represents a bounding box for objects.

This structure defines a bounding box that is used for frustum culling of map objects (it has no effect on characters)

The bounding box is defined by two vertices, which represent the corners of the box in 3D space.

Note
The vertices must be pre-transformed if necessary. The BBox inherits the transform of its parent bone; however, an inverse matrix is not applied to it automatically.
See also
nnl::model::Mesh
nnl::model::GenerateBBox

Public Attributes

BoneIndex bone_index = 0
glm::vec3 min {0.0f}
 The min coordinate.
glm::vec3 max {0.0f}
 The max coordinate.

Member Data Documentation

◆ bone_index

BoneIndex nnl::model::BBox::bone_index = 0

Index of the bone the BBox is attached to (usually the root bone).

◆ max

glm::vec3 nnl::model::BBox::max {0.0f}

The max coordinate.

◆ min

glm::vec3 nnl::model::BBox::min {0.0f}

The min coordinate.

◆ nnl::model::Primitive

struct nnl::model::Primitive

Represents the smallest unit of geometry in the hierarchy.

The Primitive struct encapsulates details about the primitive type used, the number of elements contained, and the associated data buffer. For instance, when using PrimitiveType::kTriangles, the buffer may contain 3 or more vertices to represent one or multiple triangles.

See also
nnl::model::SubMesh
nnl::vertexde::Decode

Public Attributes

PrimitiveType primitive_type = PrimitiveType::kTriangles
 Type of the primitive.
u16 num_elements = 0
Buffer vertex_index_buffer

Member Data Documentation

◆ num_elements

u16 nnl::model::Primitive::num_elements = 0

Represents the number of vertices or indices stored in the vertex_index_buffer.

◆ primitive_type

PrimitiveType nnl::model::Primitive::primitive_type = PrimitiveType::kTriangles

Type of the primitive.

◆ vertex_index_buffer

Buffer nnl::model::Primitive::vertex_index_buffer

Stores either vertices or indices (determined by vertex_format). If indexed drawing is used, the indices refer to the indexed_vertex_buffer from the parent SubMesh.

◆ nnl::model::SubMesh

struct nnl::model::SubMesh

Represents a smaller part of a mesh.

This struct represents a smaller part of a mesh. It exists mainly due to the fact that the PSP's Graphics Engine can hold only 8 skin matrices at a time when rendering a Primitive. Therefore, primitives that share bones need to be grouped into these structs to be drawn. There is usually only 1 such struct if a mesh does not use skinning. If a mesh is too big to fit into 1 submesh, it can also be sliced into multiple parts.

Note
A submesh is always influenced by at least 1 bone. Therefore, the skeleton must contain at least 1 entry, which is essential for positioning the object in the world. It is not necessary to include weights into the vertex data when a submesh is influenced by only 1 bone.

In NSUNI, it is possible to set num_bones to 0 in a specific edge case. If a mesh is influenced by multiple bones and uses multiple weights, the flag use_skinning must be set to true. However, when slicing it into submeshes, some of them may end up using only 1 bone. In this situation, to omit the inclusion of 1 weight into the vertex data, num_bones may be set to 0. However, the first bone index will be used anyway. This approach is not supported by NSLAR and will lead to partial rendering of the model.
See also
nnl::model::Mesh

Public Attributes

u16 num_bones = 1
u32 vertex_format = 0
Buffer indexed_vertex_buffer
std::vector< Primitiveprimitives
 List of primitives that make up this submesh.
std::array< BoneIndex, kMaxNumBonePerPrimbone_indices {0}
std::vector< u32display_list

Member Data Documentation

◆ bone_indices

std::array<BoneIndex, kMaxNumBonePerPrim> nnl::model::SubMesh::bone_indices {0}

Indices of the bones influencing this submesh. Every bone used by submeshes must have a corresponding entry in the inverse_matrix_bone_table

See also
nnl::model::Model::inverse_matrix_bone_table

◆ display_list

std::vector<u32> nnl::model::SubMesh::display_list

A list of rendering commands for drawing the primitives in this submesh. It must contain at least 4 basic commands per each primitive. Additional commands may also be inserted, in which case they must be located right before the draw command or after it (otherwise, the games may alter the list).

Note
These display commands are only effective when indexed drawing is not used. If indexed drawing is enabled, this list is ignored by the games.
See also
nnl::model::GeCmd

◆ indexed_vertex_buffer

Buffer nnl::model::SubMesh::indexed_vertex_buffer

If vertex_format is set to use indices, this buffer must store unique vertices. In that case, buffers in primitives store indices that refer to this buffer. It's empty otherwise.

◆ num_bones

u16 nnl::model::SubMesh::num_bones = 1

The number of bones this submesh refers to. Typically, this value must be within the range of 1 to 8 (0 is allowed in a specific edge case)

◆ primitives

std::vector<Primitive> nnl::model::SubMesh::primitives

List of primitives that make up this submesh.

◆ vertex_format

u32 nnl::model::SubMesh::vertex_format = 0

The format of the vertex data. It matches what the GE expects

See also
nnl::vertexde::fmt

◆ nnl::model::Mesh

struct nnl::model::Mesh

This struct defines various properties of a mesh.

See also
nnl::model::MeshGroup

Public Attributes

std::vector< SubMeshsubmeshes
bool use_skinning = false
bool use_bbox = false
 Flag indicating whether to use the bounding box.
BBox bbox
 The bounding box of the mesh.
u16 material_id = 0
 The index of the material associated with this mesh.

Member Data Documentation

◆ bbox

BBox nnl::model::Mesh::bbox

The bounding box of the mesh.

◆ material_id

u16 nnl::model::Mesh::material_id = 0

The index of the material associated with this mesh.

◆ submeshes

std::vector<SubMesh> nnl::model::Mesh::submeshes

A collection of submeshes that make up the mesh (1 or more)

◆ use_bbox

bool nnl::model::Mesh::use_bbox = false

Flag indicating whether to use the bounding box.

◆ use_skinning

bool nnl::model::Mesh::use_skinning = false

Flag indicating whether skinning is applied to the mesh. It should be active for meshes that include weights into their vertex data and are influenced by multiple bones. In other cases, it should be set to false.

◆ nnl::model::MeshGroup

struct nnl::model::MeshGroup

Represents a group of meshes.

This struct groups multiple meshes together. The visibility of these groups may be animated. This struct also enables texture coordinate adjustments, which are used to restore the origianl UV coordinates when they are stored as normalized integers.

Note
The visibility of a group can be influenced by multiple external sources at once: an action config, the game's code, a dedicated visibility animation file.
See also
nnl::model::Mesh
nnl::visanimation::AnimationContainer
nnl::action::ActionConfig

Public Attributes

std::vector< Meshmeshes
 Collection of meshes that belong to this group.
f32 u_scale = 1.0f
 Scale factor for the U texture coordinate.
f32 v_scale = 1.0f
 Scale factor for the V texture coordinate.
f32 u_offset = 0.0f
 Offset for the U texture coordinate.
f32 v_offset = 0.0f
 Offset for the V texture coordinate.

Member Data Documentation

◆ meshes

std::vector<Mesh> nnl::model::MeshGroup::meshes

Collection of meshes that belong to this group.

◆ u_offset

f32 nnl::model::MeshGroup::u_offset = 0.0f

Offset for the U texture coordinate.

◆ u_scale

f32 nnl::model::MeshGroup::u_scale = 1.0f

Scale factor for the U texture coordinate.

◆ v_offset

f32 nnl::model::MeshGroup::v_offset = 0.0f

Offset for the V texture coordinate.

◆ v_scale

f32 nnl::model::MeshGroup::v_scale = 1.0f

Scale factor for the V texture coordinate.

◆ nnl::model::Material

struct nnl::model::Material

Represents the properties of a material.

This struct defines various attributes of a material that determine the look of the mesh that uses it.

By default, the material does not interact with lights and only the ambient component, vertex colors, and a texture are used. To change that the kLit flag may be activated, which enables the use of the Phong reflection model.
The alpha component of the ambient color can be utilized for setting transparency. The specular component is often unused and invisible unless the light source configuration is changed.

See also
nnl::model::MaterialFeatures
nnl::lit::Lit

Public Attributes

u32 specular = 0xFF000000
u32 diffuse = 0xFFFFFFFF
u32 ambient = 0xFF808080
u32 emissive = 0xFF000000
f32 specular_power = 50.0f
 Power of the specular highlight.
i16 texture_id = -1
 Index of the texture; -1 indicates no texture.
u8 uv_animation_id = 0
u8 vfx_group_id = 0
MaterialFeatures features {}
 Render settings for the material.

Member Data Documentation

◆ ambient

u32 nnl::model::Material::ambient = 0xFF808080

Ambient/constant color of the material in the ABGR format (alpha is used).

◆ diffuse

u32 nnl::model::Material::diffuse = 0xFFFFFFFF

Diffuse color of the material in the ABGR format (alpha is ignored).

◆ emissive

u32 nnl::model::Material::emissive = 0xFF000000

Emissive color of the material in the ABGR format (alpha is ignored).

◆ features

MaterialFeatures nnl::model::Material::features {}

Render settings for the material.

◆ specular

u32 nnl::model::Material::specular = 0xFF000000

Specular color of the material in the ABGR format (alpha is ignored).

◆ specular_power

f32 nnl::model::Material::specular_power = 50.0f

Power of the specular highlight.

◆ texture_id

i16 nnl::model::Material::texture_id = -1

Index of the texture; -1 indicates no texture.

◆ uv_animation_id

u8 nnl::model::Material::uv_animation_id = 0

Index of UV animation; 0 indicates no animation.

See also
nnl::model::UVAnimation

◆ vfx_group_id

u8 nnl::model::Material::vfx_group_id = 0

Identifier for the material's visual effects group. Various effects can be applied to meshes of that group by the game. For instance, in NSUNI, in character assets, a value of 1 is used to make "outline" meshes black and "silhouette" meshes (when a character runs) semi-transparent.

◆ nnl::model::Model

struct nnl::model::Model

Represents a 3D model with various components.

Note
This struct usually stores only a portion of the data required by a 3D asset to function properly. Its binary representation must be used as part of a larger container that may also include textures, animations and other data.
See also
nnl::asset::Asset
nnl::asset::Asset3D
nnl::texture::TextureContainer
nnl::animation::AnimationContainer
nnl::action::ActionConfig
nnl::colbox::ColBoxConfig
nnl::visanimation::AnimationContainer
nnl::collision::Collision
nnl::shadow_collision::Collision

Public Attributes

std::vector< Boneskeleton
bool move_with_root = false
std::map< BoneIndex, glm::mat4 > inverse_matrix_bone_table
std::vector< std::map< BoneTarget, BoneIndex > > bone_target_tables
std::vector< TextureSwaptexture_swaps
std::vector< Attachmentattachments
std::vector< UVAnimationuv_animations
std::vector< MeshGroupmesh_groups
std::vector< Materialmaterials

Member Data Documentation

◆ attachments

std::vector<Attachment> nnl::model::Model::attachments

A collection of attachment configs for external objects.

◆ bone_target_tables

std::vector<std::map<BoneTarget, BoneIndex> > nnl::model::Model::bone_target_tables

An optional collection of bone target tables. Each table maps generic numeric IDs to concrete bone indices, enabling the game to target specific bones. For example, this allows the game to identify which bone corresponds to the right hand for attaching effects. There are at most 2 such tables present in game assets. 1 table is usually present in character assets. 2 tables are sometimes used in effect assets.

See also
nnl::model::BoneTarget
nnl::model::HumanoidRigTarget

◆ inverse_matrix_bone_table

std::map<BoneIndex, glm::mat4> nnl::model::Model::inverse_matrix_bone_table

A table that maps bone indices to their inverse bind matrices. An entry is required only if a mesh is attached to that bone. The matrix may be a simple inverse or combined with scaling and other transformations - this is often the case when positions are stored as normalized integers.

◆ materials

std::vector<Material> nnl::model::Model::materials

A collection of materials used by the model. This vector must contain at least one material.

◆ mesh_groups

std::vector<MeshGroup> nnl::model::Model::mesh_groups

A collection of mesh groups with meshes that make up the model. Typically, there is at least one mesh group.

◆ move_with_root

bool nnl::model::Model::move_with_root = false

Indicates whether the model should be repositioned in the world when the root bone is moved by an animation.

◆ skeleton

std::vector<Bone> nnl::model::Model::skeleton

Array of bones that define the skeleton. It must contain at least one bone. This array may be derived from a preorder traversal of a skeletal tree hierarchy.

◆ texture_swaps

std::vector<TextureSwap> nnl::model::Model::texture_swaps

A collection of texture swaps that may be used in animations.

◆ uv_animations

std::vector<UVAnimation> nnl::model::Model::uv_animations

A vector of UV animations for the model. This vector must contain at least one default entry.

◆ nnl::model::ConvertParam

struct nnl::model::ConvertParam

Parameters for converting a simplified mesh to the in-game format.

See also
nnl::model::Convert
nnl::SMesh

Public Attributes

CompLvl compress_lvl = CompLvl::kMedium
u32 force_vertex_format = 0
bool indexed = true
bool use_bbox = false
bool optimize_weights = false
bool use_strips = true
 Specifies whether to use triangles or triangle strips.
bool stitch_strips = true
bool join_submeshes = true

Member Data Documentation

◆ compress_lvl

CompLvl nnl::model::ConvertParam::compress_lvl = CompLvl::kMedium

The level of compression to apply to vertex data.

◆ force_vertex_format

u32 nnl::model::ConvertParam::force_vertex_format = 0

If not 0, this value forces the specified vertex format. Otherwise, the format is determined by compress_lvl and the attributes used by the source mesh.

◆ indexed

bool nnl::model::ConvertParam::indexed = true

Indicates whether the converted mesh should use indexed rendering.

◆ join_submeshes

bool nnl::model::ConvertParam::join_submeshes = true

Specifies whether to reduce the number of SubMeshes by joining some of them. This may reduce the number of draw calls.

◆ optimize_weights

bool nnl::model::ConvertParam::optimize_weights = false

Only for NSUNI! Excludes weights from vertex data in a few cases

See also
nnl::model::SubMesh

◆ stitch_strips

bool nnl::model::ConvertParam::stitch_strips = true

Indicates whether to stitch triangle strips using 0 area triangles.

◆ use_bbox

bool nnl::model::ConvertParam::use_bbox = false

Specifies if a BBox should be generated and used for the mesh.

◆ use_strips

bool nnl::model::ConvertParam::use_strips = true

Specifies whether to use triangles or triangle strips.

Enumeration Type Documentation

◆ CompLvl

enum class nnl::model::CompLvl
strong

Enum representing compression levels for mesh conversion.

This enum defines the levels of compression applied to vertex attributes when converting from a simplified mesh to the in-game Mesh format. The selected compression level affects the size and quality of the resulting mesh.

See also
nnl::model::ConvertParam
Enumerator
kNone 

No compression applied. Uses float types and RGBA8888 format.

kMedium 

Uses shorts and bytes for attributes, RGBA4444 for color.

kMax 

Uses bytes for maximum compression, RGBA4444 for color. Suitable only for basic meshes.

◆ MaterialFeatures

enum class nnl::model::MaterialFeatures : u16
strong

Enumeration of material features used in rendering.

This enum defines various flags that activate certain features in the rendering system.

Note
Not all of the flags can be activated at the same time; enabling some of them may cause others to be ignored.
See also
nnl::model::Material
Enumerator
kNone 

No material flags are set.

kVertexColors 

To use vertex colors with kLit enabled, you should also enable this option. In other cases, vertex colors (if present) will be applied regardless of this flag. Vertex colors replace the ambient component of the material.

kLit 

Enables diffuse, specular, and emissive components of the material. The first two depend on external lights. The ambient color also becomes dependent on the global ambient light. Without this flag, only a texture, vertex colors or the ambient component are used (an unshaded material). Normals must be present in the vertex data if this flag is set.

See also
nnl::lit::Lit
kProjectionMapping 

Changes the way a texture is projected onto the mesh. This mode rotates it towards the camera. Also, it disables depth writing (not depth testing). The way the projection looks depends on normals, which must be present in the vertex data if this flag is set.

kAdditiveBlending 

The blend equation is set to add the source and destination pixel values together making the output pixels look brighter.

kSubtractiveBlending 

The blend equation is set to subtract colors of the object being rendered from the previously drawn fragments making them look darker.

kNoDepthWriteDefer 

Disables depth writing for this mesh. Note that depth testing is still performed. It also causes a mesh to be rendered later (sometimes after other models). This flag is used for proper alpha blending.

kAlphaClip 

Discards rendering of any pixels that are less than 50% opaque and makes other pixels fully opaque.

kSkinning 
Note
This flag is included for completeness and must not be used directly. Instead, set 'use_skinning' in Mesh to true.
See also
nnl::model::Mesh
kEnvironmentMapping 

Changes the way a texture is projected onto the mesh. Makes it dependent on the cel_shadow_light_direction. Also, it disables depth writing. The way the projection looks depends on normals, which must be present in the vertex data if this flag is set.

See also
nnl::lit::Lit

◆ PrimitiveType

enum class nnl::model::PrimitiveType : u16
strong

Enumeration of supported primitive types.

This enum defines various primitive types that can be used in models. Each value in this enumeration maps directly to the corresponding values used by the GE. This library primarily works with triangles, making the kTriangles, kTriangleStrip types particularly relevant. The other types are included for completeness and potential use. However, they are ignored by functions that convert between a simple model representation and the in-game format.

See also
nnl::model::Primitive

◆ UVAnimationMode

enum class nnl::model::UVAnimationMode : u16
strong

Specifies the different modes of UV animation for textures.

Each mode can be used to create unique visual effects, such as flowing water or moving leaves.

See also
nnl::model::UVAnimation
Enumerator
kNone 

No shifting occurs, but the animation can still be affected by an action config or the game. In that case, UVAnimation can serve as a placeholder to be targeted.

kContinuousShift 

In this mode, the u_shift and v_shift values are added to UV coordinates every frame. The following formulas can be used to calculate the absolute u and v translation values:
u_shift*current_frame
v_shift*current_frame

kRangedShift 

In this mode, the UV coordinates are shifted in a circular manner. The u_shift and v_shift define the radius of a shape, and a full shifting cycle takes num_frames (which must be > 0). This can be used to imitate leaf movement.
u_shift*cos(current_frame*(tau/num_frames))
v_shift*sin(current_frame*(tau/num_frames))

kFramedShift 

In this mode, the u_shift and v_shift values are added to UV coordinates every nth frame (set with num_frames). This can be used to create short animations with sprite sheets.
u_shift*int(current_frame/num_frames)
v_shift*int(current_frame/num_frames)

Function Documentation

◆ Convert() [1/3]

SModel nnl::model::Convert ( const Model & model)

Converts a game model to a simplified model representation.

This function transforms a Model into an SModel, which is a simplified representation suitable for processing or for exporting into other common formats such as FBX or glTF

Parameters
modelThe game model to be converted.
Returns
An SModel.

◆ Convert() [2/3]

Model nnl::model::Convert ( SModel && smodel,
const ConvertParam & mesh_params = {},
bool move_with_root = false )

Converts a simplified model representation to the in-game format.

This function transforms an SModel into a Model.

Parameters
smodelThe simplified model representation to be converted.
mesh_paramsParameters for mesh conversion.
move_with_rootA boolean flag indicating whether the model should move with the root bone.
Returns
A Model representing the converted in-game format.
Note
Use std::move when passing an existing object.

◆ Convert() [3/3]

Model nnl::model::Convert ( SModel && smodel,
const std::vector< ConvertParam > & mesh_params,
bool move_with_root = false )

Converts a simplified model representation to the in-game format.

This function transforms an SModel into a Model.

Parameters
smodelThe simplified model representation to be converted.
mesh_paramsParameters for each individual mesh conversion.
move_with_rootA boolean flag indicating whether the model should move with the root bone.
Returns
A Model representing the converted in-game format.
Note
Use std::move when passing an existing object.

◆ Export()

Buffer nnl::model::Export ( const Model & model)
nodiscard

Converts a model to its binary file representation.

This function takes a Model object and converts it into the binary format.

Parameters
modelThe Model object to be converted.
Returns
A buffer containing the binary representation of the model.

◆ Import()

Model nnl::model::Import ( BufferView buffer)

Parses a binary file and converts it to a structured model.

This function takes a binary representation of a model, parses its contents, and converts them into a Model struct for easier access and manipulation.

Parameters
bufferThe file buffer to be processed.
Returns
A Model object representing the converted data.
See also
nnl::model::IsOfType
nnl::model::Export

◆ IsOfType()

bool nnl::model::IsOfType ( BufferView buffer)

Tests if the provided file is a model.

This function takes data representing a file and checks whether it corresponds to the in-game model format.

Parameters
bufferThe file buffer to be tested.
Returns
Returns true if the file is identified as a model;
See also
nnl::model::Import

Variable Documentation

◆ kMaxNumBonePerPrim

std::size_t nnl::model::kMaxNumBonePerPrim = 8
constexpr

Maximum number of bones that can influence a single primitive and a single vertex.

This constant defines the upper limit of bone influences that can be applied to a single vertex and a single primitive. It is set to 8 because the GE can only hold 8 bone matrices in memory at a time when drawing primitives. As the result, a model must be split into submeshes to be drawn.

See also
nnl::model::SubMesh