NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
nnl::model Namespace Reference

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

Classes

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

Typedefs

using BoneIndex = u16
 Represents a concrete bone index in a skeleton/bone array.
using BoneTarget = u16
 Represents a generic bone identifier.

Enumerations

enum class  UVAnimationMode : u16 { UVAnimationMode::kNone = 0 , UVAnimationMode::kContinuousShift = 1 , UVAnimationMode::kRangedShift = 2 , UVAnimationMode::kFramedShift = 3 }
 Specifies the different modes of UV animation for textures. More...
enum class  PrimitiveType : u16
 Enumeration of supported primitive types. More...
enum class  MaterialFeatures : u16 {
  MaterialFeatures::kNone = 0 , MaterialFeatures::kVertexColors = 0b000000001 , MaterialFeatures::kLit = 0b000000010 , MaterialFeatures::kProjectionMapping = 0b000000100 ,
  MaterialFeatures::kAdditiveBlending = 0b000001000 , MaterialFeatures::kSubtractiveBlending = 0b000010000 , MaterialFeatures::kNoDepthWriteDefer = 0b000100000 , MaterialFeatures::kAlphaClip = 0b001000000 ,
  MaterialFeatures::kSkinning = 0b010000000 , MaterialFeatures::kEnvironmentMapping = 0b100000000
}
 Enumeration of material features used in rendering. More...
enum class  CompLvl { CompLvl::kNone = 0 , CompLvl::kMedium = 1 , CompLvl::kMax = 2 }
 Enum representing compression levels for mesh conversion. More...
enum  GeCmd : u32 {
  kReturn = 0x0B'00'00'00 , kSetVertexType = 0x12'00'00'00 , kSetBaseAddress = 0x10'00'00'00 , kSetVramAddress = 0x01'00'00'00 ,
  kDrawPrimitives = 0x04'00'00'00
}
 Enumeration of essential rendering commands for the library. More...
enum  HumanoidRigTarget : BoneTarget
 Enum representing parts of a generic humanoid rig. More...

Functions

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 Convert (SModel &&smodel, const ConvertParam &mesh_params={}, bool move_with_root=false)
 Converts a simplified model representation to the in-game format.
SModel Convert (const Model &model)
 Converts a game model to a simplified model representation.
bool IsOfType (BufferView buffer)
 Tests if the provided file is a model.
Model Import (BufferView buffer)
 Parses a binary file and converts it to a structured model.
Buffer Export (const Model &model)
 Converts a model to its binary file representation.
std::vector< STriangleExtractTriangles (const SubMesh &submesh, bool skip_degenerate=true)
 Extracts triangles from a given submesh.
std::vector< TriangleGroupGroupTrianglesByBones (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 GenerateBBox (const SMesh &mesh, glm::mat4 transform=glm::mat4(1.0f))
 Generates an axis-aligned bounding box (AABB) for the given mesh.
Mesh Convert (SMesh &&smesh, const ConvertParam &param={})
 Converts a simplified representation of a mesh to the in-game format.
SMesh Convert (const Mesh &mesh)
 Converts a mesh from the in-game format to a simplified representation.
ConvertParam GenerateConvertParam (const Mesh &mesh)
 Generates a conversion parameter for SMesh to get a similar in-game Mesh when converting back to it.
std::vector< ConvertParamGenerateConvertParam (const Model &model)
 Generates a vector of conversion parameters for the entire model to achieve a similar in-game representation.
std::vector< BoneConvert (const SSkeleton &skeleton)
 Converts a skeleton represented as a tree into a vector of bones.
void 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 > > GenerateBoneTargetTables (const SSkeleton &skeleton)
 Generates bone target tables from bone names of the skeleton.
SSkeleton Convert (const std::vector< Bone > &bones)
 Converts a vector of bones into a simple tree-like skeleton representation.
std::map< BoneIndex, glm::mat4 > GenerateInverseMatrixBoneTable (const SModel &smodel)
 Generates a map of bone indices and inverse matrices.
UVAnimation Convert (const SUVChannel &suv_anim_channel)
 Converts a simple UV animation channel to an in-game UVAnimation config.
SUVChannel Convert (const UVAnimation &uv_anim)
 Converts an in-game UVAnimation config to a simple UV animation channel.
Material Convert (const SMaterial &smat)
 Converts SMaterial to Material.
SMaterial Convert (const Material &mat)
 Converts Material to SMaterial.

Variables

constexpr std::size_t kMaxNumBonePerPrim = 8
 Maximum number of bones that can influence a single primitive and a single vertex.
constexpr std::array< std::string_view, 30 > bone_target_names
 An array that associates a generic bone id with a name.

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