Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
cam_mode_unused_ahead.c
Go to the documentation of this file.
1
#include "common.h"
2
3
// implements CAM_UPDATE_UNUSED_AHEAD
4
// this mode is completely unused in vanilla; it doesn't even have a case in update_cameras
5
// seems to be based on CAM_UPDATE_NO_INTERP (the one used for battle cam)
6
// tracks a point 400 units ahead of player position in the z-direction and 60 units above
7
// defaults to a relatively short boom length and no pitch angle, resulting in a head-on direct view
8
//
9
// control parameters:
10
// dist -- length of the camera boom arm
11
// pitch -- rising angle of the boom arm, up toward the y-axis
12
// yaw -- yaw angle for the boom arm in the xz-plane
13
// skipRecalc -- do not calculate lookAt_obj and lookAt_eye from params
14
void
update_camera_unused_ahead
(
Camera
* camera) {
15
f32 yawAngle, sinYaw, cosYaw;
16
f32 pitchAngle, sinPitch, cosPitch;
17
f32 dx, dy, dz, dr;
18
19
if
(camera->
needsInit
|| camera->
needsReinit
) {
20
camera->
needsInit
= FALSE;
21
camera->
needsReinit
= FALSE;
22
camera->
params
.basic.skipRecalc = FALSE;
23
camera->
params
.basic.dist = 100;
24
camera->
params
.basic.pitch = 0;
25
camera->
params
.basic.yaw = 0;
26
camera->
params
.basic.fovScale = 100;
27
28
camera->
lookAt_obj
.
x
= camera->
lookAt_obj_target
.
x
;
29
camera->
lookAt_obj
.
y
= camera->
lookAt_obj_target
.
y
;
30
camera->
lookAt_obj
.
z
= camera->
lookAt_obj_target
.
z
;
31
}
32
33
if
(!(
gPlayerStatus
.
flags
& (
PS_FLAG_FALLING
|
PS_FLAG_JUMPING
))) {
34
camera->
lookAt_obj_target
.
y
=
gPlayerStatus
.
pos
.
y
+ 60.0f;
35
}
36
camera->
lookAt_obj_target
.
x
=
gPlayerStatus
.
pos
.
x
;
37
camera->
lookAt_obj_target
.
z
=
gPlayerStatus
.
pos
.
z
+ 400.0f;
38
39
if
(!camera->
params
.basic.skipRecalc) {
40
camera->
lookAt_obj
.
x
= camera->
lookAt_obj_target
.
x
;
41
camera->
lookAt_obj
.
y
= camera->
lookAt_obj_target
.
y
;
42
camera->
lookAt_obj
.
z
= camera->
lookAt_obj_target
.
z
;
43
44
camera->
curBoomYaw
= camera->
params
.basic.yaw;
45
camera->
curBoomPitch
= camera->
params
.basic.pitch;
46
camera->
curBoomLength
= camera->
params
.basic.dist;
47
camera->
vfov
= (10000 / camera->
params
.basic.fovScale) / 4;
48
49
pitchAngle =
DEG_TO_RAD
(camera->
curBoomPitch
);
50
sinPitch =
sin_rad
(pitchAngle);
51
cosPitch =
cos_rad
(pitchAngle);
52
53
yawAngle =
DEG_TO_RAD
(camera->
curBoomYaw
);
54
sinYaw =
sin_rad
(yawAngle);
55
cosYaw =
cos_rad
(yawAngle);
56
57
dy = camera->
curBoomLength
* sinPitch;
58
dx = camera->
curBoomLength
* cosPitch * -sinYaw;
59
dz = camera->
curBoomLength
* cosPitch * cosYaw;
60
61
camera->
lookAt_eye
.
x
= camera->
lookAt_obj
.
x
+ dx;
62
camera->
lookAt_eye
.
y
= camera->
lookAt_obj
.
y
+ dy;
63
camera->
lookAt_eye
.
z
= camera->
lookAt_obj
.
z
+ dz;
64
}
65
66
dx = camera->
lookAt_obj
.
x
- camera->
lookAt_eye
.
x
;
67
dy = camera->
lookAt_obj
.
y
- camera->
lookAt_eye
.
y
;
68
dz = camera->
lookAt_obj
.
z
- camera->
lookAt_eye
.
z
;
69
dr =
sqrtf
(
SQ
(dx) +
SQ
(dz));
70
71
camera->
lookAt_yaw
= -
atan2
(0.0f, 0.0f, dx, dz);
72
camera->
lookAt_pitch
=
atan2
(0.0f, 0.0f, dy, -dr);
73
camera->
curYaw
=
atan2
(camera->
lookAt_eye
.
x
, camera->
lookAt_eye
.
z
, camera->
lookAt_obj
.
x
, camera->
lookAt_obj
.
z
);
74
}
update_camera_unused_ahead
void update_camera_unused_ahead(Camera *camera)
Definition
cam_mode_unused_ahead.c:14
Vec3f::z
f32 z
Definition
common_structs.h:102
PlayerStatus::flags
s32 flags
Definition
common_structs.h:1980
PlayerStatus::pos
Vec3f pos
Definition
common_structs.h:1995
Vec3f::x
f32 x
Definition
common_structs.h:100
Vec3f::y
f32 y
Definition
common_structs.h:101
sqrtf
#define sqrtf
Definition
effect_shims.h:60
atan2
#define atan2
Definition
effect_shims.h:57
PS_FLAG_FALLING
@ PS_FLAG_FALLING
Definition
enums.h:3036
PS_FLAG_JUMPING
@ PS_FLAG_JUMPING
Definition
enums.h:3035
cos_rad
f32 cos_rad(f32 x)
Definition
43F0.c:717
sin_rad
f32 sin_rad(f32 x)
Definition
43F0.c:713
DEG_TO_RAD
#define DEG_TO_RAD(deg)
Definition
macros.h:134
SQ
#define SQ(x)
Definition
macros.h:166
Camera
Definition
common_structs.h:748
Camera::lookAt_obj
Vec3f lookAt_obj
Definition
common_structs.h:797
Camera::needsReinit
b16 needsReinit
Definition
common_structs.h:753
Camera::vfov
f32 vfov
Definition
common_structs.h:760
Camera::lookAt_obj_target
Vec3f lookAt_obj_target
Definition
common_structs.h:798
Camera::lookAt_yaw
f32 lookAt_yaw
Definition
common_structs.h:807
Camera::curBoomPitch
f32 curBoomPitch
Definition
common_structs.h:803
Camera::curBoomYaw
f32 curBoomYaw
Definition
common_structs.h:804
Camera::curYaw
f32 curYaw
Definition
common_structs.h:800
Camera::needsInit
b16 needsInit
Definition
common_structs.h:752
Camera::lookAt_pitch
f32 lookAt_pitch
Definition
common_structs.h:808
Camera::params
union Camera::@17 params
Camera::curBoomLength
f32 curBoomLength
Definition
common_structs.h:802
Camera::lookAt_eye
Vec3f lookAt_eye
Definition
common_structs.h:796
gPlayerStatus
PlayerStatus gPlayerStatus
Definition
77480.c:39
src
cam_mode_unused_ahead.c
Generated by
1.10.0