aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-09-18 17:02:30 +0200
committerKahrl <kahrl@gmx.net>2011-09-18 17:02:30 +0200
commit4ed837bcfa2d9601c6b5c3d2e8d37ad9f5a6e2a6 (patch)
tree54177b1fc84fb36aa2e670ce1c6eee73d16a36cc
parent54f3796f9105cb220c95aa6c2e80516cdd4e4a00 (diff)
downloadminetest-4ed837bcfa2d9601c6b5c3d2e8d37ad9f5a6e2a6.tar.gz
minetest-4ed837bcfa2d9601c6b5c3d2e8d37ad9f5a6e2a6.tar.bz2
minetest-4ed837bcfa2d9601c6b5c3d2e8d37ad9f5a6e2a6.zip
trying some view bobbing changes
-rw-r--r--src/camera.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index a9497152b..43009bd7c 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -133,16 +133,31 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
f32 bobfrac = (f32) bobframe / (BOBFRAMES/2);
f32 bobdir = (m_view_bobbing_anim < (BOBFRAMES/2)) ? 1.0 : -1.0;
+ #if 1
f32 bobknob = 1.2;
f32 bobtmp = sin(pow(bobfrac, bobknob) * PI);
v3f bobvec = v3f(
- 0.01 * bobdir * sin(bobfrac * PI),
- 0.005 * bobtmp * bobtmp,
+ bobdir * sin(bobfrac * PI),
+ 0.8 * bobtmp * bobtmp,
0.);
- rel_cam_pos += bobvec * 3.;
- rel_cam_target += bobvec * 4.5;
+ rel_cam_pos += 0.03 * bobvec;
+ 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