Last active
May 23, 2022 11:35
-
-
Save vurtun/77e44ec7e9b41ce682aaf97dc7c85598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Symbols: | |
// Dropdowns rendering: [|----------------[v]|] | |
// Right Click -> New State Machine -> Name: "blnd_tree_loco_walk" | |
static struct anim_pose* | |
blnd_tree_loco_walk(struct anim_ctx *ctx, struct anim_sm *sm) { | |
struct anim_pose *res = 0; | |
{ | |
// Right Click -> New Node -> Animation -> Walk Left | |
struct anim *walk_l = [|----------------[v]|]; | |
// Right Click -> New Node -> Animation -> Walk Forward | |
struct anim *walk_f = [|----------------[v]|]; | |
// Right Click -> New Node -> Animation -> Walk Right | |
struct anim *walk_r = [|----------------[v]|]; | |
// Right Click -> New Node -> Blend -> Ranged Blend | |
struct anim_blnd_rng_param p = {0}; | |
p.value = [|-"g_head_direction"----[v]|]; // generated code: float g_head_direction = anim_get_global_param_f(ctx, STR_HASH16("g_head_direction")); | |
// Right Click `anim_blnd_rng_param` -> add input | |
p.in[p.in_cnt++] = {walk_l, -90.0f}; | |
// Right Click `anim_blnd_rng_param` -> add input | |
p.in[p.in_cnt++] = {walk_f, 0.0f}; | |
// Right Click `anim_blnd_rng_param` -> add input | |
p.in[p.in_cnt++] = {walk_r, 90.0f}; | |
struct anim_pose *rng_blnd_pose = anim_blnd_rng(ctx, sm, p); | |
res = rng_blnd_pose; | |
} | |
return res; | |
} | |
// Right Click -> New State Machine -> Name: "blnd_tree_loco_move" | |
static struct anim_pose* | |
blnd_tree_loco_move(struct anim_graph_ctx *ctx, struct anim_sm *sm) { | |
Pose *res = 0; | |
{ | |
// generated code: float g_speed = anim_get_global_param_f(ctx, STR_HASH16("g_speed")); | |
if ([|-"g_speed"----[v]|] >= 60) { | |
res = blnd_tree_loco_run(ctx, sm); | |
} else { | |
res = blnd_tree_loco_walk(ctx, sm); | |
} | |
} | |
return res; | |
} | |
// Right Click -> New State Machine -> Name: "sm_loco" | |
static struct anim_pose* | |
sm_loco(struct anim_ctx *ctx, struct anim_sm *sm) { | |
Pose *res = 0; | |
struct anim_sm sm = {0}; | |
anim_sm_begin(ctx, &sm, STR_HASH16("sm_loco")); | |
{ | |
switch (sm->state) { | |
case STATE_IDLE: { | |
if ([|-"g_speed"----[v]|] > 0) { | |
sm->state = STATE_WALK; | |
} | |
} break; | |
case STATE_WALK: { | |
if ([|-"g_speed"----[v]|] <= 0) { | |
sm->state = STATE_IDLE; | |
} | |
} break;} | |
switch (sm->state) { | |
case STATE_IDLE: | |
res = blnd_tree_loco_idle(ctx, sm); | |
break; | |
case STATE_WALK: | |
res = blnd_tree_loco_walk(ctx, sm); | |
break; | |
} | |
} | |
anim_sm_end(ctx, &sm); | |
return res; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment