Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
cam_mode_unused_ahead.c File Reference

Go to the source code of this file.

Functions

void update_camera_unused_ahead (Camera *camera)
 

Function Documentation

◆ update_camera_unused_ahead()

void update_camera_unused_ahead ( Camera * camera)

Definition at line 14 of file cam_mode_unused_ahead.c.

14 {
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
34 camera->lookAt_obj_target.y = gPlayerStatus.pos.y + 60.0f;
35 }
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}
#define sqrtf
#define atan2
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PS_FLAG_JUMPING
Definition enums.h:3035
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 sin_rad(f32 x)
Definition 43F0.c:713
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define SQ(x)
Definition macros.h:166
Vec3f lookAt_obj
b16 needsReinit
Vec3f lookAt_obj_target
f32 curBoomPitch
f32 lookAt_pitch
union Camera::@17 params
f32 curBoomLength
Vec3f lookAt_eye
PlayerStatus gPlayerStatus
Definition 77480.c:39