Page 1 of 1

Better digging animation

PostPosted: Fri Sep 21, 2012 21:36
by jordan4ibanez
In the source code, in camera.cpp at line 336 replace this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if (m_digging_button != -1)
{
    f32 digfrac = m_digging_anim;
    wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * M_PI);
    wield_position.Y += 15 * sin(digfrac * 2 * M_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 * M_PI));
    quat_slerp.toEuler(wield_rotation);
    wield_rotation *= core::RADTODEG;
}



WITH THIS!

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if (m_digging_button != -1)
{
    f32 digfrac = m_digging_anim;
    wield_position.X -= 50 * sin(pow(digfrac, 0.8f) * M_PI);
    wield_position.Y += 24 * sin(digfrac * 1.8 * M_PI);
    wield_position.Z += 25 * 0.5;

    // Euler angles are PURE EVIL, so why not use quaternions?
    core::quaternion quat_begin(wield_rotation * core::DEGTORAD);
    core::quaternion quat_end(v3f(80, 30, 100) * core::DEGTORAD);
    core::quaternion quat_slerp;
    quat_slerp.slerp(quat_begin, quat_end, sin(digfrac * M_PI));
    quat_slerp.toEuler(wield_rotation);
    wield_rotation *= core::RADTODEG;
}

PostPosted: Sun Sep 23, 2012 12:36
by rubenwardy
what is better?

PostPosted: Sun Sep 23, 2012 17:41
by irksomeduck
I don't get it

PostPosted: Sun Sep 23, 2012 18:13
by jordan4ibanez
rubenwardy wrote:what is better?

your hand doesn't twist and it actually looks like you are digging and not just flailing your hands in the air

PostPosted: Mon Sep 24, 2012 15:39
by wokste
Please add this in an issue on github. In that case there is a bigger chance that this gets upstream.

PostPosted: Mon Sep 24, 2012 16:30
by rubenwardy
wokste wrote:Please add this in an issue on github. In that case there is a bigger chance that this gets upstream.


Pull request would be better...

PostPosted: Fri Sep 28, 2012 16:42
by jordan4ibanez
here i've made a video demonstrating it http://youtu.be/jtZWvzkflWU and i've updated the line (336 not 366)

PostPosted: Sat Sep 29, 2012 15:50
by rubenwardy
Yeah, it is good

PostPosted: Sat Sep 29, 2012 19:01
by Mito551
good :)
it looks really nice!

PostPosted: Mon Oct 01, 2012 04:43
by Josh
Where can you find the source code?

PostPosted: Mon Oct 01, 2012 07:07
by PilzAdam
Josh wrote:Where can you find the source code?

In minetest/src/

PostPosted: Wed Oct 03, 2012 23:55
by lord_james
Cool!!! But... Could it be possible add custom object's movement for mods? For Example, It isn't the same use a bow that eat a cookie

PostPosted: Mon Oct 08, 2012 05:53
by CTMN
No, but it's similar. The standart digging animation could be used for almost every action.