Document & refactor c_keyframe

This commit is contained in:
Cuyler36
2024-02-05 10:18:05 -05:00
parent 32621e2946
commit fe6e806aae
4 changed files with 1849 additions and 1027 deletions
+406 -70
View File
@@ -10,73 +10,89 @@
extern "C" {
#endif
enum {
cKF_STATE_NONE,
cKF_STATE_STOPPED,
cKF_STATE_CONTINUE,
#define cKF_JOINT_FLAG_DISP_OPA (0 << 0) // Joint rendered in OPA display list
#define cKF_JOINT_FLAG_DISP_XLU (1 << 0) // When set, joint is rendered in XLU display list
cKF_STATE_NUM
/* Flags for animation components to apply to each joint */
#define cKF_ANIMITION_BIT_NONE (0 << 0) // No translation or rotation
#define cKF_ANIMATION_BIT_TRANS_X (1 << 5)
#define cKF_ANIMATION_BIT_TRANS_Y (1 << 4)
#define cKF_ANIMATION_BIT_TRANS_Z (1 << 3)
#define cKF_ANIMATION_BIT_ROT_X (1 << 2)
#define cKF_ANIMATION_BIT_ROT_Y (1 << 1)
#define cKF_ANIMATION_BIT_ROT_Z (1 << 0)
#define cKF_ANIMATION_TRANS_XZ (1 << 0) // Translation on XZ
#define cKF_ANIMATION_TRANS_Y (1 << 1) // Translation on Y
#define cKF_ANIMATION_ROT_X (1 << 2) // Rotation on the X axis
enum {
cKF_STATE_NONE,
cKF_STATE_STOPPED,
cKF_STATE_CONTINUE,
cKF_STATE_NUM
};
typedef struct joint_s {
Gfx* model;
u8 child;
u8 flags;
s_xyz translation;
Gfx* model;
u8 child;
u8 flags;
s_xyz translation;
} cKF_Joint_R_c;
typedef struct skeleton_s {
u8 num_joints;
u8 num_shown_joints;
cKF_Joint_R_c* joint_table;
u8 num_joints;
u8 num_shown_joints;
cKF_Joint_R_c* joint_table;
} cKF_Skeleton_R_c;
typedef struct animation_s {
u8* flag_table;
s16* data_table;
s16* key_table;
s16* fixed_table;
s16 pad;
s16 frames;
u8* flag_table;
s16* data_table;
s16* key_table;
s16* fixed_table;
s16 pad;
s16 frames;
} cKF_Animation_R_c;
enum {
cKF_FRAMECONTROL_STOP,
cKF_FRAMECONTROL_REPEAT,
cKF_FRAMECONTROL_STOP,
cKF_FRAMECONTROL_REPEAT,
cKF_FRAMECONTROL_NUM
cKF_FRAMECONTROL_NUM
};
typedef struct frame_control_s {
f32 start_frame;
f32 end_frame;
f32 max_frames;
f32 speed;
f32 current_frame;
int mode;
f32 start_frame;
f32 end_frame;
f32 max_frames;
f32 speed;
f32 current_frame;
int mode;
} cKF_FrameControl_c;
typedef struct skeleton_info_s {
cKF_FrameControl_c frame_control;
cKF_Skeleton_R_c* skeleton;
cKF_Animation_R_c* animation;
cKF_FrameControl_c frame_control;
cKF_Skeleton_R_c* skeleton;
cKF_Animation_R_c* animation;
f32 morph_counter;
s_xyz* current_joint;
s_xyz* target_joint;
s_xyz* rotation_diff_table;
f32 morph_counter;
s_xyz* current_joint;
s_xyz* target_joint;
s_xyz* rotation_diff_table;
int animation_enabled;
xyz_t base_world_position;
s16 base_angle_y;
int animation_enabled;
xyz_t base_world_position;
s16 base_angle_y;
xyz_t base_model_translation;
s_xyz base_model_rotation;
s_xyz updated_base_model_rotation;
xyz_t base_model_translation;
s_xyz base_model_rotation;
s_xyz updated_base_model_rotation;
f32 fixed_counter;
xyz_t model_world_position_correction;
s16 model_angle_correction;
f32 fixed_counter;
xyz_t model_world_position_correction;
s16 model_angle_correction;
} cKF_SkeletonInfo_R_c;
typedef struct combine_work_set_s {
@@ -88,59 +104,379 @@ typedef struct combine_work_set_s {
int anm_key_num_idx;
int anm_const_val_tbl_idx;
int anm_data_src_idx;
}cKF_SkeletonInfo_R_combine_work_c;
} cKF_SkeletonInfo_R_combine_work_c;
typedef struct tex_anim_s {
s16 frame;
s16 timer;
s16 frame;
s16 timer;
} cKF_TextureAnimation_c;
typedef int (*cKF_draw_callback)(GAME*, cKF_SkeletonInfo_R_c*, int, Gfx**, u8*, void*, s_xyz*, xyz_t*);
#define cKF_FRAMERATE 30.0f
#define cKF_FRAMETIME (1.0f / cKF_FRAMERATE)
#define cKF_EPSILON 0.008f
/**
* Determines if the current frame has passed a specified frame, considering direction.
*
* @param fc Pointer to the frame control structure.
* @param current The frame to check against the current frame.
* @return Returns 1 if the current frame is past the specified frame, 0 otherwise.
*/
extern int cKF_FrameControl_passCheck_now(cKF_FrameControl_c* fc, f32 current);
extern f32 cKF_HermitCalc(f32 t, f32 tension, f32 p0, f32 p1, f32 m0, f32 m1);
/**
* Stops animation at its end frame.
*
* Adjusts the current frame to the end frame if it's determined to surpass the end or start frame,
* effectively stopping the animation.
*
* @param fc Pointer to the frame control structure.
* @return cKF_STATE_STOPPED if animation stops; cKF_STATE_NONE otherwise.
*/
extern int cKF_FrameControl_stop_proc(cKF_FrameControl_c* fc);
/**
* Computes a point on a Hermite curve for given time and tension.
*
* @param time Normalized time (0 to 1) along the curve.
* @param tension Controls curve tightness around control points.
* @param startPos Position of the start point.
* @param endPos Position of the end point.
* @param startTangent Tangent at the start point.
* @param endTangent Tangent at the end point.
* @return Position of the point on the curve.
*/
extern f32 cKF_HermitCalc(f32 time, f32 tension, f32 startPos, f32 endPos, f32 startTangent, f32 endTangent);
/**
* Interpolates rotation values for skeletal animation blending.
*
* Determines the shortest rotation path and interpolates based on a given fraction (t),
* considering both signed and unsigned differences to handle wraparound cases.
*
* @param t Interpolation factor between 0 and 1.
* @param out Pointer to store interpolated rotation result.
* @param rot1 Start rotation value.
* @param rot2 End rotation value.
*/
extern void cKF_SkeletonInfo_subRotInterpolation(f32 t, s16* out, s16 rot1, s16 rot2);
extern void cKF_SkeletonInfo_R_ct(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton_R_c* skeleton, cKF_Animation_R_c* animation, s_xyz* work_table, s_xyz* target_table);
/**
* Initializes a skeleton info structure with skeleton and animation data.
*
* Sets up the skeleton info structure for use, linking it with its skeleton structure,
* animation data, and joint work and target tables.
*
* @param keyframe Pointer to the skeleton info structure.
* @param skeleton Pointer to the associated skeleton structure.
* @param animation Pointer to the animation data to use.
* @param work_table Pointer to the work table for current joint positions.
* @param target_table Pointer to the target table for target joint positions.
*/
extern void cKF_SkeletonInfo_R_ct(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton_R_c* skeleton,
cKF_Animation_R_c* animation, s_xyz* work_table, s_xyz* target_table);
/**
* Destructor for a skeleton info structure. Currently a stub with no operation.
*
* @param keyframe Pointer to the skeleton info structure to destruct.
*/
extern void cKF_SkeletonInfo_R_dt(cKF_SkeletonInfo_R_c* keyframe);
extern void cKF_SkeletonInfo_R_init_standard_stop(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table);
extern void cKF_SkeletonInfo_R_init_standard_stop_morph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 morph);
extern void cKF_SkeletonInfo_R_init_standard_repeat(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table);
extern void cKF_SkeletonInfo_R_init_standard_repeat_morph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 morph);
/**
* Initializes a skeleton info structure for standard stop animation.
*
* Sets up the animation to stop at the last frame.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
*/
extern void cKF_SkeletonInfo_R_init_standard_stop(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table);
extern void cKF_SkeletonInfo_R_init(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton_R_c* skeleton, cKF_Animation_R_c* animation, f32 start_frame, f32 end_frame,
f32 current_frame, f32 frame_speed, f32 morph_counter,int mode,s_xyz* rotation_diff_table);
/**
* Initializes a skeleton info structure for standard stop animation with morphing.
*
* Similar to standard stop but includes a morph counter to blend animations.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param morph Morph counter for animation blending.
*/
extern void cKF_SkeletonInfo_R_init_standard_stop_morph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 morph);
/**
* Initializes a skeleton info structure for standard repeat animation.
*
* Sets up the animation to repeat from start to end frame.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
*/
extern void cKF_SkeletonInfo_R_init_standard_repeat(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table);
/**
* Initializes a skeleton info structure for standard repeat animation with morphing.
*
* Similar to standard repeat but includes a morph counter for blending animations.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param morph Morph counter for animation blending.
*/
extern void cKF_SkeletonInfo_R_init_standard_repeat_morph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 morph);
/**
* Generic initializer for a skeleton info structure with detailed animation control.
*
* Allows for custom start, end, current frame, and frame speed settings, including
* the animation mode and morph counter.
*
* @param keyframe Pointer to the skeleton info structure.
* @param skeleton Pointer to the skeleton structure.
* @param animation Pointer to the animation data.
* @param start_frame Animation start frame.
* @param end_frame Animation end frame.
* @param current_frame Current frame of animation.
* @param frame_speed Speed of frame progression.
* @param morph_counter Counter for morphing between animations.
* @param mode Animation mode (stop or repeat).
* @param rotation_diff_table Pointer to the rotation difference table.
*/
extern void cKF_SkeletonInfo_R_init(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton_R_c* skeleton,
cKF_Animation_R_c* animation, f32 start_frame, f32 end_frame, f32 current_frame,
f32 frame_speed, f32 morph_counter, int mode, s_xyz* rotation_diff_table);
/**
* Plays the animation for a given skeleton info structure, applying keyframe data and morphing.
*
* Advances the animation based on the current frame, applying keyframe data for each joint.
* Handles morphing between the current and target joint positions if a morph counter is set.
* Updates joint positions based on animation flags, fixed values, and calculated keyframe values.
* Also applies rotation differences and updates the frame control state based on the animation mode.
*
* @param keyframe Pointer to the skeleton info structure containing animation and joint data.
* @return The state of the animation after processing (e.g., stopped, none, continued).
*/
extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe);
extern void cKF_Si3_draw_SV_R_child(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int* joint_num, cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, void* arg, Mtx** mtxpp);
extern void cKF_Si3_draw_R_SV(GAME* game, cKF_SkeletonInfo_R_c* keyframe, Mtx* mtxp, cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, void* arg);
/**
* Recursively draws child joints of a skeleton, applying transformations and rendering callbacks.
*
* @param game Pointer to the game structure.
* @param keyframe Pointer to the skeleton info structure for joint data and animation state.
* @param joint_num Pointer to the current joint index being processed.
* @param prerender_callback Callback function executed before rendering each joint.
* @param postrender_callback Callback function executed after rendering each joint.
* @param arg Additional arguments passed to the callbacks.
* @param mtxpp Pointer to the transformation matrix for the current joint.
*/
extern void cKF_Si3_draw_SV_R_child(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int* joint_num,
cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback,
void* arg, Mtx** mtxpp);
extern void cKF_SkeletonInfo_R_init_standard_repeat_speedsetandmorph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 frame_speed, f32 morph_counter);
extern void cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 frame, f32 frame_speed, f32 morph_counter);
extern void cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 frame, f32 frame_speed, f32 morph_counter, int mode);
extern void cKF_SkeletonInfo_R_init_reverse_setspeedandmorphandmode(cKF_SkeletonInfo_R_c* keyframe, cKF_Animation_R_c* animation, s_xyz* rotation_diff_table, f32 frame_speed, f32 morph_counter, int mode);
/**
* Renders a skeleton before and after applying transformations, using callbacks for custom rendering logic.
*
* @param game Pointer to the game structure.
* @param keyframe Pointer to the skeleton info structure.
* @param mtxp Pointer to the transformation matrix.
* @param prerender_callback Function called before rendering the skeleton.
* @param postrender_callback Function called after rendering the skeleton.
* @param arg Additional arguments passed to the callbacks.
*/
extern void cKF_Si3_draw_R_SV(GAME* game, cKF_SkeletonInfo_R_c* keyframe, Mtx* mtxp,
cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, void* arg);
extern void cKF_SkeletonInfo_R_combine_work_set(cKF_SkeletonInfo_R_combine_work_c* combine, cKF_SkeletonInfo_R_c* keyframe);
extern void cKF_SkeletonInfo_R_combine_translation(s16** joint, int* flag, cKF_SkeletonInfo_R_combine_work_c* combine , s8* cwork_num);
extern void cKF_SkeletonInfo_R_combine_rotation(s16** joint, int* flag, cKF_SkeletonInfo_R_combine_work_c* combine , s8* cwork_num);
/**
* Initializes a skeleton info structure for repeating animation with specified speed and morph counter.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param frame_speed Animation playback speed.
* @param morph_counter Counter for morphing between animations.
*/
extern void cKF_SkeletonInfo_R_init_standard_repeat_speedsetandmorph(cKF_SkeletonInfo_R_c* keyframe,
cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 frame_speed,
f32 morph_counter);
extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_SkeletonInfo_R_c* info2,s8* flag);
/**
* Initializes a skeleton info structure for repeating animation, setting frame, speed, and morph counter.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param frame Starting frame for animation.
* @param frame_speed Animation playback speed.
* @param morph_counter Counter for morphing between animations.
*/
extern void cKF_SkeletonInfo_R_init_standard_repeat_setframeandspeedandmorph(cKF_SkeletonInfo_R_c* keyframe,
cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 frame,
f32 frame_speed, f32 morph_counter);
extern void cKF_SkeletonInfo_R_T_combine_play(int* arg1, int* arg2, int* arg3,cKF_SkeletonInfo_R_c* info1, cKF_SkeletonInfo_R_c* info2, cKF_SkeletonInfo_R_c* info3,s8* flag);
extern void cKF_SkeletonInfo_R_Animation_Set_base_shape_trs(f32 transx, f32 transy, f32 transz, cKF_SkeletonInfo_R_c* keyframe, s16 anglex, s16 angley, s16 anglez);
extern void cKF_SkeletonInfo_R_AnimationMove_ct_base(f32 counter, xyz_t* basepos, xyz_t* correctpos, s16 ybase, s16 yidle, cKF_SkeletonInfo_R_c* keyframe, int animation_flag);
/**
* Initializes a skeleton info structure with custom settings including frame, speed, morph counter, and mode.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param frame Starting frame for animation.
* @param frame_speed Animation playback speed.
* @param morph_counter Counter for morphing between animations.
* @param mode Animation mode (e.g., repeat, stop).
*/
extern void cKF_SkeletonInfo_R_init_standard_setframeandspeedandmorphandmode(cKF_SkeletonInfo_R_c* keyframe,
cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 frame,
f32 frame_speed, f32 morph_counter,
int mode);
/**
* Initializes a skeleton info structure for reverse playback with specified speed, morph counter, and mode.
*
* @param keyframe Pointer to the skeleton info structure.
* @param animation Pointer to the animation data.
* @param rotation_diff_table Pointer to the rotation difference table.
* @param frame_speed Animation playback speed in reverse.
* @param morph_counter Counter for morphing between animations.
* @param mode Animation mode (e.g., repeat, stop).
*/
extern void cKF_SkeletonInfo_R_init_reverse_setspeedandmorphandmode(cKF_SkeletonInfo_R_c* keyframe,
cKF_Animation_R_c* animation,
s_xyz* rotation_diff_table, f32 frame_speed,
f32 morph_counter, int mode);
/**
* Prepares combine work set structure for joint animation combination.
*
* @param combine Pointer to the combine work set structure.
* @param keyframe Pointer to the skeleton info structure.
*/
extern void cKF_SkeletonInfo_R_combine_work_set(cKF_SkeletonInfo_R_combine_work_c* combine,
cKF_SkeletonInfo_R_c* keyframe);
/**
* Combines translation data for joints based on animation flags, supporting up to three animation layers.
*
* @param joint Pointer to the joint data.
* @param flag Pointer to the current joint flag.
* @param combine Pointer to the combine work set structure.
* @param cwork_num Pointer to the current work layer number.
*/
extern void cKF_SkeletonInfo_R_combine_translation(s16** joint, int* flag, cKF_SkeletonInfo_R_combine_work_c* combine,
s8* cwork_num);
/**
* Combines rotation data from multiple animation layers for a joint, modifying it based on animation flags.
*
* @param joint Pointer to the current joint's rotation data.
* @param flag Pointer to the animation flag affecting the current joint.
* @param combine Pointer to the combine work set structure containing animation layer data.
* @param cwork_num Pointer to the layer number being processed.
*/
extern void cKF_SkeletonInfo_R_combine_rotation(s16** joint, int* flag, cKF_SkeletonInfo_R_combine_work_c* combine,
s8* cwork_num);
/**
* Combines and plays two sets of animation data, applying translations and rotations from both.
*
* @param info1 First skeleton info structure to combine.
* @param info2 Second skeleton info structure to combine.
* @param flag Pointer to a flag determining the combination behavior.
* @return Status of the combination and play operation.
*/
extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_SkeletonInfo_R_c* info2, s8* flag);
/**
* Combines and plays three sets of animation data, applying translations and rotations, and updates playback state.
*
* @param arg1 Result of playing first animation.
* @param arg2 Result of playing second animation.
* @param arg3 Result of playing third animation.
* @param info1 First skeleton info structure to combine.
* @param info2 Second skeleton info structure to combine.
* @param info3 Third skeleton info structure to combine.
* @param flag Pointer to a flag determining the combination behavior.
*/
extern void cKF_SkeletonInfo_R_T_combine_play(int* arg1, int* arg2, int* arg3, cKF_SkeletonInfo_R_c* info1,
cKF_SkeletonInfo_R_c* info2, cKF_SkeletonInfo_R_c* info3, s8* flag);
/**
* Sets base shape translation and rotation for a skeleton info structure.
*
* @param transx X translation of the base model.
* @param transy Y translation of the base model.
* @param transz Z translation of the base model.
* @param keyframe Skeleton info structure to modify.
* @param anglex X angle for base model rotation.
* @param angley Y angle for base model rotation.
* @param anglez Z angle for base model rotation.
*/
extern void cKF_SkeletonInfo_R_Animation_Set_base_shape_trs(f32 transx, f32 transy, f32 transz,
cKF_SkeletonInfo_R_c* keyframe, s16 anglex, s16 angley,
s16 anglez);
/**
* Adjusts the base position and correction for a skeleton info structure based on animation flags.
*
* @param counter Animation counter to determine the phase of movement.
* @param basepos Original base position of the model.
* @param correctpos Corrected base position of the model.
* @param ybase Base Y angle for rotation.
* @param yidle Idle Y angle for rotation.
* @param keyframe Skeleton info structure to modify.
* @param an_flag Animation flags to determine which corrections to apply.
*/
extern void cKF_SkeletonInfo_R_AnimationMove_ct_base(f32 counter, xyz_t* basepos, xyz_t* correctpos, s16 ybase,
s16 yidle, cKF_SkeletonInfo_R_c* keyframe, int animation_flag);
/**
* Resets animation movement and flags for a skeleton info structure.
*
* @param keyframe The skeleton info structure to reset.
*/
extern void cKF_SkeletonInfo_R_AnimationMove_dt(cKF_SkeletonInfo_R_c* keyframe);
extern void cKF_SkeletonInfo_R_AnimationMove_base(xyz_t* base, s_xyz* sbase, xyz_t* move, s16 yidle, cKF_SkeletonInfo_R_c* keyframe);
extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(f32 calcx, f32 calcy, f32 calcz, xyz_t* base, xyz_t* calcp, s16 val, xyz_t* trans, cKF_SkeletonInfo_R_c* keyframe, int animation_flag);
/**
* Applies base movement and adjustment based on animation counter and flags.
*
* @param base Base position to modify.
* @param sbase Base rotation to modify.
* @param move Movement amount to apply.
* @param yidle Y-axis idle angle.
* @param keyframe Skeleton info structure containing animation data.
*/
extern void cKF_SkeletonInfo_R_AnimationMove_base(xyz_t* base, s_xyz* sbase, xyz_t* move, s16 yidle,
cKF_SkeletonInfo_R_c* keyframe);
/**
* Calculates and applies transformation to world coordinates based on animation data.
*
* @param calcx X-coordinate for calculation base.
* @param calcy Y-coordinate for calculation base.
* @param calcz Z-coordinate for calculation base.
* @param base Base position result.
* @param calcp Position calculation parameters.
* @param val Angle value for rotation.
* @param trans Transformation to apply.
* @param keyframe Skeleton info structure containing animation data.
* @param animation_flag Flags determining which transformations to apply.
*/
extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld(f32 calcx, f32 calcy, f32 calcz, xyz_t* base,
xyz_t* calcp, s16 val, xyz_t* trans,
cKF_SkeletonInfo_R_c* keyframe, int animation_flag);
#ifdef __cplusplus
}
+3
View File
@@ -23,6 +23,9 @@ extern "C" {
#define SQ(x) ((x)*(x))
#define CLAMP_MAX(x, min) ((min) < (x) ? (min) : (x))
/* Percent of 360 deg */
#define MOD_F(a, m) (a - (int)((a) * (1.0f / (m))) * (m))
/* radians -> short angle */
#define RAD2SHORT_ANGLE(rad) ((s16)(int)((rad) * (65536.0f / (2.0f * F_PI))))
#define RAD2SHORTANGLE(rad) ((s16)((32768.0f / F_PI) * ((f32)(rad))))
+1032 -957
View File
File diff suppressed because it is too large Load Diff
+408
View File
@@ -0,0 +1,408 @@
#include "types.h"
#include "c_keyframe.h"
#include "libforest/gbi_extensions.h"
// TODO: assetrip textures & vertices then link
static u8 obj_s_boat_t10_tex_txt[128];
static u8 obj_s_boat_t11_tex_txt[128];
static u8 obj_s_boat_t9_tex_txt[192];
static u8 obj_s_boat_t6_tex_txt[256];
static u8 obj_s_boat_t7_tex_txt[128];
static u8 obj_s_boat_t1_tex_txt[1024];
static u8 obj_s_boat_t3_tex_txt[1024];
static u8 obj_s_boat_t2_tex_txt[128];
static u8 obj_s_boat_t5_tex_txt[128];
static u8 obj_s_boat_t8_tex_txt[128];
static u8 obj_s_boat_t4_tex_txt[128];
static u8 obj_s_boat_water1_pic_i4[512];
static u8 obj_s_boat_water2_pic_i4[256];
static Vtx obj_e_boat_v[156];
static Gfx obj_e_boat_boat1_model[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0, PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t6_tex_txt, G_IM_FMT_CI, 16, 32, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsDPSetPrimColor(0, 128, 255, 255, 255, 255),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[30], 30, 0),
gsSPNTrianglesInit_5b(
4, // tri count
0, 1, 2, // tri0
0, 2, 3, // tri1
4, 5, 6 // tri2
),
gsSPNTriangles_5b(
4, 6, 7, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t7_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsSPNTrianglesInit_5b(
2, // tri count
8, 9, 10, // tri0
8, 10, 11, // tri1
0, 0, 0 // tri2
),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
2, // tri count
12, 13, 14, // tri0
12, 14, 15, // tri1
0, 0, 0 // tri2
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t1_tex_txt, G_IM_FMT_CI, 32, 64, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
5, // tri count
16, 17, 18, // tri0
16, 18, 19, // tri1
16, 20, 21 // tri2
),
gsSPNTriangles_5b(
16, 21, 17, // tri0
20, 22, 21, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t3_tex_txt, G_IM_FMT_CI, 32, 64, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsSPNTrianglesInit_5b(
5, // tri count
23, 24, 25, // tri0
23, 25, 26, // tri1
23, 27, 24 // tri2
),
gsSPNTriangles_5b(
26, 25, 28, // tri0
26, 28, 29, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t2_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[60], 31, 0),
gsSPNTrianglesInit_5b(
8, // tri count
0, 1, 2, // tri0
0, 2, 3, // tri1
4, 5, 6 // tri2
),
gsSPNTriangles_5b(
4, 6, 7, // tri0
8, 9, 10, // tri1
8, 10, 11, // tri2
12, 13, 14 // tri3
),
gsSPNTriangles_5b(
12, 14, 15, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t5_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPNTrianglesInit_5b(
4, // tri count
16, 17, 18, // tri0
16, 18, 19, // tri1
20, 21, 22 // tri2
),
gsSPNTriangles_5b(
20, 22, 16, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t8_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
2, // tri count
23, 24, 25, // tri0
23, 25, 26, // tri1
0, 0, 0 // tri2
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t4_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
2, // tri count
27, 28, 29, // tri0
27, 29, 30, // tri1
0, 0, 0 // tri2
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t3_tex_txt, G_IM_FMT_CI, 32, 64, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsSPVertex(&obj_e_boat_v[91], 7, 0),
gsSPNTrianglesInit_5b(
5, // tri count
0, 1, 2, // tri0
0, 3, 1, // tri1
4, 5, 6 // tri2
),
gsSPNTriangles_5b(
4, 3, 0, // tri0
4, 6, 3, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsSPEndDisplayList(),
};
static Gfx obj_e_boat_water1_model[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, COMBINED, 0, TEXEL0, 0),
gsDPSetPrimColor(0, 255, 190, 210, 255, 230),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water2_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water1_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 14),
gsSPDisplayList(0x09000000),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[142], 14, 0),
gsSPNTrianglesInit_5b(
14, // tri count
0, 1, 2, // tri0
2, 1, 3, // tri1
4, 5, 6 // tri2
),
gsSPNTriangles_5b(
2, 7, 8, // tri0
2, 9, 0, // tri1
10, 11, 12, // tri2
8, 9, 2 // tri3
),
gsSPNTriangles_5b(
3, 7, 2, // tri0
8, 13, 10, // tri1
6, 13, 8, // tri2
8, 12, 9 // tri3
),
gsSPNTriangles_5b(
10, 12, 8, // tri0
8, 4, 6, // tri1
7, 4, 8, // tri2
0, 0, 0 // tri3
),
gsSPEndDisplayList(),
};
static Gfx obj_e_boat_water2_model[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, COMBINED, 0, TEXEL0, 0),
gsDPSetPrimColor(0, 255, 190, 210, 255, 230),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water2_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water1_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 14),
gsSPDisplayList(0x09000000),
gsSPMatrix(0x0D000080, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[125], 5, 0),
gsSPMatrix(0x0D0000C0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW),
gsSPVertex(&obj_e_boat_v[130], 12, 5),
gsSPNTrianglesInit_5b(
8, // tri count
1, 5, 6, // tri0
3, 7, 8, // tri1
0, 4, 9 // tri2
),
gsSPNTriangles_5b(
4, 10, 11, // tri0
0, 12, 13, // tri1
4, 2, 14, // tri2
3, 1, 15 // tri3
),
gsSPNTriangles_5b(
2, 3, 16, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsSPEndDisplayList(),
};
static Gfx obj_e_boat_water3_model[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, COMBINED, 0, TEXEL0, 0),
gsDPSetPrimColor(0, 255, 190, 210, 255, 230),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water2_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 0),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_water1_pic_i4, G_IM_FMT_I, 32, 32, 15, GX_REPEAT, GX_REPEAT, 0, 14),
gsSPDisplayList(0x09000000),
gsSPMatrix(0x0D0000C0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[98], 5, 0),
gsSPMatrix(0x0D000100, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW),
gsSPVertex(&obj_e_boat_v[103], 22, 5),
gsSPNTrianglesInit_5b(
8, // tri count
0, 1, 5, // tri0
0, 6, 7, // tri1
1, 2, 8 // tri2
),
gsSPNTriangles_5b(
2, 3, 9, // tri0
3, 4, 10, // tri1
4, 11, 12, // tri2
3, 13, 14 // tri3
),
gsSPNTriangles_5b(
1, 15, 16, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsSPNTrianglesInit_5b(
8, // tri count
17, 18, 19, // tri0
20, 21, 22, // tri1
19, 23, 24 // tri2
),
gsSPNTriangles_5b(
20, 22, 25, // tri0
23, 26, 24, // tri1
25, 26, 23, // tri2
25, 23, 20 // tri3
),
gsSPNTriangles_5b(
24, 17, 19, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsSPEndDisplayList(),
};
static Gfx obj_e_boat_oar1_model[] = {
gsSPTexture(0, 0, 0, 0, G_ON),
gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0, PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED),
gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t10_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0),
gsDPSetPrimColor(0, 128, 255, 255, 255, 255),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(&obj_e_boat_v[0], 30, 0),
gsSPNTrianglesInit_5b(
2, // tri count
0, 1, 2, // tri0
3, 4, 5, // tri1
0, 0, 0 // tri2
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t11_tex_txt, G_IM_FMT_CI, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0),
gsSPNTrianglesInit_5b(
6, // tri count
6, 7, 8, // tri0
6, 8, 9, // tri1
10, 11, 12 // tri2
),
gsSPNTriangles_5b(
10, 12, 13, // tri0
14, 15, 16, // tri1
14, 16, 17, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t9_tex_txt, G_IM_FMT_CI, 48, 8, 15, GX_CLAMP, GX_MIRROR, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
4, // tri count
18, 19, 20, // tri0
21, 18, 20, // tri1
22, 23, 24 // tri2
),
gsSPNTriangles_5b(
25, 22, 24, // tri0
0, 0, 0, // tri1
0, 0, 0, // tri2
0, 0, 0 // tri3
),
gsDPLoadTextureBlock_4b_Dolphin(obj_s_boat_t9_tex_txt, G_IM_FMT_CI, 48, 8, 15, GX_CLAMP, GX_CLAMP, 0, 0),
gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH),
gsSPNTrianglesInit_5b(
2, // tri count
26, 27, 28, // tri0
26, 28, 29, // tri1
0, 0, 0 // tri2
),
gsSPEndDisplayList(),
};
extern cKF_Joint_R_c cKF_je_r_obj_e_boat_tbl[] = {
/* joint 0 */ obj_e_boat_boat1_model, 2, cKF_JOINT_FLAG_DISP_OPA, 0,0,0,
/* joint 1 */ NULL, 1, cKF_JOINT_FLAG_DISP_OPA, 300,2200,-4500,
/* joint 2 */ obj_e_boat_oar1_model, 0, cKF_JOINT_FLAG_DISP_OPA, 0,0,0,
/* joint 3 */ NULL, 1, cKF_JOINT_FLAG_DISP_OPA, 0,0,4000,
/* joint 4 */ obj_e_boat_water1_model, 1, cKF_JOINT_FLAG_DISP_XLU, 0,0,0,
/* joint 5 */ obj_e_boat_water2_model, 1, cKF_JOINT_FLAG_DISP_XLU, 8400,0,0,
/* joint 6 */ obj_e_boat_water3_model, 0, cKF_JOINT_FLAG_DISP_XLU, 4600,0,0,
};
extern cKF_Skeleton_R_c cKF_bs_r_obj_e_boat = {
7, // 7 total joints
5, // 5 displayed joints (rendered joints)
cKF_je_r_obj_e_boat_tbl
};
static u8 cKF_ckcb_r_obj_e_boat_tbl[] = {
/* joint 0 */ cKF_ANIMITION_BIT_NONE,
/* joint 1 */ cKF_ANIMITION_BIT_NONE,
/* joint 2 */ cKF_ANIMATION_BIT_ROT_X | cKF_ANIMATION_BIT_ROT_Y | cKF_ANIMATION_BIT_ROT_Z,
/* joint 3 */ cKF_ANIMITION_BIT_NONE,
/* joint 4 */ cKF_ANIMITION_BIT_NONE,
/* joint 5 */ cKF_ANIMITION_BIT_NONE,
/* joint 6 */ cKF_ANIMITION_BIT_NONE
};
static s16 cKF_kn_obj_e_boat_tbl[] = {
8,
5,
9
};
// Fixed position table (used when the joint has no translation)
static s16 cKF_c_obj_e_boat_tbl[] = {
/* joint 0 */ 0, 0, 0,
/* joint 1 */ 0, 0, 0,
/* joint 2 */ 0, 900, 900,
/* joint 3 */ -450, 900, 450,
/* joint 4 */ 0, 0, 0,
/* joint 5 */ 0, 0, 0,
/* joint 6 */ 0, 0, 0
};
/* frame value slope */
static s16 cKF_ds_obj_e_boat_tbl[] = {
/* joint 2 X rotational frames */
1, 904, 648,
13, 1075, 212,
23, 1099, -60,
40, 920, -572,
45, 828, -481,
62, 701, 20,
80, 877, 651,
81, 900, 675,
/* joint 2 Y rotational frames */
1, 449, 134,
27, 495, -50,
43, 442, -124,
67, 405, 49,
81, 449, 132,
/* joint 2 Z rotational frames */
1, -180, 143,
5, -143, 443,
20, 141, 303,
26, 177, 119,
40, 183, -81,
44, 156, -370,
60, -141, -305,
65, -173, -137,
81, -180, 83
};
extern cKF_Animation_R_c cKF_ba_r_obj_e_boat = {
cKF_ckcb_r_obj_e_boat_tbl,
cKF_ds_obj_e_boat_tbl,
cKF_kn_obj_e_boat_tbl,
cKF_c_obj_e_boat_tbl,
-1,
81
};