Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
FoliageTransform.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3#include "model.h"
4
5typedef struct FoliageModelList {
6 s32 count;
7 s32 models[VLA];
9
10typedef struct FoliageDropList {
11 s32 count;
12 struct {
13 s32 itemID;
14 Vec3i pos;
15 s32 spawnMode;
16 Bytecode pickupFlag;
17 Bytecode spawnFlag;
20
25
32
40
41void N(foliage_setup_shear_mtx)(Matrix4f mtx, f32 scale, f32 xAmount, f32 zAmount) {
42 guMtxIdentF(mtx);
43 mtx[1][0] = scale * xAmount;
44 mtx[1][1] = 1.0f;
45 mtx[1][2] = scale * zAmount;
46}
47
53API_CALLABLE(N(TransformFoliage)) {
54 Bytecode* args = script->ptrReadPos;
55 s32 modelListIndex = get_model_list_index_from_tree_index(evt_get_variable(script, *args++));
56 f32 scale = evt_get_float_variable(script, *args++);
57 f32 dx = evt_get_float_variable(script, *args++);
58 f32 dy = evt_get_float_variable(script, *args++);
59 f32 dz = evt_get_float_variable(script, *args++);
60 Model* model = get_model_from_list_index(modelListIndex);
61 Matrix4f mtx;
62
63 if (!(model->flags & MODEL_FLAG_HAS_TRANSFORM)) {
64 guTranslateF(model->userTransformMtx, 0.0f, dy, 0.0f);
65 N(foliage_setup_shear_mtx)(mtx, scale, dx, dz);
66 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
67 guTranslateF(mtx, 0.0f, -dy, 0.0f);
68 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
70 } else {
71 guTranslateF(mtx, 0.0f, dy, 0.0f);
72 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
73 N(foliage_setup_shear_mtx)(mtx, scale, dx, dz);
74 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
75 guTranslateF(mtx, 0.0f, -dy, 0.0f);
76 guMtxCatF(mtx, model->userTransformMtx, model->userTransformMtx);
77 }
78
79 return ApiStatus_DONE2;
80}
void N foliage_setup_shear_mtx(Matrix4f mtx, f32 scale, f32 xAmount, f32 zAmount)
FoliageVectorList * vectors
FoliageDropList * drops
FoliageModelList * trunk
FoliageVectorList * vectors
FoliageModelList * leaves
struct FoliageDropList::@114 drops[VLA]
FoliageDropList * drops
FoliageModelList * bush
f32 Matrix4f[4][4]
Bytecode EvtScript[]
Vec3s pos
Definition demo_api.c:17
#define guTranslateF
#define guMtxCatF
@ MODEL_FLAG_HAS_TRANSFORM
Definition enums.h:4367
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4369
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
u16 flags
Definition model.h:60
Matrix4f userTransformMtx
Definition model.h:68
Definition model.h:59
#define VLA
Definition macros.h:516