mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 03:55:11 +00:00
adds cylindrical billboarding, enables it for trees.
This commit is contained in:
parent
8017d1dfa4
commit
70ca0af987
9 changed files with 134 additions and 89 deletions
|
@ -219,6 +219,9 @@
|
|||
#define BILLBOARD() \
|
||||
BC_B(0x21)
|
||||
|
||||
#define CYLBOARD() \
|
||||
BC_B(0x38)
|
||||
|
||||
// Hides the current object.
|
||||
#define HIDE() \
|
||||
BC_B(0x22)
|
||||
|
@ -3181,6 +3184,7 @@ const BehaviorScript bhvFloorTrapInCastle[] = {
|
|||
const BehaviorScript bhvTree[] = {
|
||||
BEGIN(OBJ_LIST_POLELIKE),
|
||||
BILLBOARD(),
|
||||
CYLBOARD(),
|
||||
OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE),
|
||||
SET_INT(oInteractType, INTERACT_POLE),
|
||||
SET_HITBOX(/*Radius*/ 80, /*Height*/ 500),
|
||||
|
@ -6105,5 +6109,3 @@ const BehaviorScript bhvIntroScene[] = {
|
|||
CALL_NATIVE(bhv_intro_scene_loop),
|
||||
END_LOOP(),
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -138,6 +138,14 @@ static s32 bhv_cmd_billboard(void) {
|
|||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x
|
||||
static s32 bhv_cmd_cylboard(void) {
|
||||
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_CYLBOARD;
|
||||
|
||||
gCurBhvCommand++;
|
||||
return BHV_PROC_CONTINUE;
|
||||
}
|
||||
|
||||
// Command 0x1B: Sets the current model ID of the object.
|
||||
// Usage: SET_MODEL(modelID)
|
||||
static s32 bhv_cmd_set_model(void) {
|
||||
|
@ -842,62 +850,63 @@ void stub_behavior_script_2(void) {
|
|||
|
||||
typedef s32 (*BhvCommandProc)(void);
|
||||
static BhvCommandProc BehaviorCmdTable[] = {
|
||||
bhv_cmd_begin,
|
||||
bhv_cmd_delay,
|
||||
bhv_cmd_call,
|
||||
bhv_cmd_return,
|
||||
bhv_cmd_goto,
|
||||
bhv_cmd_begin_repeat,
|
||||
bhv_cmd_end_repeat,
|
||||
bhv_cmd_end_repeat_continue,
|
||||
bhv_cmd_begin_loop,
|
||||
bhv_cmd_end_loop,
|
||||
bhv_cmd_break,
|
||||
bhv_cmd_break_unused,
|
||||
bhv_cmd_call_native,
|
||||
bhv_cmd_add_float,
|
||||
bhv_cmd_set_float,
|
||||
bhv_cmd_add_int,
|
||||
bhv_cmd_set_int,
|
||||
bhv_cmd_or_int,
|
||||
bhv_cmd_bit_clear,
|
||||
bhv_cmd_set_int_rand_rshift,
|
||||
bhv_cmd_set_random_float,
|
||||
bhv_cmd_set_random_int,
|
||||
bhv_cmd_add_random_float,
|
||||
bhv_cmd_add_int_rand_rshift,
|
||||
bhv_cmd_nop_1,
|
||||
bhv_cmd_nop_2,
|
||||
bhv_cmd_nop_3,
|
||||
bhv_cmd_set_model,
|
||||
bhv_cmd_spawn_child,
|
||||
bhv_cmd_deactivate,
|
||||
bhv_cmd_drop_to_floor,
|
||||
bhv_cmd_sum_float,
|
||||
bhv_cmd_sum_int,
|
||||
bhv_cmd_billboard,
|
||||
bhv_cmd_hide,
|
||||
bhv_cmd_set_hitbox,
|
||||
bhv_cmd_nop_4,
|
||||
bhv_cmd_delay_var,
|
||||
bhv_cmd_begin_repeat_unused,
|
||||
bhv_cmd_load_animations,
|
||||
bhv_cmd_animate,
|
||||
bhv_cmd_spawn_child_with_param,
|
||||
bhv_cmd_load_collision_data,
|
||||
bhv_cmd_set_hitbox_with_offset,
|
||||
bhv_cmd_spawn_obj,
|
||||
bhv_cmd_set_home,
|
||||
bhv_cmd_set_hurtbox,
|
||||
bhv_cmd_set_interact_type,
|
||||
bhv_cmd_set_obj_physics,
|
||||
bhv_cmd_set_interact_subtype,
|
||||
bhv_cmd_scale,
|
||||
bhv_cmd_parent_bit_clear,
|
||||
bhv_cmd_animate_texture,
|
||||
bhv_cmd_disable_rendering,
|
||||
bhv_cmd_set_int_unused,
|
||||
bhv_cmd_spawn_water_droplet,
|
||||
bhv_cmd_begin, //00
|
||||
bhv_cmd_delay, //01
|
||||
bhv_cmd_call, //02
|
||||
bhv_cmd_return, //03
|
||||
bhv_cmd_goto, //04
|
||||
bhv_cmd_begin_repeat, //05
|
||||
bhv_cmd_end_repeat, //06
|
||||
bhv_cmd_end_repeat_continue, //07
|
||||
bhv_cmd_begin_loop, //08
|
||||
bhv_cmd_end_loop, //09
|
||||
bhv_cmd_break, //0A
|
||||
bhv_cmd_break_unused, //0B
|
||||
bhv_cmd_call_native, //0C
|
||||
bhv_cmd_add_float, //0D
|
||||
bhv_cmd_set_float, //0E
|
||||
bhv_cmd_add_int, //0F
|
||||
bhv_cmd_set_int, //10
|
||||
bhv_cmd_or_int, //11
|
||||
bhv_cmd_bit_clear, //12
|
||||
bhv_cmd_set_int_rand_rshift, //13
|
||||
bhv_cmd_set_random_float, //14
|
||||
bhv_cmd_set_random_int, //15
|
||||
bhv_cmd_add_random_float, //16
|
||||
bhv_cmd_add_int_rand_rshift, //17
|
||||
bhv_cmd_nop_1, //18
|
||||
bhv_cmd_nop_2, //19
|
||||
bhv_cmd_nop_3, //1A
|
||||
bhv_cmd_set_model, //1B
|
||||
bhv_cmd_spawn_child, //1C
|
||||
bhv_cmd_deactivate, //1D
|
||||
bhv_cmd_drop_to_floor, //1E
|
||||
bhv_cmd_sum_float, //1F
|
||||
bhv_cmd_sum_int, //20
|
||||
bhv_cmd_billboard, //21
|
||||
bhv_cmd_hide, //22
|
||||
bhv_cmd_set_hitbox, //23
|
||||
bhv_cmd_nop_4, //24
|
||||
bhv_cmd_delay_var, //25
|
||||
bhv_cmd_begin_repeat_unused, //26
|
||||
bhv_cmd_load_animations, //27
|
||||
bhv_cmd_animate, //28
|
||||
bhv_cmd_spawn_child_with_param, //29
|
||||
bhv_cmd_load_collision_data, //2A
|
||||
bhv_cmd_set_hitbox_with_offset, //2B
|
||||
bhv_cmd_spawn_obj, //2C
|
||||
bhv_cmd_set_home, //2D
|
||||
bhv_cmd_set_hurtbox, //2E
|
||||
bhv_cmd_set_interact_type, //2F
|
||||
bhv_cmd_set_obj_physics, //30
|
||||
bhv_cmd_set_interact_subtype, //31
|
||||
bhv_cmd_scale, //32
|
||||
bhv_cmd_parent_bit_clear, //33
|
||||
bhv_cmd_animate_texture, //34
|
||||
bhv_cmd_disable_rendering, //35
|
||||
bhv_cmd_set_int_unused, //36
|
||||
bhv_cmd_spawn_water_droplet, //37
|
||||
bhv_cmd_cylboard //38
|
||||
};
|
||||
|
||||
// Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects.
|
||||
|
|
|
@ -30,6 +30,7 @@ extern Vec3s gVec3sOne;
|
|||
#define GRAPH_RENDER_Z_BUFFER (1 << 3)
|
||||
#define GRAPH_RENDER_INVISIBLE (1 << 4)
|
||||
#define GRAPH_RENDER_HAS_ANIMATION (1 << 5)
|
||||
#define GRAPH_RENDER_CYLBOARD (1 << 6)
|
||||
|
||||
// Whether the node type has a function pointer of type GraphNodeFunc
|
||||
#define GRAPH_NODE_TYPE_FUNCTIONAL 0x100
|
||||
|
|
|
@ -377,6 +377,26 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
|
|||
dest[3][3] = 1;
|
||||
}
|
||||
|
||||
void mtxf_cylboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) { //straight up mtxf_billboard but minus the dest[1][n] lines. transform for cylindrical billboards
|
||||
dest[0][0] = coss(angle);
|
||||
dest[0][1] = sins(angle);
|
||||
dest[0][2] = 0;
|
||||
dest[0][3] = 0;
|
||||
|
||||
dest[2][0] = 0;
|
||||
dest[2][1] = 0;
|
||||
dest[2][2] = 1;
|
||||
dest[2][3] = 0;
|
||||
|
||||
dest[3][0] =
|
||||
mtx[0][0] * position[0] + mtx[1][0] * position[1] + mtx[2][0] * position[2] + mtx[3][0];
|
||||
dest[3][1] =
|
||||
mtx[0][1] * position[0] + mtx[1][1] * position[1] + mtx[2][1] * position[2] + mtx[3][1];
|
||||
dest[3][2] =
|
||||
mtx[0][2] * position[0] + mtx[1][2] * position[1] + mtx[2][2] * position[2] + mtx[3][2];
|
||||
dest[3][3] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'dest' to a transformation matrix that aligns an object with the terrain
|
||||
* based on the normal. Used for enemies.
|
||||
|
|
|
@ -56,6 +56,7 @@ void mtxf_lookat(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d);
|
|||
void mtxf_rotate_zxy_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c);
|
||||
void mtxf_rotate_xyz_and_translate(f32 mtx[4][4], Vec3f b, Vec3s c);
|
||||
void mtxf_billboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d);
|
||||
void mtxf_cylboard(f32 mtx1[4][4], f32 mtx2[4][4], Vec3f c, s16 d);
|
||||
void mtxf_align_terrain_normal(f32 mtx[4][4], Vec3f b, Vec3f c, s16 d);
|
||||
void mtxf_align_terrain_triangle(f32 mtx[4][4], Vec3f b, s16 c, f32 d);
|
||||
void mtxf_mul(f32 dest[4][4], f32 a[4][4], f32 b[4][4]);
|
||||
|
|
|
@ -17,9 +17,11 @@ void opened_cannon_act_0(void) {
|
|||
cur_obj_enable_rendering();
|
||||
cur_obj_become_tangible();
|
||||
}
|
||||
if (o->oDistanceToMario < 500.0f) {
|
||||
cur_obj_become_tangible();
|
||||
cur_obj_enable_rendering();
|
||||
if (o->oDistanceToMario < 500.0f) {
|
||||
//cur_obj_become_tangible();
|
||||
//cur_obj_enable_rendering();
|
||||
if (o->oInteractStatus & INT_STATUS_INTERACTED
|
||||
&& (!(o->oInteractStatus
|
||||
& INT_STATUS_TOUCHED_BOB_OMB))) // bob-omb explodes when it gets into a cannon
|
||||
|
@ -30,8 +32,8 @@ void opened_cannon_act_0(void) {
|
|||
} else
|
||||
o->oInteractStatus = 0;
|
||||
} else {
|
||||
cur_obj_become_intangible();
|
||||
cur_obj_disable_rendering();
|
||||
//cur_obj_become_intangible();
|
||||
//cur_obj_disable_rendering();
|
||||
o->oCannonUnk10C = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1595,6 +1595,10 @@ void obj_set_billboard(struct Object *obj) {
|
|||
obj->header.gfx.node.flags |= GRAPH_RENDER_BILLBOARD;
|
||||
}
|
||||
|
||||
void obj_set_cylboard(struct Object *obj) {
|
||||
obj->header.gfx.node.flags |= GRAPH_RENDER_CYLBOARD;
|
||||
}
|
||||
|
||||
void cur_obj_set_hitbox_radius_and_height(f32 radius, f32 height) {
|
||||
o->hitboxRadius = radius;
|
||||
o->hitboxHeight = height;
|
||||
|
|
|
@ -292,6 +292,7 @@ extern void cur_obj_shake_y(f32);
|
|||
void cur_obj_start_cam_event(struct Object *obj, s32 cameraEvent);
|
||||
// extern ? set_mario_interact_hoot_if_in_range(?);
|
||||
void obj_set_billboard(struct Object *a0);
|
||||
void obj_set_cylboard(struct Object *a0);
|
||||
void cur_obj_set_hitbox_radius_and_height(f32,f32);
|
||||
void cur_obj_set_hurtbox_radius_and_height(f32,f32);
|
||||
// extern ? obj_spawn_loot_coins(?);
|
||||
|
|
|
@ -803,8 +803,13 @@ static void geo_process_object(struct Object *node) {
|
|||
mtxf_mul(gMatStack[gMatStackIndex + 1], (void *) node->header.gfx.throwMatrix,
|
||||
gMatStack[gMatStackIndex]);
|
||||
} else if (node->header.gfx.node.flags & GRAPH_RENDER_BILLBOARD) {
|
||||
if (node->header.gfx.node.flags & GRAPH_RENDER_CYLBOARD){
|
||||
mtxf_cylboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex],
|
||||
node->header.gfx.pos, gCurGraphNodeCamera->roll);
|
||||
} else {
|
||||
mtxf_billboard(gMatStack[gMatStackIndex + 1], gMatStack[gMatStackIndex],
|
||||
node->header.gfx.pos, gCurGraphNodeCamera->roll);
|
||||
}
|
||||
} else {
|
||||
mtxf_rotate_zxy_and_translate(mtxf, node->header.gfx.pos, node->header.gfx.angle);
|
||||
mtxf_mul(gMatStack[gMatStackIndex + 1], mtxf, gMatStack[gMatStackIndex]);
|
||||
|
|
Loading…
Reference in a new issue