+
+ // Position the wielded item
+ //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;
+ wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * PI);
+ wield_position.Y += 15 * sin(digfrac * 2 * PI);
+ wield_position.Z += 5 * digfrac;
+
+ // Euler angles are PURE EVIL, so why not use quaternions?
+ core::quaternion quat_begin(wield_rotation * core::DEGTORAD);
+ core::quaternion quat_end(v3f(90, -10, -130) * core::DEGTORAD);
+ core::quaternion quat_slerp;
+ quat_slerp.slerp(quat_begin, quat_end, sin(digfrac * PI));
+ quat_slerp.toEuler(wield_rotation);
+ wield_rotation *= core::RADTODEG;
+ }
+ else {
+ f32 bobfrac = my_modf(m_view_bobbing_anim);
+ wield_position.X -= sin(bobfrac*PI*2.0) * 3.0;
+ wield_position.Y += sin(my_modf(bobfrac*2.0)*PI) * 3.0;
+ }
+ m_wieldnode->setPosition(wield_position);
+ m_wieldnode->setRotation(wield_rotation);
+ m_wieldlight = player->light;