mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
camera_freeze, camera_unfreeze, djui_hud_get_mouse_x, djui_hud_get_mouse_y, set_override_fov, set_override_near, set_override_far (#74)
This commit is contained in:
parent
8812fbac8b
commit
6466fbe457
15 changed files with 327 additions and 2 deletions
|
@ -3565,6 +3565,16 @@ function djui_chat_message_create(message)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @return number
|
||||
function djui_hud_get_mouse_x()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return number
|
||||
function djui_hud_get_mouse_y()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function djui_hud_get_screen_height()
|
||||
-- ...
|
||||
|
@ -7122,6 +7132,16 @@ function allocate_mario_action(actFlags)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function camera_freeze()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return nil
|
||||
function camera_unfreeze()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param pointer Pointer_integer
|
||||
--- @return integer
|
||||
function deref_s32_pointer(pointer)
|
||||
|
@ -7236,6 +7256,24 @@ function set_environment_region(index, value)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param far number
|
||||
--- @return number
|
||||
function set_override_far(far)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param fov number
|
||||
--- @return number
|
||||
function set_override_fov(fov)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param near number
|
||||
--- @return number
|
||||
function set_override_near(near)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param aDelay integer
|
||||
--- @return boolean
|
||||
function warp_exit_level(aDelay)
|
||||
|
|
|
@ -1997,6 +1997,42 @@
|
|||
<br />
|
||||
|
||||
|
||||
## [djui_hud_get_mouse_x](#djui_hud_get_mouse_x)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = djui_hud_get_mouse_x()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 djui_hud_get_mouse_x(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [djui_hud_get_mouse_y](#djui_hud_get_mouse_y)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = djui_hud_get_mouse_y()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 djui_hud_get_mouse_y(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [djui_hud_get_screen_height](#djui_hud_get_screen_height)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -4701,6 +4701,42 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [camera_freeze](#camera_freeze)
|
||||
|
||||
### Lua Example
|
||||
`camera_freeze()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void camera_freeze(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [camera_unfreeze](#camera_unfreeze)
|
||||
|
||||
### Lua Example
|
||||
`camera_unfreeze()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void camera_unfreeze(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [deref_s32_pointer](#deref_s32_pointer)
|
||||
|
||||
### Lua Example
|
||||
|
@ -5049,6 +5085,66 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_override_far](#set_override_far)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = set_override_far(far)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| far | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 set_override_far(f32 far);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_override_fov](#set_override_fov)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = set_override_fov(fov)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| fov | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 set_override_fov(f32 fov);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_override_near](#set_override_near)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = set_override_near(near)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| near | `number` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 set_override_near(f32 near);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [warp_exit_level](#warp_exit_level)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -699,6 +699,8 @@
|
|||
<br />
|
||||
|
||||
- djui_hud_utils.h
|
||||
- [djui_hud_get_mouse_x](functions-3.md#djui_hud_get_mouse_x)
|
||||
- [djui_hud_get_mouse_y](functions-3.md#djui_hud_get_mouse_y)
|
||||
- [djui_hud_get_screen_height](functions-3.md#djui_hud_get_screen_height)
|
||||
- [djui_hud_get_screen_width](functions-3.md#djui_hud_get_screen_width)
|
||||
- [djui_hud_measure_text](functions-3.md#djui_hud_measure_text)
|
||||
|
@ -1333,6 +1335,8 @@
|
|||
|
||||
- smlua_misc_utils.h
|
||||
- [allocate_mario_action](functions-4.md#allocate_mario_action)
|
||||
- [camera_freeze](functions-4.md#camera_freeze)
|
||||
- [camera_unfreeze](functions-4.md#camera_unfreeze)
|
||||
- [deref_s32_pointer](functions-4.md#deref_s32_pointer)
|
||||
- [get_current_save_file_num](functions-4.md#get_current_save_file_num)
|
||||
- [get_environment_region](functions-4.md#get_environment_region)
|
||||
|
@ -1350,6 +1354,9 @@
|
|||
- [play_transition](functions-4.md#play_transition)
|
||||
- [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot)
|
||||
- [set_environment_region](functions-4.md#set_environment_region)
|
||||
- [set_override_far](functions-4.md#set_override_far)
|
||||
- [set_override_fov](functions-4.md#set_override_fov)
|
||||
- [set_override_near](functions-4.md#set_override_near)
|
||||
- [warp_exit_level](functions-4.md#warp_exit_level)
|
||||
- [warp_restart_level](functions-4.md#warp_restart_level)
|
||||
- [warp_to_castle](functions-4.md#warp_to_castle)
|
||||
|
|
|
@ -917,3 +917,13 @@ s32 anim_spline_poll(struct MarioState* m, Vec3f result) {
|
|||
|
||||
return hasEnded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the second value if it does not equal zero.
|
||||
*/
|
||||
f32 not_zero(f32 value, f32 replacement) {
|
||||
if (replacement != 0) {
|
||||
return replacement;
|
||||
}
|
||||
return value;
|
||||
}
|
|
@ -80,4 +80,6 @@ void spline_get_weights(struct MarioState* m, Vec4f result, f32 t, UNUSED s32 c)
|
|||
void anim_spline_init(struct MarioState* m, Vec4s *keyFrames);
|
||||
s32 anim_spline_poll(struct MarioState* m, Vec3f result);
|
||||
|
||||
f32 not_zero(f32 value, f32 replacement);
|
||||
|
||||
#endif // MATH_UTIL_H
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
static u8 sSoftResettingCamera = FALSE;
|
||||
u8 gCameraUseCourseSpecificSettings = TRUE;
|
||||
u8 gOverrideFreezeCamera;
|
||||
|
||||
/**
|
||||
* @file camera.c
|
||||
|
@ -3049,6 +3050,9 @@ void update_lakitu(struct Camera *c) {
|
|||
* Gets controller input, checks for cutscenes, handles mode changes, and moves the camera
|
||||
*/
|
||||
void update_camera(struct Camera *c) {
|
||||
if (gOverrideFreezeCamera) {
|
||||
return;
|
||||
}
|
||||
UNUSED u8 unused[24];
|
||||
|
||||
gCamera = c;
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "level_table.h"
|
||||
|
||||
extern u8 gOverrideFreezeCamera;
|
||||
|
||||
/**
|
||||
* @file camera.h
|
||||
* Constants, defines, and structs used by the camera system.
|
||||
|
|
|
@ -173,6 +173,10 @@ s32 gMtxTblSize;
|
|||
struct Object* gCurGraphNodeProcessingObject = NULL;
|
||||
struct MarioState* gCurGraphNodeMarioState = NULL;
|
||||
|
||||
f32 gOverrideFOV = 0;
|
||||
f32 gOverrideNear = 0;
|
||||
f32 gOverrideFar = 0;
|
||||
|
||||
void patch_mtx_before(void) {
|
||||
gMtxTblSize = 0;
|
||||
|
||||
|
@ -203,7 +207,7 @@ void patch_mtx_interpolated(f32 delta) {
|
|||
if (sPerspectiveNode != NULL) {
|
||||
u16 perspNorm;
|
||||
f32 fovInterpolated = delta_interpolate_f32(sPerspectiveNode->prevFov, sPerspectiveNode->fov, delta);
|
||||
guPerspective(sPerspectiveMtx, &perspNorm, fovInterpolated, sPerspectiveAspect, sPerspectiveNode->near, sPerspectiveNode->far, 1.0f);
|
||||
guPerspective(sPerspectiveMtx, &perspNorm, not_zero(fovInterpolated, gOverrideFOV), sPerspectiveAspect, not_zero(sPerspectiveNode->near, gOverrideNear), not_zero(sPerspectiveNode->far, gOverrideFar), 1.0f);
|
||||
gSPMatrix(sPerspectivePos, VIRTUAL_TO_PHYSICAL(sPerspectiveNode), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
}
|
||||
|
||||
|
@ -406,7 +410,7 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
|
|||
f32 aspect = (f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height;
|
||||
#endif
|
||||
|
||||
guPerspective(mtx, &perspNorm, node->prevFov, aspect, node->near, node->far, 1.0f);
|
||||
guPerspective(mtx, &perspNorm, not_zero(node->prevFov, gOverrideFOV), aspect, not_zero(node->near, gOverrideNear), not_zero(node->far, gOverrideFar), 1.0f);
|
||||
|
||||
sPerspectiveNode = node;
|
||||
sPerspectiveMtx = mtx;
|
||||
|
|
|
@ -28,6 +28,10 @@ extern struct Object* gCurGraphNodeProcessingObject;
|
|||
// translation types the type is set to this
|
||||
#define ANIM_TYPE_ROTATION 5
|
||||
|
||||
extern f32 gOverrideFOV;
|
||||
extern f32 gOverrideNear;
|
||||
extern f32 gOverrideFar;
|
||||
|
||||
void geo_process_node_and_siblings(struct GraphNode *firstNode);
|
||||
void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor);
|
||||
void interpolate_vectors(Vec3f res, Vec3f a, Vec3f b);
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <PR/gbi.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pc/controller/controller_sdl.h"
|
||||
#include "pc/controller/controller_mouse.h"
|
||||
#include "pc/gfx/gfx_pc.h"
|
||||
#include "pc/gfx/gfx_window_manager_api.h"
|
||||
#include "pc/pc_main.h"
|
||||
|
@ -83,6 +85,16 @@ u32 djui_hud_get_screen_height(void) {
|
|||
: (windowHeight / djui_gfx_get_scale());
|
||||
}
|
||||
|
||||
f32 djui_hud_get_mouse_x(void) {
|
||||
controller_sdl_read_mouse_window();
|
||||
return mouse_window_x / djui_gfx_get_scale();
|
||||
}
|
||||
|
||||
f32 djui_hud_get_mouse_y(void) {
|
||||
controller_sdl_read_mouse_window();
|
||||
return mouse_window_y / djui_gfx_get_scale();
|
||||
}
|
||||
|
||||
f32 djui_hud_measure_text(const char* message) {
|
||||
if (message == NULL) { return 0; }
|
||||
const struct DjuiFont* font = gDjuiFonts[sFont];
|
||||
|
|
|
@ -34,6 +34,9 @@ void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a);
|
|||
u32 djui_hud_get_screen_width(void);
|
||||
u32 djui_hud_get_screen_height(void);
|
||||
|
||||
f32 djui_hud_get_mouse_x(void);
|
||||
f32 djui_hud_get_mouse_y(void);
|
||||
|
||||
f32 djui_hud_measure_text(const char* message);
|
||||
void djui_hud_print_text(const char* message, float x, float y, float scale);
|
||||
void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);
|
||||
|
|
|
@ -7186,6 +7186,24 @@ int smlua_func_djui_chat_message_create(lua_State* L) {
|
|||
// djui_hud_utils.h //
|
||||
//////////////////////
|
||||
|
||||
int smlua_func_djui_hud_get_mouse_x(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
lua_pushnumber(L, djui_hud_get_mouse_x());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_djui_hud_get_mouse_y(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
lua_pushnumber(L, djui_hud_get_mouse_y());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_djui_hud_get_screen_height(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
@ -14679,6 +14697,24 @@ int smlua_func_allocate_mario_action(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_camera_freeze(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
camera_freeze();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_camera_unfreeze(UNUSED lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||
|
||||
|
||||
camera_unfreeze();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_deref_s32_pointer(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
@ -14890,6 +14926,39 @@ int smlua_func_set_environment_region(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_override_far(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
f32 far = smlua_to_number(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, set_override_far(far));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_override_fov(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
f32 fov = smlua_to_number(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, set_override_fov(fov));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_override_near(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
f32 near = smlua_to_number(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; }
|
||||
|
||||
lua_pushnumber(L, set_override_near(near));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_warp_exit_level(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
@ -16509,6 +16578,8 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "djui_chat_message_create", smlua_func_djui_chat_message_create);
|
||||
|
||||
// djui_hud_utils.h
|
||||
smlua_bind_function(L, "djui_hud_get_mouse_x", smlua_func_djui_hud_get_mouse_x);
|
||||
smlua_bind_function(L, "djui_hud_get_mouse_y", smlua_func_djui_hud_get_mouse_y);
|
||||
smlua_bind_function(L, "djui_hud_get_screen_height", smlua_func_djui_hud_get_screen_height);
|
||||
smlua_bind_function(L, "djui_hud_get_screen_width", smlua_func_djui_hud_get_screen_width);
|
||||
smlua_bind_function(L, "djui_hud_measure_text", smlua_func_djui_hud_measure_text);
|
||||
|
@ -17110,6 +17181,8 @@ void smlua_bind_functions_autogen(void) {
|
|||
|
||||
// smlua_misc_utils.h
|
||||
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
|
||||
smlua_bind_function(L, "camera_freeze", smlua_func_camera_freeze);
|
||||
smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze);
|
||||
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
|
||||
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
|
@ -17127,6 +17200,9 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "play_transition", smlua_func_play_transition);
|
||||
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
smlua_bind_function(L, "set_override_far", smlua_func_set_override_far);
|
||||
smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov);
|
||||
smlua_bind_function(L, "set_override_near", smlua_func_set_override_near);
|
||||
smlua_bind_function(L, "warp_exit_level", smlua_func_warp_exit_level);
|
||||
smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level);
|
||||
smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle);
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#include "types.h"
|
||||
|
||||
#include "data/dynos.c.h"
|
||||
#include "game/camera.h"
|
||||
#include "game/hud.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "smlua_misc_utils.h"
|
||||
#include "pc/debuglog.h"
|
||||
#include "game/object_list_processor.h"
|
||||
#include "game/rendering_graph_node.h"
|
||||
#include "game/level_update.h"
|
||||
#include "pc/djui/djui_hud_utils.h"
|
||||
|
||||
|
@ -98,6 +100,16 @@ void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height) {
|
|||
|
||||
///
|
||||
|
||||
void camera_freeze(void) {
|
||||
gOverrideFreezeCamera = TRUE;
|
||||
}
|
||||
|
||||
void camera_unfreeze(void) {
|
||||
gOverrideFreezeCamera = FALSE;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct) {
|
||||
return dynos_warp_to_level(aLevel, aArea, aAct);
|
||||
}
|
||||
|
@ -168,3 +180,15 @@ void set_environment_region(u8 index, s32 value) {
|
|||
gEnvironmentRegions[6 * (int)index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
f32 set_override_fov(f32 fov) {
|
||||
gOverrideFOV = fov;
|
||||
}
|
||||
|
||||
f32 set_override_near(f32 near) {
|
||||
gOverrideNear = near;
|
||||
}
|
||||
|
||||
f32 set_override_far(f32 far) {
|
||||
gOverrideFar = far;
|
||||
}
|
|
@ -36,6 +36,9 @@ s32 hud_get_value(enum HudDisplayValue type);
|
|||
void hud_set_value(enum HudDisplayValue type, s32 value);
|
||||
void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height);
|
||||
|
||||
void camera_freeze(void);
|
||||
void camera_unfreeze(void);
|
||||
|
||||
bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct);
|
||||
bool warp_restart_level(void);
|
||||
bool warp_exit_level(s32 aDelay);
|
||||
|
@ -54,6 +57,10 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type);
|
|||
f32 get_environment_region(u8 index);
|
||||
void set_environment_region(u8 index, s32 value);
|
||||
|
||||
f32 set_override_fov(f32 fov);
|
||||
f32 set_override_near(f32 near);
|
||||
f32 set_override_far(f32 far);
|
||||
|
||||
void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue