Paper Mario DX
Paper Mario (N64) modding
Loading...
Searching...
No Matches
cam_mode_no_interp.c
Go to the documentation of this file.
1
#include "common.h"
2
3
// implements CAM_UPDATE_NO_INTERP
4
// this camera uses a set of control parameters to calculate its lookAt_obj and lookAt_eye positions,
5
// which are only updated if skipRecalc = FALSE
6
// the ultimate target is given by lookAt_obj_target, with an offset given by targetPos (?!)
7
// in practice, this is used for CAM_BATTLE and CAM_TATTLE, with skipRecalc almost always set to FALSE
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
// offsetY -- offset of the base of the boom arm above the target point
14
// fovScale -- adjusts vertical fov, with 100 being normal (=25). scales as 1/x so larger values mean smaller vfov.
15
// skipRecalc -- do not calculate lookAt_obj and lookAt_eye from params
16
void
update_camera_no_interp
(
Camera
* camera) {
17
f32 yawAngle, sinYaw, cosYaw;
18
f32 pitchAngle, sinPitch, cosPitch;
19
f32 dx, dy, dz, dr;
20
21
if
(camera->
needsInit
|| camera->
needsReinit
) {
22
camera->
needsInit
= FALSE;
23
camera->
needsReinit
= FALSE;
24
camera->
params
.basic.skipRecalc = FALSE;
25
camera->
params
.basic.dist = 100;
26
camera->
params
.basic.pitch = 0;
27
camera->
params
.basic.yaw = 0;
28
camera->
params
.basic.offsetY = 0;
29
camera->
params
.basic.fovScale = 100;
30
31
camera->
targetPos
.
x
= 0.0f;
32
camera->
targetPos
.
y
= 0.0f;
33
camera->
targetPos
.
z
= 0.0f;
34
35
camera->
lookAt_obj
.
x
= camera->
lookAt_obj_target
.
x
;
36
camera->
lookAt_obj
.
y
= camera->
lookAt_obj_target
.
y
;
37
camera->
lookAt_obj
.
z
= camera->
lookAt_obj_target
.
z
;
38
}
39
40
if
(!camera->
params
.basic.skipRecalc) {
41
camera->
lookAt_obj
.
x
= camera->
lookAt_obj_target
.
x
+ camera->
targetPos
.
x
;
42
camera->
lookAt_obj
.
y
= camera->
lookAt_obj_target
.
y
+ camera->
targetPos
.
y
+ camera->
params
.basic.offsetY / 256.0;
43
camera->
lookAt_obj
.
z
= camera->
lookAt_obj_target
.
z
+ camera->
targetPos
.
z
;
44
45
camera->
curBoomLength
= camera->
params
.basic.dist;
46
camera->
curBoomPitch
= camera->
params
.basic.pitch;
47
camera->
curBoomYaw
= camera->
params
.basic.yaw;
48
camera->
vfov
= (10000 / camera->
params
.basic.fovScale) / 4;
49
50
pitchAngle =
DEG_TO_RAD
(camera->
curBoomPitch
);
51
sinPitch =
sin_rad
(pitchAngle);
52
cosPitch =
cos_rad
(pitchAngle);
53
54
yawAngle =
DEG_TO_RAD
(camera->
curBoomYaw
);
55
sinYaw =
sin_rad
(yawAngle);
56
cosYaw =
cos_rad
(yawAngle);
57
58
dy = camera->
curBoomLength
* sinPitch;
59
dx = camera->
curBoomLength
* cosPitch * -sinYaw;
60
dz = camera->
curBoomLength
* cosPitch * cosYaw;
61
62
camera->
lookAt_eye
.
x
= camera->
lookAt_obj
.
x
+ dx;
63
camera->
lookAt_eye
.
y
= camera->
lookAt_obj
.
y
+ dy;
64
camera->
lookAt_eye
.
z
= camera->
lookAt_obj
.
z
+ dz;
65
}
66
67
dx = camera->
lookAt_obj
.
x
- camera->
lookAt_eye
.
x
;
68
dy = camera->
lookAt_obj
.
y
- camera->
lookAt_eye
.
y
;
69
dz = camera->
lookAt_obj
.
z
- camera->
lookAt_eye
.
z
;
70
dr =
sqrtf
(
SQ
(dx) +
SQ
(dz));
71
72
camera->
lookAt_yaw
= -
atan2
(0.0f, 0.0f, dx, dz);
73
camera->
lookAt_pitch
=
atan2
(0.0f, 0.0f, dy, -dr);
74
camera->
curYaw
=
atan2
(camera->
lookAt_eye
.
x
, camera->
lookAt_eye
.
z
, camera->
lookAt_obj
.
x
, camera->
lookAt_obj
.
z
);
75
76
gBattleStatus
.
camLookatObjPos
.
x
= camera->
lookAt_obj
.
x
;
77
gBattleStatus
.
camLookatObjPos
.
y
= camera->
lookAt_obj
.
y
;
78
gBattleStatus
.
camLookatObjPos
.
z
= camera->
lookAt_obj
.
z
;
79
}
update_camera_no_interp
void update_camera_no_interp(Camera *camera)
Definition
cam_mode_no_interp.c:16
Vec3f::z
f32 z
Definition
common_structs.h:102
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
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
BattleStatus::camLookatObjPos
Vec3f camLookatObjPos
Definition
common_structs.h:928
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::targetPos
Vec3f targetPos
Definition
common_structs.h:799
Camera::curBoomLength
f32 curBoomLength
Definition
common_structs.h:802
Camera::lookAt_eye
Vec3f lookAt_eye
Definition
common_structs.h:796
gBattleStatus
BattleStatus gBattleStatus
Definition
battle.c:11
src
cam_mode_no_interp.c
Generated by
1.10.0