diff options
author | Kahrl <kahrl@gmx.net> | 2011-09-18 02:24:43 +0200 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2011-09-18 02:24:43 +0200 |
commit | 54f3796f9105cb220c95aa6c2e80516cdd4e4a00 (patch) | |
tree | d50d8d63ab5e294edce9afe1c589627386b149f6 /src | |
parent | ae66d611f2020e0fddb45f40af2d42c13e7ba585 (diff) | |
download | minetest-54f3796f9105cb220c95aa6c2e80516cdd4e4a00.tar.gz minetest-54f3796f9105cb220c95aa6c2e80516cdd4e4a00.tar.bz2 minetest-54f3796f9105cb220c95aa6c2e80516cdd4e4a00.zip |
Oops, up vector is needed.
Diffstat (limited to 'src')
-rw-r--r-- | src/camera.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/camera.cpp b/src/camera.cpp index 0c6fe1df5..a9497152b 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -120,10 +120,12 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize) v3f eye_offset = player->getEyePosition() - player->getPosition(); m_headnode->setPosition(eye_offset); m_headnode->setRotation(v3f(player->getPitch(), 0, 0)); + m_headnode->updateAbsolutePosition(); // Compute relative camera position and target v3f rel_cam_pos = v3f(0,0,0); v3f rel_cam_target = v3f(0,0,1); + v3f rel_cam_up = v3f(0,1,0); s32 bobframe = m_view_bobbing_anim & (BOBFRAMES/2-1); if (bobframe != 0) @@ -140,7 +142,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize) 0.); rel_cam_pos += bobvec * 3.; - rel_cam_target += bobvec * 1.5; + rel_cam_target += bobvec * 4.5; } // Compute absolute camera position and target @@ -148,8 +150,13 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize) m_headnode->getAbsoluteTransformation().transformVect(m_camera_direction, rel_cam_target); m_camera_direction -= m_camera_position; + v3f abs_cam_up; + m_headnode->getAbsoluteTransformation().transformVect(abs_cam_up, rel_cam_pos + rel_cam_up); + abs_cam_up -= m_camera_position; + // Set camera node transformation m_cameranode->setPosition(m_camera_position); + m_cameranode->setUpVector(abs_cam_up); m_cameranode->setTarget(m_camera_position + m_camera_direction); // FOV and and aspect ratio |