NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
model.hpp File Reference

Contains structures and functions for working with in-game 3D models. More...

#include <array>
#include <cstring>
#include <map>
#include <vector>
#include "NNL/common/enum_flag.hpp"
#include "NNL/common/fixed_type.hpp"
#include "NNL/common/io.hpp"
#include "NNL/game_asset/visual/model_common.hpp"
#include "NNL/simple_asset/smodel.hpp"
#include "NNL/utility/static_set.hpp"

Go to the source code of this file.

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...
struct  nnl::model::TriangleGroup
 Represents a group of triangles associated with specific bones. More...

Namespaces

namespace  nnl
namespace  nnl::model
 Contains structures and functions for working with in-game 3D models.

Macros

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

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...
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

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.
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::size_t nnl::model::kMaxNumBonePerPrim = 8
 Maximum number of bones that can influence a single primitive and a single vertex.
constexpr std::array< std::string_view, 30 > nnl::model::bone_target_names
 An array that associates a generic bone id with a name.
constexpr u32 nnl::model::raw::kMagicBytes = 0x16'81'00'01
 Magic bytes used to identify the model format.

Detailed Description

Contains structures and functions for working with in-game 3D models.

See also
nnl::model::Model
nnl::model::IsOfType
nnl::model::Import
nnl::model::Export
nnl::model::Convert
model_common.hpp