trying some view bobbing changes

master
Kahrl 2011-09-18 17:02:30 +02:00
parent 54f3796f91
commit 4ed837bcfa
1 changed files with 19 additions and 4 deletions

View 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