summaryrefslogtreecommitdiff
path: root/src/camera.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-09 23:53:25 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-10 11:28:14 +0200
commit989aba1966373885d4cac306daea25e102f8d68d (patch)
tree7e735cba9a7c38eee1b3ccb4474cd5963e74a378 /src/camera.cpp
parent6b7d6c27ee53836c5f5a702056617770b59bf595 (diff)
downloadminetest-989aba1966373885d4cac306daea25e102f8d68d.tar.gz
minetest-989aba1966373885d4cac306daea25e102f8d68d.tar.bz2
minetest-989aba1966373885d4cac306daea25e102f8d68d.zip
Fix and tune things, add tool "recharge" animation, add dummyball
Diffstat (limited to 'src/camera.cpp')
-rw-r--r--src/camera.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/camera.cpp b/src/camera.cpp
index b36daf1d7..83b7ccd34 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <cmath>
#include "settings.h"
#include "itemdef.h" // For wield visualization
+#include "noise.h" // easeCurve
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control):
m_smgr(smgr),
@@ -182,7 +183,8 @@ void Camera::step(f32 dtime)
}
}
-void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
+void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
+ f32 tool_reload_ratio)
{
// Set player node transformation
m_playernode->setPosition(player->getPosition());
@@ -267,8 +269,25 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize)
m_cameranode->setFOV(m_fov_y);
// Position the wielded item
- v3f wield_position = v3f(45, -35, 65);
+ //v3f wield_position = v3f(45, -35, 65);
+ v3f wield_position = v3f(55, -35, 65);
+ //v3f wield_rotation = v3f(-100, 120, -100);
v3f wield_rotation = v3f(-100, 120, -100);
+ if(m_digging_anim < 0.05 || m_digging_anim > 0.5){
+ f32 frac = 1.0;
+ if(m_digging_anim > 0.5)
+ frac = 2.0 * (m_digging_anim - 0.5);
+ // This value starts from 1 and settles to 0
+ f32 ratiothing = pow((1.0 - tool_reload_ratio), 0.5);
+ //f32 ratiothing2 = pow(ratiothing, 0.5);
+ f32 ratiothing2 = (easeCurve(ratiothing*0.5))*2.0;
+ wield_position.Y -= frac * 25.0 * pow(ratiothing2, 1.7);
+ //wield_position.Z += frac * 5.0 * ratiothing2;
+ wield_position.X -= frac * 35.0 * pow(ratiothing2, 1.1);
+ wield_rotation.Y += frac * 70.0 * pow(ratiothing2, 1.4);
+ //wield_rotation.X -= frac * 15.0 * pow(ratiothing2, 1.4);
+ //wield_rotation.Z += frac * 15.0 * pow(ratiothing2, 1.0);
+ }
if (m_digging_button != -1)
{
f32 digfrac = m_digging_anim;