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

Go to the source code of this file.

Functions

void update_camera_no_interp (Camera *camera)
 

Function Documentation

◆ update_camera_no_interp()

void update_camera_no_interp ( Camera * camera)

Definition at line 16 of file cam_mode_no_interp.c.

16 {
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
79}
#define sqrtf
#define atan2
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
Vec3f targetPos
f32 curBoomLength
Vec3f lookAt_eye
BattleStatus gBattleStatus
Definition battle.c:11

Referenced by update_cameras().