Go to the source code of this file.
|
|
#define | T3D_ALPHA_MODE_DEFAULT 0 |
| |
|
#define | T3D_ALPHA_MODE_OPAQUE 1 |
| |
|
#define | T3D_ALPHA_MODE_CUTOUT 2 |
| |
|
#define | T3D_ALPHA_MODE_TRANSP 3 |
| |
|
#define | T3D_FOG_MODE_DEFAULT 0 |
| |
|
#define | T3D_FOG_MODE_DISABLED 1 |
| |
|
#define | T3D_FOG_MODE_ACTIVE 2 |
| |
|
|
typedef void(* | T3DModelTileCb) (void *userData, rdpq_texparms_t *tileParams, rdpq_tile_t tile) |
| |
|
typedef bool(* | T3DModelFilterCb) (void *userData, const T3DObject *obj) |
| |
|
typedef void(* | T3DModelDynTextureCb) (void *userData, const T3DMaterial *material, rdpq_texparms_t *tileParams, rdpq_tile_t tile) |
| |
|
| enum | T3DModelChunkType {
T3D_CHUNK_TYPE_VERTICES = 'V'
, T3D_CHUNK_TYPE_INDICES = 'I'
, T3D_CHUNK_TYPE_MATERIAL = 'M'
, T3D_CHUNK_TYPE_OBJECT = 'O'
,
T3D_CHUNK_TYPE_SKELETON = 'S'
, T3D_CHUNK_TYPE_ANIM = 'A'
, T3D_CHUNK_TYPE_BVH = 'B'
} |
| |
|
| T3DModel * | t3d_model_load (const char *path) |
| |
| static T3DModelState | t3d_model_state_create () |
| |
| void | t3d_model_free (T3DModel *model) |
| |
| void | t3d_model_draw_custom (const T3DModel *model, T3DModelDrawConf conf) |
| |
| static void | t3d_model_draw (const T3DModel *model) |
| |
| void | t3d_model_draw_object (const T3DObject *object, const T3DMat4FP *boneMatrices) |
| |
| void | t3d_model_draw_material (T3DMaterial *mat, T3DModelState *state) |
| |
| static T3DVertPacked * | t3d_model_get_vertices (const T3DModel *model) |
| |
| void | t3d_model_make_object_vert_placeholder (const T3DModel *model, T3DObject *object, uint8_t segmentId) |
| |
| static const T3DChunkSkeleton * | t3d_model_get_skeleton (const T3DModel *model) |
| |
| static uint32_t | t3d_model_get_animation_count (const T3DModel *model) |
| |
| void | t3d_model_get_animations (const T3DModel *model, T3DChunkAnim **anims) |
| |
| T3DChunkAnim * | t3d_model_get_animation (const T3DModel *model, const char *name) |
| |
| T3DObject * | t3d_model_get_object (const T3DModel *model, const char *name) |
| |
| static T3DObject * | t3d_model_get_object_by_index (const T3DModel *model, uint32_t index) |
| |
| T3DMaterial * | t3d_model_get_material (const T3DModel *model, const char *name) |
| |
| static T3DModelIter | t3d_model_iter_create (const T3DModel *model, enum T3DModelChunkType chunkType) |
| |
| bool | t3d_model_iter_next (T3DModelIter *iter) |
| |
| static const T3DBvh * | t3d_model_bvh_get (const T3DModel *model) |
| |
| void | t3d_model_bvh_query_frustum (const T3DBvh *bvh, const T3DFrustum *frustum) |
| |
- Copyright
- 2024 - Max Bebök @license MIT
◆ t3d_model_bvh_get()
Returns the BVH of a model. Note that this is optional and may return NULL. To create one, pass '–bvh' to the gltf importer.
- Parameters
-
- Returns
- pointer to the BVH or NULL if not found
◆ t3d_model_bvh_query_frustum()
| void t3d_model_bvh_query_frustum |
( |
const T3DBvh * | bvh, |
|
|
const T3DFrustum * | frustum ) |
Queries the BVH of a model with a frustum. Note that the BVH is in model space, so the frustum may need to be transformed before. This will mark all objects in the BVH as visible via the 'isVisible' flag. Note that you need to first set all to false before calling this.
- Parameters
-
| bvh | BVH to check |
| frustum | frustum to check against |
- Returns
◆ t3d_model_draw()
| static void t3d_model_draw |
( |
const T3DModel * | model | ) |
|
|
inlinestatic |
Draws a model with default settings. This call can be recorded into a display list.
- Parameters
-
◆ t3d_model_draw_custom()
Draws a model with a custom configuration. This call can be recorded into a display list.
- Parameters
-
| model | model to draw |
| conf | custom configuration |
◆ t3d_model_draw_material()
Draws/Applies a material of an object. This can be called before 't3d_model_draw_object'.
This will set up the texture, CC, and other RDP and t3d settings of the material.
NOTE: if you want to use this to record individual objects into a display list,
make sure to pass NULL for 'state', otherwise you may only record partial state changes.
For complete recordings, create a state via 't3d_model_state_create' and pass it to each call.
- Parameters
-
| mat | material to apply |
| state | state for material settings, used to minimized changes across materials |
◆ t3d_model_draw_object()
| void t3d_model_draw_object |
( |
const T3DObject * | object, |
|
|
const T3DMat4FP * | boneMatrices ) |
Draws an object in a model directly.
This will only handle the mesh part, and not any material or texture settings.
As in, it will load vertices (optionally a bone matrix) and then draw the triangles.
If you want to change material settings, you can use 't3d_model_draw_material' before this.
Take a look at 't3d_model_iter_create' for an example of how to use it.
- Parameters
-
| object | object to draw |
| boneMatrices | matrices in the case of skinned meshes, set to NULL for non-skinned |
◆ t3d_model_free()
Free model and any related resources (e.g. textures)
- Parameters
-
◆ t3d_model_get_animation()
Returns an animation definition by name. Note: if you want to create an animation instance, use 't3d_anim_create'.
- Parameters
-
- Returns
- pointer to the animation or NULL if not found
◆ t3d_model_get_animation_count()
| static uint32_t t3d_model_get_animation_count |
( |
const T3DModel * | model | ) |
|
|
inlinestatic |
Returns the number of animations in the model.
- Parameters
-
- Returns
◆ t3d_model_get_animations()
Stores the pointers to all animations inside the model into anims. Make sure to use t3d_model_get_animation_count to allocate enough memory.
- Parameters
-
| model | |
| anims | array to store the pointers to |
◆ t3d_model_get_material()
Returns a material by name.
- Parameters
-
| model | model |
| name | material name |
- Returns
- material or NULL if not found
◆ t3d_model_get_object()
Returns an object by name.
- Parameters
-
| model | model |
| name | object name |
- Returns
- object or NULL if not found
◆ t3d_model_get_object_by_index()
| static T3DObject * t3d_model_get_object_by_index |
( |
const T3DModel * | model, |
|
|
uint32_t | index ) |
|
inlinestatic |
Returns an object by index. Note that no bounds checking is done, so make sure the index is valid.
- Parameters
-
| model | model |
| index | object index |
- Returns
- object, invalid pointer if OOB!
◆ t3d_model_get_skeleton()
Returns the first/main skeleton of a model. If the model contains multiple skeletons, data must be manually traversed instead.
- Parameters
-
- Returns
- pointer to the skeleton or NULL if not found
◆ t3d_model_get_vertices()
| static T3DVertPacked * t3d_model_get_vertices |
( |
const T3DModel * | model | ) |
|
|
inlinestatic |
Returns the global vertex buffer of a model. For the amount of vertices, see 'model->totalVertCount'. Since vertices are interleaved, the max index is 'totalVertCount / 2'. For easy access, use functions like 't3d_vertbuffer_get_pos' and similar.
Note that this is shared for all parts of the model. If you need to change specific vertices, you must iterate over the parts.
- Parameters
-
- Returns
- pointer to the vertex buffer
◆ t3d_model_iter_create()
| static T3DModelIter t3d_model_iter_create |
( |
const T3DModel * | model, |
|
|
enum T3DModelChunkType | chunkType ) |
|
inlinestatic |
Creates an iterator to manually traverse the chunks contained in a file.
This can be used to manually iterate and draw objects.
Note that the iterator does not need to be freed,
you can simply discard it, or call this function again to rewind it.
the model it points to must however outlive the iterator.
As an example, here is how to do a custom draw of all objects in a file:
while(t3d_model_iter_next(&it)) {
t3d_model_draw_object(it.object, NULL);
}
Definition t3dmodel.h:171
static T3DModelIter t3d_model_iter_create(const T3DModel *model, enum T3DModelChunkType chunkType)
Definition t3dmodel.h:438
- Parameters
-
| model | model to iterate |
| chunkType | type of chunk to iterate (e.g. T3D_CHUNK_TYPE_OBJECT) |
- Returns
- iterator
◆ t3d_model_iter_next()
Advances the iterator to the next chunk.
A pointer to the chunk is stored in 'iter->chunk'.
If it reached the end, this function will return false and set 'iter->chunk' to NULL.
Depending on the type you passed in via 't3d_model_iter_create', you either have to cast it,
or directly use one of the typed accessors like 'iter.object' for T3D_CHUNK_TYPE_OBJECT.
- Parameters
-
- Returns
- true if it found a chunk, false if it reached the end
◆ t3d_model_load()
| T3DModel * t3d_model_load |
( |
const char * | path | ) |
|
Loads a model from a file. If you no longer need the model, call 't3d_model_free'
- Parameters
-
- Returns
- pointer to the model (that you now own)
◆ t3d_model_make_object_vert_placeholder()
| void t3d_model_make_object_vert_placeholder |
( |
const T3DModel * | model, |
|
|
T3DObject * | object, |
|
|
uint8_t | segmentId ) |
Modifies an object to replace absolute vertex addresses with relative addressing. This can be used for switching out vertex buffers for effects or dynamic meshes, while still being able to record a mesh.
Internally this works by replacing the pointers with segments (see 't3d_segment_address'). In order to draw anything, you have to point the segment to a vertex buffer before drawing.
See the '04_dynamic' example for a full demo.
- Parameters
-
| model | model containing the object |
| object | object to patch |
| segmentId | segment id to use (1-7) |
◆ t3d_model_state_create()
Creates a new draw state with default values.
- Returns