LibT2FS 0.1
C API for accessing TEngine data in memory.
Loading...
Searching...
No Matches
models.h File Reference
#include <stdint.h>
#include "t2fs.h"
#include "array.h"
#include "models/common.h"

Go to the source code of this file.

Data Structures

struct  s_T2FSDataModelInfo
struct  s_T2FSDataModelInfoDino
struct  s_T2FSDataBone
struct  s_T2FSDataBoneOrientation
struct  s_T2FSDataBoneOrientationE3
struct  s_T2FSDataAnimationBoneIndices
struct  s_T2FSDataAnimationHeader
struct  s_T2FSDataUnk2_x_4
 This is a guess, to try out stuff. More...
struct  s_T2FSDataHotpoint
struct  s_T2FSDataColorRGBA8
struct  s_T2FSDataMaterial
struct  s_T2FSDataVertexNormal
struct  s_T2FSDataVertexColor
union  u_T2FSDataVertexAttr
struct  s_T2FSDataVertex
struct  s_T2FSDataVertexN64
struct  s_T2FSAnimationFrame
struct  s_T2FSAnimation
struct  s_T2FSPolygon
struct  s_T2FSVertexBonePair
struct  s_T2FSSurface
struct  s_T2FSModel
struct  s_T2FSVtxCache
struct  s_T2FSSurfaceVertices
 Contains indices to vertices in global vertex buffer. More...
struct  s_T2FSPolygonBuffer
struct  s_T2FSModelContext
 helper to unify different games/versions More...

Macros

#define T2FS_VERTEX_CACHE_SIZE   32
#define T2FS_VERTEX_GLOBAL_UNSET   (uint32_t)-1
#define T2FS_MODEL_BONE_SYMBOL_LEG   0b001
#define T2FS_MODEL_BONE_SYMBOL_NOT_HEAD   0b010
#define T2FS_MODEL_BONE_SYMBOL_RIGHT   0b100
#define T2FS_MATERIAL_FLAG_UNK_0   0b0000000000000001
#define T2FS_MATERIAL_FLAG_UNK_1   0b0000000000000010
#define T2FS_MATERIAL_FLAG_CULBF   0b0000000000000100
#define T2FS_MATERIAL_FLAG_UNK_3   0b0000000000001000
#define T2FS_MATERIAL_FLAG_UNK_4   0b0000000000010000
#define T2FS_MATERIAL_FLAG_UNK_5   0b0000000000100000
#define T2FS_MATERIAL_FLAG_UNK_6   0b0000000001000000
#define T2FS_MATERIAL_FLAG_UNK_7   0b0000000010000000
#define T2FS_MATERIAL_FLAG_TRANSPARENCY   0b0000000100000000
#define T2FS_MATERIAL_FLAG_UNK_9   0b0000001000000000
#define T2FS_MATERIAL_FLAG_UNK_10   0b0000010000000000
#define T2FS_MATERIAL_FLAG_UNK_11   0b0000100000000000
#define T2FS_MATERIAL_FLAG_UNK_12   0b0001000000000000
#define T2FS_MATERIAL_FLAG_UNK_13   0b0010000000000000
#define T2FS_MATERIAL_FLAG_UNK_14   0b0100000000000000
#define T2FS_MATERIAL_FLAG_UNK_15   0b1000000000000000

Typedefs

typedef struct s_T2FSDataModelInfo T2FSDataModelInfo
typedef struct s_T2FSDataModelInfoDino T2FSDataModelInfoDino
typedef struct s_T2FSDataBone T2FSDataBone
typedef struct s_T2FSDataBoneOrientation T2FSDataBoneOrientation
typedef struct s_T2FSDataBoneOrientationE3 T2FSDataBoneOrientationE3
typedef struct s_T2FSDataAnimationBoneIndices T2FSDataAnimationBoneIndices
typedef struct s_T2FSDataAnimationHeader T2FSDataAnimationHeader
typedef struct s_T2FSDataUnk2_x_4 T2FSDataUnk2_x_4
 This is a guess, to try out stuff.
typedef struct s_T2FSDataHotpoint T2FSDataHotpoint
typedef struct s_T2FSDataColorRGBA8 T2FSDataColorRGBA8
typedef struct s_T2FSDataMaterial T2FSDataMaterial
typedef struct s_T2FSDataVertexNormal T2FSDataVertexNormal
typedef struct s_T2FSDataVertexColor T2FSDataVertexColor
typedef union u_T2FSDataVertexAttr T2FSDataVertexAttr
typedef struct s_T2FSDataVertex T2FSDataVertex
typedef struct s_T2FSDataVertexN64 T2FSDataVertexN64
typedef struct s_T2FSAnimationFrame T2FSAnimationFrame
typedef struct s_T2FSAnimation T2FSAnimation
typedef struct s_T2FSPolygon T2FSPolygon
typedef struct s_T2FSVertexBonePair T2FSVertexBonePair
typedef struct s_T2FSSurface T2FSSurface
typedef enum e_T2FSModelType T2FSModelType
typedef struct s_T2FSModel T2FSModel
typedef struct s_T2FSVtxCache T2FSVtxCache
typedef struct s_T2FSSurfaceVertices T2FSSurfaceVertices
 Contains indices to vertices in global vertex buffer.
typedef struct s_T2FSPolygonBuffer T2FSPolygonBuffer
typedef struct s_T2FSModelContext T2FSModelContext
 helper to unify different games/versions

Enumerations

enum  e_T2FSModelType { T2FS_MDL_TYPE_STATIC , T2FS_MDL_TYPE_ANIMATED }

Functions

uint32_t t2fs_model_count (T2FSContext *ctx)
 Get the amount of models present.
void t2fs_model_context_init (T2FSContext *ctx, T2FSModelContext *mdlCtx)
 Initialize T2FSModelContext.
int t2fs_model_load_data_node (T2FSModelContext *mdlCtx, uint32_t mdlId, T2FSNode **dest)
 Loads the model data into memory.
void t2fs_model_unload_data_node (T2FSNode *modelNode)
 Unloads the model data node.
uint32_t t2fs_model_get_variation_count (T2FSModelContext *mdlCtx, T2FSNode *mdlNode)
 Get the model variation count.
void t2fs_model_init (T2FSModel *mdl)
 Init our unified model struct.
int t2fs_model_make (T2FSModelContext *mdlCtx, T2FSNode *mdlNode, uint32_t varId, T2FSModel *dest)
 Convert the model data to our unified struct s_T2FSModel.
void t2fs_model_free (T2FSModel *mdl)
 Free all allocated memory for given T2FSModel.

Macro Definition Documentation

◆ T2FS_VERTEX_CACHE_SIZE

#define T2FS_VERTEX_CACHE_SIZE   32

◆ T2FS_VERTEX_GLOBAL_UNSET

#define T2FS_VERTEX_GLOBAL_UNSET   (uint32_t)-1

◆ T2FS_MODEL_BONE_SYMBOL_LEG

#define T2FS_MODEL_BONE_SYMBOL_LEG   0b001

◆ T2FS_MODEL_BONE_SYMBOL_NOT_HEAD

#define T2FS_MODEL_BONE_SYMBOL_NOT_HEAD   0b010

◆ T2FS_MODEL_BONE_SYMBOL_RIGHT

#define T2FS_MODEL_BONE_SYMBOL_RIGHT   0b100

◆ T2FS_MATERIAL_FLAG_UNK_0

#define T2FS_MATERIAL_FLAG_UNK_0   0b0000000000000001

◆ T2FS_MATERIAL_FLAG_UNK_1

#define T2FS_MATERIAL_FLAG_UNK_1   0b0000000000000010

◆ T2FS_MATERIAL_FLAG_CULBF

#define T2FS_MATERIAL_FLAG_CULBF   0b0000000000000100

◆ T2FS_MATERIAL_FLAG_UNK_3

#define T2FS_MATERIAL_FLAG_UNK_3   0b0000000000001000

◆ T2FS_MATERIAL_FLAG_UNK_4

#define T2FS_MATERIAL_FLAG_UNK_4   0b0000000000010000

◆ T2FS_MATERIAL_FLAG_UNK_5

#define T2FS_MATERIAL_FLAG_UNK_5   0b0000000000100000

◆ T2FS_MATERIAL_FLAG_UNK_6

#define T2FS_MATERIAL_FLAG_UNK_6   0b0000000001000000

◆ T2FS_MATERIAL_FLAG_UNK_7

#define T2FS_MATERIAL_FLAG_UNK_7   0b0000000010000000

◆ T2FS_MATERIAL_FLAG_TRANSPARENCY

#define T2FS_MATERIAL_FLAG_TRANSPARENCY   0b0000000100000000

◆ T2FS_MATERIAL_FLAG_UNK_9

#define T2FS_MATERIAL_FLAG_UNK_9   0b0000001000000000

◆ T2FS_MATERIAL_FLAG_UNK_10

#define T2FS_MATERIAL_FLAG_UNK_10   0b0000010000000000

◆ T2FS_MATERIAL_FLAG_UNK_11

#define T2FS_MATERIAL_FLAG_UNK_11   0b0000100000000000

◆ T2FS_MATERIAL_FLAG_UNK_12

#define T2FS_MATERIAL_FLAG_UNK_12   0b0001000000000000

◆ T2FS_MATERIAL_FLAG_UNK_13

#define T2FS_MATERIAL_FLAG_UNK_13   0b0010000000000000

◆ T2FS_MATERIAL_FLAG_UNK_14

#define T2FS_MATERIAL_FLAG_UNK_14   0b0100000000000000

◆ T2FS_MATERIAL_FLAG_UNK_15

#define T2FS_MATERIAL_FLAG_UNK_15   0b1000000000000000

Typedef Documentation

◆ T2FSDataUnk2_x_4

This is a guess, to try out stuff.

◆ T2FSDataVertexNormal

◆ T2FSDataVertexColor

◆ T2FSDataVertexAttr

◆ T2FSDataVertexN64

◆ T2FSAnimationFrame

◆ T2FSAnimation

◆ T2FSPolygon

typedef struct s_T2FSPolygon T2FSPolygon

◆ T2FSVertexBonePair

◆ T2FSSurface

typedef struct s_T2FSSurface T2FSSurface

◆ T2FSModelType

◆ T2FSModel

typedef struct s_T2FSModel T2FSModel

◆ T2FSVtxCache

typedef struct s_T2FSVtxCache T2FSVtxCache

◆ T2FSSurfaceVertices

Contains indices to vertices in global vertex buffer.

◆ T2FSPolygonBuffer

◆ T2FSModelContext

helper to unify different games/versions

Enumeration Type Documentation

◆ e_T2FSModelType

Enumerator
T2FS_MDL_TYPE_STATIC 
T2FS_MDL_TYPE_ANIMATED 

Function Documentation

◆ t2fs_model_count()

uint32_t t2fs_model_count ( T2FSContext * ctx)

Get the amount of models present.

Returns
The model count.

◆ t2fs_model_context_init()

void t2fs_model_context_init ( T2FSContext * ctx,
T2FSModelContext * mdlCtx )

Initialize T2FSModelContext.

T2FSModelContext is a struct with function pointers, this will set those pointers to functions that match current file (game platform and version specific stuff).

Parameters
ctxOpen and valid T2FSContext object.
mdlCtxThe model context object to initialize.

◆ t2fs_model_load_data_node()

int t2fs_model_load_data_node ( T2FSModelContext * mdlCtx,
uint32_t mdlId,
T2FSNode ** dest )

Loads the model data into memory.

It will decompress and de-interleave when needed.

Parameters
mdlCtxInitialized model context.
mdlIdModel ID
destThis will be set on success, it is the model data node.
Returns
0 on success, anything else is an error.

◆ t2fs_model_unload_data_node()

void t2fs_model_unload_data_node ( T2FSNode * modelNode)

Unloads the model data node.

This will free all allocated memory used by this model data node.

◆ t2fs_model_get_variation_count()

uint32_t t2fs_model_get_variation_count ( T2FSModelContext * mdlCtx,
T2FSNode * mdlNode )

Get the model variation count.

Parameters
mdlCtxInitialized model context.
modelNodeLoaded model node (see t2fs_model_load_data_node()).
Returns
0 on error, the model variation count on success.

◆ t2fs_model_init()

void t2fs_model_init ( T2FSModel * mdl)

Init our unified model struct.

Always call this on new T2FSModel instances so t2fs_model_free() can be safely called.

◆ t2fs_model_make()

int t2fs_model_make ( T2FSModelContext * mdlCtx,
T2FSNode * mdlNode,
uint32_t varId,
T2FSModel * dest )

Convert the model data to our unified struct s_T2FSModel.

You are responsible to call t2fs_model_free() when this returned success and you are done with the T2FSModel.

On error all potential memory this allocated will be freed, so no need to call t2fs_model_free() when this returns an error.

Parameters
mdlCtxInitialized model context.
mdlNodeLoaded model node (see t2fs_model_load_data_node()).
varIdVariation index (use t2fs_model_get_variation_count() to find the amount of variations this model has).
Returns
0 on success, anything else is an error.

◆ t2fs_model_free()

void t2fs_model_free ( T2FSModel * mdl)

Free all allocated memory for given T2FSModel.