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

Classes

struct  nnl::animation::KeyFrame
 Represents a keyframe in an animation. More...
struct  nnl::animation::BoneAnimation
 Represents the transformations of a bone during an animation. More...
struct  nnl::animation::Animation
 Represents a single skeletal animation. More...
struct  nnl::animation::AnimationContainer
 Holds a collection of skeletal animations. More...
struct  nnl::animation::ConvertParam
 Parameters for converting animations to the in-game format. More...

Functions

std::vector< SAnimationnnl::animation::Convert (const AnimationContainer &animations)
 Converts multiple in-game animations to a simpler format.
AnimationContainer nnl::animation::Convert (std::vector< SAnimation > &&sanimations, const ConvertParam &anim_params={}, bool move_with_root=false)
 Converts multiple animations back to AnimationContainer.
bool nnl::animation::IsOfType (BufferView buffer)
 Tests if the provided file is an animation container.
AnimationContainer nnl::animation::Import (BufferView buffer)
 Imports animations from a binary file.
Buffer nnl::animation::Export (const AnimationContainer &animation_container)
 Exports animations to a binary file format.

Detailed Description


Class Documentation

◆ nnl::animation::KeyFrame

struct nnl::animation::KeyFrame

Represents a keyframe in an animation.

This struct encapsulates the time at which the keyframe occurs in the animation timeline, as well as a new value set at that keyframe.

Public Attributes

u16 time_tick {0}
glm::vec3 value {0.0f}

Member Data Documentation

◆ time_tick

u16 nnl::animation::KeyFrame::time_tick {0}

Time in ticks (1 tick ~ 1 frame).

Note
In some assets, this value sometimes exceed the total duration, in which case an animation gets truncated.

◆ value

glm::vec3 nnl::animation::KeyFrame::value {0.0f}

The new value at the specified time. This can store scale, translation, or Euler rotation (pitch, yaw, roll) in degrees. Note that rotation values must be in the range [-180, 180].

◆ nnl::animation::BoneAnimation

struct nnl::animation::BoneAnimation

Represents the transformations of a bone during an animation.

This struct contains keyframes that set new scale, rotatation, and translation transformations of a bone.

Note
Each vector must contain at least 1 keyframe.

Public Attributes

std::vector< KeyFramescale_keys
 Scale keys.
std::vector< KeyFramerotation_keys
 Rotation keys.
std::vector< KeyFrametranslation_keys
 Translation keys.

Member Data Documentation

◆ rotation_keys

std::vector<KeyFrame> nnl::animation::BoneAnimation::rotation_keys

Rotation keys.

◆ scale_keys

std::vector<KeyFrame> nnl::animation::BoneAnimation::scale_keys

Scale keys.

◆ translation_keys

std::vector<KeyFrame> nnl::animation::BoneAnimation::translation_keys

Translation keys.

◆ nnl::animation::Animation

struct nnl::animation::Animation

Represents a single skeletal animation.

See also
nnl::animation::AnimationContainer

Public Attributes

u16 duration_ticks = 1
std::vector< BoneAnimationanimation_channels

Member Data Documentation

◆ animation_channels

std::vector<BoneAnimation> nnl::animation::Animation::animation_channels

Bone animation data for each bone of a skeleton.

Note
The number of channels must match the number of bones in the model.
See also
nnl::model::Model::skeleton

◆ duration_ticks

u16 nnl::animation::Animation::duration_ticks = 1

The duration of the animation in ticks. In general, it should be set to the time of the last keyframe + 1.

◆ nnl::animation::AnimationContainer

struct nnl::animation::AnimationContainer

Holds a collection of skeletal animations.

Note
This struct usually stores only a portion of the data that may be required by a 3D asset to function properly. Its binary representation must be used as part of a larger container that may also include models, textures and other data.
See also
nnl::asset::Asset
nnl::asset::Asset3D
nnl::model::Model
nnl::action::ActionConfig
nnl::visanimation::AnimationContainer

Public Attributes

bool move_with_root = false
std::vector< Animationanimations
 Collection of animations.

Member Data Documentation

◆ animations

std::vector<Animation> nnl::animation::AnimationContainer::animations

Collection of animations.

◆ move_with_root

bool nnl::animation::AnimationContainer::move_with_root = false

Doesn't affect anything (?). It reflects the value of the same flag from the Model struct

See also
nnl::model::Model

◆ nnl::animation::ConvertParam

struct nnl::animation::ConvertParam

Parameters for converting animations to the in-game format.

See also
nnl::animation::Convert
nnl::SAnimation

Public Attributes

bool unbake = true
 Remove keyframes that are duplicate or can be derived via interpolation.

Member Data Documentation

◆ unbake

bool nnl::animation::ConvertParam::unbake = true

Remove keyframes that are duplicate or can be derived via interpolation.

Function Documentation

◆ Convert() [1/2]

std::vector< SAnimation > nnl::animation::Convert ( const AnimationContainer & animations)

Converts multiple in-game animations to a simpler format.

This function takes an AnimationContainer object and converts all contained animations into a format that is more suitable for exporting to other formats.

It performs the following data normalization:

  • Transforms Euler angles into quaternions.
  • Re-bases animations to start at frame 0.
  • Properly clips keyframes to ensure they do not exceed the defined animation duration.
Parameters
animationsThe container of in-game animations to be converted.
Returns
A vector of converted animations in a simpler format.

◆ Convert() [2/2]

AnimationContainer nnl::animation::Convert ( std::vector< SAnimation > && sanimations,
const ConvertParam & anim_params = {},
bool move_with_root = false )

Converts multiple animations back to AnimationContainer.

This function takes a vector of SAnimation objects and converts them into an AnimationContainer object that represent the in-game animation format.

Parameters
sanimationsThe vector of animations to be converted.
anim_paramsConversion parameters
move_with_rootSets the respective value to true or false. Has no noticeable effect.
Returns
The converted container of in-game animations.
Note
Use std::move when passing an existing object.

◆ Export()

Buffer nnl::animation::Export ( const AnimationContainer & animation_container)
nodiscard

Exports animations to a binary file format.

This function takes an AnimationContainer and exports it into the binary format.

Parameters
animation_containerThe container of animations to be exported.
Returns
The exported animations in the binary format.

◆ Import()

AnimationContainer nnl::animation::Import ( BufferView buffer)

Imports animations from a binary file.

This function takes a file buffer, parses its contents, and returns an AnimationContainer object.

Parameters
bufferThe binary file to be imported.
Returns
AnimationContainer The imported container of animations.
See also
nnl::animation::IsOfType
nnl::animation::Export

◆ IsOfType()

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

Tests if the provided file is an animation container.

This function takes a file buffer and checks whether it corresponds to the in-game animation format.

Parameters
bufferThe binary file to be tested.
Returns
Returns true if the file is identified as an animation container.
See also
nnl::animation::Import