trying some view bobbing changes
authorKahrl <kahrl@gmx.net>
Sun, 18 Sep 2011 15:02:30 +0000 (17:02 +0200)
committerKahrl <kahrl@gmx.net>
Sun, 18 Sep 2011 15:02:30 +0000 (17:02 +0200)
src/camera.cpp

index a9497152b44f29d33c1303d7eacbdad116f417a2..43009bd7cc4995a9b4f3189cc53a5b74c0873078 100644 (file)
@@ -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