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

Go to the source code of this file.

Macros

#define YSCALE   (1.0f / 5.0f)
 
#define LEN_SCALE   (100 / CamLengthScale)
 

Functions

void update_camera_unused_radial (Camera *camera)
 

Macro Definition Documentation

◆ YSCALE

#define YSCALE   (1.0f / 5.0f)

Definition at line 4 of file cam_mode_unused_radial.c.

Referenced by update_camera_unused_radial().

◆ LEN_SCALE

#define LEN_SCALE   (100 / CamLengthScale)

Definition at line 5 of file cam_mode_unused_radial.c.

Referenced by update_camera_unused_radial().

Function Documentation

◆ update_camera_unused_radial()

void update_camera_unused_radial ( Camera * camera)

Definition at line 16 of file cam_mode_unused_radial.c.

16 {
17 f32 yawAngle, sinYaw, cosYaw;
18 f32 pitchAngle, sinPitch, cosPitch;
19 f32 dx, dy, dz, dr;
20 f32 x1, z1, x2, z2;
21 f32 dist, angle;
22
23 if (camera->needsInit) {
24 camera->needsInit = FALSE;
25
26 x1 = camera->lookAt_obj_target.x;
27 z1 = camera->lookAt_obj_target.z;
28 x2 = camera->targetPos.x;
29 z2 = camera->targetPos.z;
30
31 camera->curBoomPitch = camera->params.radial.pitch;
32 camera->curBoomLength = camera->params.radial.dist * LEN_SCALE;
33 camera->targetOffsetY = camera->params.radial.offsetY * YSCALE * LEN_SCALE;
34
35 angle = atan2(x1, z1, x2, z2);
36 dist = dist2D(x1, z1, x2, z2);
37 if (dist >= camera->params.radial.minRadius * LEN_SCALE) {
38 camera->curBoomYaw = angle;
39 }
40 camera->targetBoomYaw = camera->curBoomYaw;
41
42 camera->lookAt_obj.x = camera->lookAt_obj_target.x;
43 camera->lookAt_obj.y = camera->lookAt_obj_target.y + camera->targetOffsetY;
44 camera->lookAt_obj.z = camera->lookAt_obj_target.z;
45
46 pitchAngle = DEG_TO_RAD(camera->curBoomPitch);
47 sinPitch = sin_rad(pitchAngle);
48 cosPitch = cos_rad(pitchAngle);
49
50 yawAngle = DEG_TO_RAD(angle);
51 sinYaw = sin_rad(yawAngle);
52 cosYaw = cos_rad(yawAngle);
53
54 dy = camera->curBoomLength * sinPitch;
55 dx = camera->curBoomLength * cosPitch * -sinYaw;
56 dz = camera->curBoomLength * cosPitch * cosYaw;
57
58 camera->lookAt_eye.x = camera->lookAt_obj.x + dx;
59 camera->lookAt_eye.y = camera->lookAt_obj.y + dy;
60 camera->lookAt_eye.z = camera->lookAt_obj.z + dz;
61 }
62
63 camera->curBoomPitch = camera->params.radial.pitch;
64 camera->curBoomLength = camera->params.radial.dist * LEN_SCALE;
65 camera->targetOffsetY = camera->params.radial.offsetY * YSCALE * LEN_SCALE;
66
67 dx = camera->lookAt_obj_target.x - camera->lookAt_obj.x;
68 dy = camera->lookAt_obj_target.y - camera->lookAt_obj.y + camera->targetOffsetY;
69 dz = camera->lookAt_obj_target.z - camera->lookAt_obj.z;
70
71 camera->lookAt_obj.x += dx * 0.5f;
72 camera->lookAt_obj.y += dy * YSCALE * 0.5f;
73 camera->lookAt_obj.z += dz * 0.5f;
74
75 x1 = camera->lookAt_obj_target.x;
76 z1 = camera->lookAt_obj_target.z;
77 x2 = camera->targetPos.x;
78 z2 = camera->targetPos.z;
79
80 angle = atan2(x1, z1, x2, z2);
81 dist = dist2D(x1, z1, x2, z2);
82 if (dist >= camera->params.radial.minRadius * LEN_SCALE) {
83 camera->curBoomYaw = angle;
84 }
85 camera->targetBoomYaw -= get_clamped_angle_diff(camera->curBoomYaw, camera->targetBoomYaw) / 10.0f;
86
87 pitchAngle = DEG_TO_RAD(camera->curBoomPitch);
88 sinPitch = sin_rad(pitchAngle);
89 cosPitch = cos_rad(pitchAngle);
90
91 yawAngle = DEG_TO_RAD((camera->targetBoomYaw));
92 sinYaw = sin_rad(yawAngle);
93 cosYaw = cos_rad(yawAngle);
94
95 dy = camera->curBoomLength * sinPitch;
96 dx = camera->curBoomLength * cosPitch * -sinYaw;
97 dz = camera->curBoomLength * cosPitch * cosYaw;
98
99 camera->lookAt_eye.x = camera->lookAt_obj.x + dx;
100 camera->lookAt_eye.y = camera->lookAt_obj.y + dy;
101 camera->lookAt_eye.z = camera->lookAt_obj.z + dz;
102
103 dx = camera->lookAt_obj.x - camera->lookAt_eye.x;
104 dy = camera->lookAt_obj.y - camera->lookAt_eye.y;
105 dz = camera->lookAt_obj.z - camera->lookAt_eye.z;
106 dr = sqrtf(SQ(dx) + SQ(dz));
107
108 camera->lookAt_yaw = -atan2(0.0f, 0.0f, dx, dz);
109 camera->lookAt_pitch = atan2(0.0f, 0.0f, dy, -dr);
110 camera->curYaw = atan2(camera->lookAt_eye.x, camera->lookAt_eye.z, camera->lookAt_obj.x, camera->lookAt_obj.z);
111}
#define LEN_SCALE
#define YSCALE
#define sqrtf
#define atan2
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
f32 sin_rad(f32 x)
Definition 43F0.c:713
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
#define DEG_TO_RAD(deg)
Definition macros.h:134
#define SQ(x)
Definition macros.h:166
Vec3f lookAt_obj
f32 targetOffsetY
Vec3f lookAt_obj_target
f32 curBoomPitch
f32 targetBoomYaw
f32 lookAt_pitch
union Camera::@17 params
Vec3f targetPos
f32 curBoomLength
Vec3f lookAt_eye

Referenced by update_cameras().