mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-17 14:55:13 -05:00
trying some view bobbing changes
This commit is contained in:
parent
54f3796f91
commit
4ed837bcfa
@ -133,16 +133,31 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
|
|||||||
f32 bobfrac = (f32) bobframe / (BOBFRAMES/2);
|
f32 bobfrac = (f32) bobframe / (BOBFRAMES/2);
|
||||||
f32 bobdir = (m_view_bobbing_anim < (BOBFRAMES/2)) ? 1.0 : -1.0;
|
f32 bobdir = (m_view_bobbing_anim < (BOBFRAMES/2)) ? 1.0 : -1.0;
|
||||||
|
|
||||||
|
#if 1
|
||||||
f32 bobknob = 1.2;
|
f32 bobknob = 1.2;
|
||||||
f32 bobtmp = sin(pow(bobfrac, bobknob) * PI);
|
f32 bobtmp = sin(pow(bobfrac, bobknob) * PI);
|
||||||
|
|
||||||
v3f bobvec = v3f(
|
v3f bobvec = v3f(
|
||||||
0.01 * bobdir * sin(bobfrac * PI),
|
bobdir * sin(bobfrac * PI),
|
||||||
0.005 * bobtmp * bobtmp,
|
0.8 * bobtmp * bobtmp,
|
||||||
0.);
|
0.);
|
||||||
|
|
||||||
rel_cam_pos += bobvec * 3.;
|
rel_cam_pos += 0.03 * bobvec;
|
||||||
rel_cam_target += bobvec * 4.5;
|
rel_cam_target += 0.045 * bobvec;
|
||||||
|
rel_cam_up.rotateXYBy(0.03 * bobdir * bobtmp * PI);
|
||||||
|
#else
|
||||||
|
f32 angle_deg = 1 * bobdir * sin(bobfrac * PI);
|
||||||
|
f32 angle_rad = angle_deg * PI / 180;
|
||||||
|
f32 r = 0.05;
|
||||||
|
v3f off = v3f(
|
||||||
|
r * sin(angle_rad),
|
||||||
|
r * (cos(angle_rad) - 1),
|
||||||
|
0);
|
||||||
|
rel_cam_pos += off;
|
||||||
|
//rel_cam_target += off;
|
||||||
|
rel_cam_up.rotateXYBy(angle_deg);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute absolute camera position and target
|
// Compute absolute camera position and target
|
||||||
|
Loading…
Reference in New Issue
Block a user