Skip to content

Commit

Permalink
incomplete code for mario in mo-cap cutscenes
Browse files Browse the repository at this point in the history
i find it way too difficult to translate CJ's arm rotations to mario, so i will be putting this code commented out
until i can figure something out. on some cutscenes, i saw CJ having a t-pose when out of bounds by using a
free camera mod, so that's a custom animation i use on mario as a template.
  • Loading branch information
headshot2017 committed Feb 15, 2024
1 parent b679a82 commit 79f41af
Show file tree
Hide file tree
Showing 13 changed files with 722 additions and 11 deletions.
5 changes: 5 additions & 0 deletions libsm64/src/decomp/game/mario_actions_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ s32 act_vehicle_crawl_out(struct MarioState *m) {
return FALSE;
}

s32 act_cutscene(struct MarioState *m) {
return FALSE;
}

s32 check_common_object_cancels(struct MarioState *m) {
f32 waterSurface = m->waterLevel - 100;
if (m->pos[1] < waterSurface) {
Expand Down Expand Up @@ -686,6 +690,7 @@ s32 mario_execute_object_action(struct MarioState *m) {
case ACT_VEHICLE_JACKED: cancel = act_vehicle_jacked(m); break;
case ACT_VOMIT: cancel = act_vomit(m); break;
case ACT_VEHICLE_CRAWL_OUT: cancel = act_vehicle_crawl_out(m); break;
case ACT_CUTSCENE: cancel = act_cutscene(m); break;
}
/* clang-format on */

Expand Down
143 changes: 141 additions & 2 deletions libsm64/src/decomp/game/mario_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING
&& action != ACT_RIDING_SHELL_GROUND && action != ACT_DRIVING_VEHICLE && action != ACT_IDLE) {
&& action != ACT_RIDING_SHELL_GROUND && action != ACT_DRIVING_VEHICLE && action != ACT_IDLE && action != ACT_CUTSCENE) {
vec3s_copy(bodyState->torsoAngle, gVec3sZero);
}
rotNode->rotation[0] = bodyState->torsoAngle[1];
Expand All @@ -419,7 +419,6 @@ Gfx *geo_mario_tilt_left_arm(s32 callContext, struct GraphNode *node, UNUSED Mat
Gfx *geo_mario_tilt_right_arm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
s32 action = bodyState->action;

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
Expand All @@ -431,6 +430,146 @@ Gfx *geo_mario_tilt_right_arm(s32 callContext, struct GraphNode *node, UNUSED Ma
return NULL;
}

Gfx *geo_mario_tilt_left_forearm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->leftForeArmAngle[1];
rotNode->rotation[1] = bodyState->leftForeArmAngle[2];
rotNode->rotation[2] = bodyState->leftForeArmAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_right_forearm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->rightForeArmAngle[1];
rotNode->rotation[1] = bodyState->rightForeArmAngle[2];
rotNode->rotation[2] = bodyState->rightForeArmAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_left_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->leftHandAngle[1];
rotNode->rotation[1] = bodyState->leftHandAngle[2];
rotNode->rotation[2] = bodyState->leftHandAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_right_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->rightHandAngle[1];
rotNode->rotation[1] = bodyState->rightHandAngle[2];
rotNode->rotation[2] = bodyState->rightHandAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_left_leg(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->leftLegAngle[1];
rotNode->rotation[1] = bodyState->leftLegAngle[2];
rotNode->rotation[2] = bodyState->leftLegAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_right_leg(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->rightLegAngle[1];
rotNode->rotation[1] = bodyState->rightLegAngle[2];
rotNode->rotation[2] = bodyState->rightLegAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_left_ankle(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->leftAnkleAngle[1];
rotNode->rotation[1] = bodyState->leftAnkleAngle[2];
rotNode->rotation[2] = bodyState->leftAnkleAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_right_ankle(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->rightAnkleAngle[1];
rotNode->rotation[1] = bodyState->rightAnkleAngle[2];
rotNode->rotation[2] = bodyState->rightAnkleAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_left_foot(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->leftFootAngle[1];
rotNode->rotation[1] = bodyState->leftFootAngle[2];
rotNode->rotation[2] = bodyState->leftFootAngle[0];
}
return NULL;
}

Gfx *geo_mario_tilt_right_foot(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];

if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;

rotNode->rotation[0] = bodyState->rightFootAngle[1];
rotNode->rotation[1] = bodyState->rightFootAngle[2];
rotNode->rotation[2] = bodyState->rightFootAngle[0];
}
return NULL;
}

/**
* Makes Mario's head rotate with the camera angle when in C-up mode
*/
Expand Down
10 changes: 10 additions & 0 deletions libsm64/src/decomp/game/mario_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4
Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_arm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_arm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_forearm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_forearm(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_leg(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_leg(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_ankle(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_ankle(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_left_foot(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_right_foot(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Expand Down
1 change: 1 addition & 0 deletions libsm64/src/decomp/include/sm64shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
#define ACT_VEHICLE_JACKED 0x0000039A // (0x19A | ACT_FLAG_STATIONARY) (custom libsm64 GTA SA action)
#define ACT_VOMIT 0x0000039B // (0x19B | ACT_FLAG_STATIONARY) (custom libsm64 GTA SA action)
#define ACT_VEHICLE_CRAWL_OUT 0x0000039C // (0x19C | ACT_FLAG_STATIONARY) (custom libsm64 GTA SA action)
#define ACT_CUTSCENE 0x0002039D // (0x19D | ACT_FLAG_STATIONARY | ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE) (custom libsm64 GTA SA action)

/*
this input mask is unused by the controller,
Expand Down
10 changes: 10 additions & 0 deletions libsm64/src/decomp/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ struct MarioBodyState

Vec3s leftArmAngle; // sm64-san-andreas: added field
Vec3s rightArmAngle; // sm64-san-andreas: added field
Vec3s leftForeArmAngle; // sm64-san-andreas: added field
Vec3s rightForeArmAngle; // sm64-san-andreas: added field
Vec3s leftHandAngle; // sm64-san-andreas: added field
Vec3s rightHandAngle; // sm64-san-andreas: added field
Vec3s leftLegAngle; // sm64-san-andreas: added field
Vec3s rightLegAngle; // sm64-san-andreas: added field
Vec3s leftAnkleAngle; // sm64-san-andreas: added field
Vec3s rightAnkleAngle; // sm64-san-andreas: added field
Vec3s leftFootAngle; // sm64-san-andreas: added field
Vec3s rightFootAngle; // sm64-san-andreas: added field
s16 animOverrideWanted; // sm64-san-andreas: added field
};

Expand Down
24 changes: 20 additions & 4 deletions libsm64/src/decomp/mario/geo.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,17 @@ const GeoLayout mario_geo_body[] = {
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, mario_left_arm), // starts sharing solid color with mario_left_forearm (red)
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 65, 0, 0, mario_left_forearm_shared_dl),
GEO_ASM(0, geo_mario_tilt_left_forearm),
GEO_ROTATION_NODE(0x00, 0, 0, 0),
GEO_OPEN_NODE(),
GEO_BRANCH(1, mario_geo_left_hand), // stops sharing because hand has its solid color (white)
GEO_ANIMATED_PART(LAYER_OPAQUE, 65, 0, 0, mario_left_forearm_shared_dl),
GEO_OPEN_NODE(),
GEO_ASM(0, geo_mario_tilt_left_hand),
GEO_ROTATION_NODE(0x00, 0, 0, 0),
GEO_OPEN_NODE(),
GEO_BRANCH(1, mario_geo_left_hand), // stops sharing because hand has its solid color (white)
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
Expand All @@ -147,9 +155,17 @@ const GeoLayout mario_geo_body[] = {
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 0, 0, 0, mario_right_arm), // starts sharing solid color of his dl with mario_right_forearm (red)
GEO_OPEN_NODE(),
GEO_ANIMATED_PART(LAYER_OPAQUE, 65, 0, 0, mario_right_forearm_shared_dl),
GEO_ASM(0, geo_mario_tilt_right_forearm),
GEO_ROTATION_NODE(0x00, 0, 0, 0),
GEO_OPEN_NODE(),
GEO_BRANCH(1, mario_geo_right_hand), // stops sharing because hand has its solid color (white)
GEO_ANIMATED_PART(LAYER_OPAQUE, 65, 0, 0, mario_right_forearm_shared_dl),
GEO_OPEN_NODE(),
GEO_ASM(0, geo_mario_tilt_right_hand),
GEO_ROTATION_NODE(0x00, 0, 0, 0),
GEO_OPEN_NODE(),
GEO_BRANCH(1, mario_geo_right_hand), // stops sharing because hand has its solid color (white)
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
GEO_CLOSE_NODE(),
Expand Down
Loading

0 comments on commit 79f41af

Please sign in to comment.