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

Provides data structures for representing various animation types and their essential components. More...

Classes

struct  nnl::SKeyFrame< T >
 Represents a single keyframe in an animation. More...
struct  nnl::SBoneChannel
 Represents the animation tracks for a single bone. More...
struct  nnl::SAnimation
 Represents a skeletal animation. More...
struct  nnl::SVisibilityAnimation
 Represents a visibility animation of mesh groups. More...
struct  nnl::SUVChannel
 A single animation track for UV coordinates. More...
struct  nnl::SUVAnimation
 Represents a texture coordinate animation. More...

Typedefs

using nnl::SVisibilityChannel = std::vector<SKeyFrame<bool>>
 A single animation track for visibility of a mesh group.

Enumerations

enum class  nnl::SInterpolationMode
 Enumeration of interpolation modes for animations. More...

Detailed Description

Provides data structures for representing various animation types and their essential components.

This file defines structures for various animation types found in 3D models, including skeletal animations, visibility animations, and texture coordinate animations. These structures facilitate the conversion of animation data between various common exchange formats (such as FBX and glTF) and in-game formats.

See also
nnl::SAnimation
nnl::SVisibilityAnimation
nnl::SUVAnimation

Class Documentation

◆ nnl::SKeyFrame

struct nnl::SKeyFrame
template<typename T>
struct nnl::SKeyFrame< T >

Represents a single keyframe in an animation.

This template structure holds the time at which the keyframe occurs in the animation timeline along with a new value set at that time.

Template Parameters
TThe type of value associated with the keyframe.
See also
nnl::SBoneChannel
nnl::SVisibilityChannel
nnl::SUVChannel

Public Attributes

u16 time = 0
 The timestamp in ticks (1 tick ~ 1 frame).
value {}
 The new value at the specified time.

Member Data Documentation

◆ time

template<typename T>
u16 nnl::SKeyFrame< T >::time = 0

The timestamp in ticks (1 tick ~ 1 frame).

◆ value

template<typename T>
T nnl::SKeyFrame< T >::value {}

The new value at the specified time.

◆ nnl::SBoneChannel

struct nnl::SBoneChannel

Represents the animation tracks for a single bone.

This structure defines how a bone transforms over time during animation.

Note
Linear interpolation of keyframes and a constant rate of 30 ticks per second are assumed. Keyframes must be in ascending order and should not contain duplicate timestamps. Additionally, the time values of keyframes must not exceed the duration of the animation they belong to.
See also
nnl::SAnimation

Public Attributes

std::vector< SKeyFrame< glm::vec3 > > scale_keys
 Scale transformations.
std::vector< SKeyFrame< glm::quat > > rotation_keys
 Rotation transformations.
std::vector< SKeyFrame< glm::vec3 > > translation_keys
 Translation transformations.

Member Data Documentation

◆ rotation_keys

std::vector<SKeyFrame<glm::quat> > nnl::SBoneChannel::rotation_keys

Rotation transformations.

◆ scale_keys

std::vector<SKeyFrame<glm::vec3> > nnl::SBoneChannel::scale_keys

Scale transformations.

◆ translation_keys

std::vector<SKeyFrame<glm::vec3> > nnl::SBoneChannel::translation_keys

Translation transformations.

◆ nnl::SAnimation

struct nnl::SAnimation

Represents a skeletal animation.

This struct consists of channels that specify the transformations over time for each bone of a skeleton.

See also
nnl::animation::Animation
nnl::SSkeleton
nnl::SModel
nnl::SAsset3D

Public Member Functions

void Unbake (float tolerance=1.0e-4f)
 Removes redundant keyframes.
void Bake ()
 Bakes the animation.

Public Attributes

std::string name
 An optional name of the animation.
u16 duration = 0
std::vector< SBoneChannelbone_channels
SValue extras
 Any additional data for custom use.

Member Function Documentation

◆ Bake()

void nnl::SAnimation::Bake ( )

Bakes the animation.

This method generates keyframes for every frame of the animation, creating a complete set of keyframes.

◆ Unbake()

void nnl::SAnimation::Unbake ( float tolerance = 1.0e-4f)

Removes redundant keyframes.

This function removes keyframes that are identical or may be calculated via interpolation.

Parameters
toleranceThe maximum allowed deviation from the original key value

Member Data Documentation

◆ bone_channels

std::vector<SBoneChannel> nnl::SAnimation::bone_channels

Animation channels for bones of the skeleton. The size of this vector must match the total number of bones in the skeleton.

◆ duration

u16 nnl::SAnimation::duration = 0

Duration of the animation in ticks. It must be >= (last keyframe time + 1).

◆ extras

SValue nnl::SAnimation::extras

Any additional data for custom use.

◆ name

std::string nnl::SAnimation::name

An optional name of the animation.

◆ nnl::SVisibilityAnimation

struct nnl::SVisibilityAnimation

Represents a visibility animation of mesh groups.

This structure consists of channels that control the visibility of mesh groups over time. Up to 16 groups are supported.

Note
Constant interpolation of keyframes and a constant rate of 30 ticks per second are assumed. Keyframes must be in ascending order and should not contain duplicate timestamps. Unlike game visibility animations, which may use 2 channels (left and right) for each mesh group, the channels in this struct strictly correspond to 1 group, and the values in them are absolute - there's no need for additional bitwise operations.
See also
nnl::visanimation::Animation
nnl::SMesh
nnl::SAsset3D

Public Attributes

std::string name
 An optional name for the animation.
std::array< SVisibilityChannel, 16 > visibility_channels
 Channels for 16 mesh groups.

Member Data Documentation

◆ name

std::string nnl::SVisibilityAnimation::name

An optional name for the animation.

◆ visibility_channels

std::array<SVisibilityChannel, 16> nnl::SVisibilityAnimation::visibility_channels

Channels for 16 mesh groups.

◆ nnl::SUVChannel

struct nnl::SUVChannel

A single animation track for UV coordinates.

See also
nnl::SUVAnimation

Public Attributes

SInterpolationMode interpolation
 The method used to interpolate between keyframes.
std::vector< SKeyFrame< glm::vec2 > > keys
 The keyframes.

Member Data Documentation

◆ interpolation

SInterpolationMode nnl::SUVChannel::interpolation

The method used to interpolate between keyframes.

◆ keys

std::vector<SKeyFrame<glm::vec2> > nnl::SUVChannel::keys

The keyframes.

◆ nnl::SUVAnimation

struct nnl::SUVAnimation

Represents a texture coordinate animation.

Note
Constant or Linear interpolation of keyframes may be used. Keyframes must be in ascending order and should not contain duplicate timestamps.
Unlike the UVAnimation config defined in the model namespace, this struct can represent any offset transformations over time. Only a subset of these can be converted into the UVAnimation structure.
See also
nnl::model::UVAnimation
nnl::SModel

Public Attributes

std::string name
 An optional name for the animation.
std::map< std::size_t, SUVChanneltranslation_channels
SValue extras
 Any additional data for custom use.

Member Data Documentation

◆ extras

SValue nnl::SUVAnimation::extras

Any additional data for custom use.

◆ name

std::string nnl::SUVAnimation::name

An optional name for the animation.

◆ translation_channels

std::map<std::size_t, SUVChannel> nnl::SUVAnimation::translation_channels

A map where the key is the id of the target material and the value is an animation channel that controls UV offsets of the material's texture.

Typedef Documentation

◆ SVisibilityChannel

using nnl::SVisibilityChannel = std::vector<SKeyFrame<bool>>

A single animation track for visibility of a mesh group.

See also
nnl::SVisibilityAnimation

Enumeration Type Documentation

◆ SInterpolationMode

enum class nnl::SInterpolationMode
strong

Enumeration of interpolation modes for animations.

This enum defines the modes of interpolation for keyframes in animations.

Note
Currently, these modes are only applicable to UV animations. For other animation types, the interpolation method is pre-defined and fixed.
See also
nnl::SUVAnimation