[Mod] Bone-Based Animation [playeranim]

User avatar
ParaklataChotou
Member
 
Posts: 209
Joined: Sat Jun 18, 2016 17:09
GitHub: paraklatachotou
IRC: CareBearWhoCares
In-game: AutistCortana

Re: [Mod] Bone-Based Animation [playeranim]

by ParaklataChotou » Tue Dec 06, 2016 11:37

fireglow wrote:Hi,
we've got a problem with playeranim, the arms are always stuck in the air.
3d_armor: version-0.4.4-49-g98786fd
playeranim: at commit 5814be7a984cde0c48a5c1ab447991f7950e0770
Screenshot:
Image

Anybody else experiencing this issue?

Wow, your player poly looks like a fire dancer boss (in Majora's Mask) XD. I don't know. Maybe you added wieldview??? Remove wieldview and try again.
Visit my server: freextress.ddnsking.com 30002 . mobs, npcs, interesting places, pvp.
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: [Mod] Bone-Based Animation [playeranim]

by stu » Tue Dec 06, 2016 19:47

fireglow wrote:Hi,
we've got a problem with playeranim, the arms are always stuck in the air.
3d_armor: version-0.4.4-49-g98786fd
playeranim: at commit 5814be7a984cde0c48a5c1ab447991f7950e0770


You will need to update to 3d_armor version-0.4.6 (current git master) and use the latest version of this mod.
 

User avatar
fireglow
Member
 
Posts: 93
Joined: Fri Mar 28, 2014 11:36
Location: Germany
IRC: fireglow
In-game: fireglow

Re: [Mod] Bone-Based Animation [playeranim]

by fireglow » Tue Dec 06, 2016 21:59

3d_armor is at the latest version.
Code: Select all
root@alpha ~ # ❯❯❯ cd /usr/jails/freeminer/srv/minetest/world/worldmods/3d_armor
root@alpha /u/j/f/s/m/w/w/3d_armor # ❯❯❯ sudo -u builder git pull
Already up-to-date.
root@alpha /u/j/f/s/m/w/w/3d_armor # ❯❯❯ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   shields/init.lua
        modified:   shields/textures/shields_inv_shield_admin.png
        modified:   shields/textures/shields_shield_admin.png
        modified:   shields/textures/shields_shield_admin_preview.png

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        shields/textures/null.png
        shields/textures/shields_inv_shield_fireglow.png
        shields/textures/shields_shield_fireglow.png
        shields/textures/shields_shield_fireglow_preview.png

no changes added to commit (use "git add" and/or "git commit -a")
root@alpha /u/j/f/s/m/w/w/3d_armor # ❯❯❯ git describe
version-0.4.4-49-g98786fd
root@alpha /u/j/f/s/m/w/w/3d_armor # ❯❯❯ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/stujones11/minetest-3d_armor.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

root@alpha /u/j/f/s/m/w/w/3d_armor # ❯❯❯ git log -1
commit 98786fd8f7c12524e33ecffe36b9b750996a19fa
Author: stujones11 <stujones111@gmail.com>
Date:   Sun Nov 27 17:18:08 2016 +0000

    Add killme command to replace old kill command



Latest commit on branch master:
https://github.com/stujones11/minetest- ... its/master
98786fd8f7c12524e33ecffe36b9b750996a19fa
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: [Mod] Bone-Based Animation [playeranim]

by stu » Wed Dec 07, 2016 18:17

fireglow wrote:3d_armor is at the latest version.
Code: Select all
root@alpha ~ # ❯❯❯ cd /usr/jails/freeminer/srv/minetest/world/worldmods/3d_armor

Okay, it looks like this mod has not been updated yet to support the new player model while 3d_armor has. There is an open pull request with the necessary updates, however, if you are using freeminer as your system path suggests, I have no idea if it uses the latest player model or not. If that is the case then you might be better off using 3d_armor version-0.4.5 for now, you can find it under releases.

Correction: This mod has been updated since I last checked and now supports the current development version minetest_game player model, soon(tm) to be part of minetest version 0.4.15
 

User avatar
Warrior_4_Christ
Member
 
Posts: 30
Joined: Thu Oct 27, 2016 18:16
Location: Palm Bay, FL U.S.
GitHub: Warrior-4-Christ
In-game: Warrior_4_Christ

Re: [Mod] Bone-Based Animation [playeranim]

by Warrior_4_Christ » Wed Jan 25, 2017 20:06

Hi. When I use this mod, any skin with a cape on it makes the cape stick up behind the player as if there is a constant upward wind. Is there a way to fix this?
For God so loved the world that He gave his only begotten Son, that whosoever believeth in Him should not perish, but have everlasting life. -- John 3:16 KJV
____
| [] []|
| _>/
 

Rui
Member
 
Posts: 261
Joined: Wed Oct 01, 2014 12:59
Location: Japan

Re: [Mod] Bone-Based Animation [playeranim]

by Rui » Fri Feb 03, 2017 10:20

Shadow_The_Hedgehog wrote:Hi. When I use this mod, any skin with a cape on it makes the cape stick up behind the player as if there is a constant upward wind. Is there a way to fix this?

Thanks for your reporting.
Could you add the screenshot, please?
I speak Engrish.
 

User avatar
texmex
Member
 
Posts: 1451
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Bone-Based Animation [playeranim]

by texmex » Wed Feb 15, 2017 01:19

Thank you for this great mod, Rui. It adds so much more personality to players behavior. I was wondering if you could have a look at the emote mod, with the aim to see if the two mods could be made to coexist?
 

Zachary
Member
 
Posts: 21
Joined: Wed Mar 08, 2017 09:42
Location: Below the bedrock layer
IRC: ayden
In-game: ayden

Re: [Mod] Bone-Based Animation [playeranim]

by Zachary » Sun Mar 12, 2017 03:09

I have one problem which is my head is moving but my hands are sticking up like someone told me to hands up so my hands turn like that.
"Your Skies Are Dark
And Days Are Gray
Because You Have No Love
To Light Your Way"
-
CRYSTAL R. KORDEL
 

User avatar
LordStephen77
Member
 
Posts: 33
Joined: Mon May 22, 2017 15:26

Re: [Mod] Bone-Based Animation [playeranim]

by LordStephen77 » Mon May 29, 2017 12:39

Interesting. When this mode is optimized it will be a nice addition.

I misunderstanded apologize. I did not see Rui's post, I do not understand why ??? Now I read it all without any problems :D
Last edited by LordStephen77 on Mon May 29, 2017 14:35, edited 2 times in total.
 

User avatar
texmex
Member
 
Posts: 1451
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Bone-Based Animation [playeranim]

by texmex » Mon May 29, 2017 13:10

LordStephen77 wrote:The user "Rui" or I should say "ex-user" has made a commitment to implement a mod that implements one of the most required features in Minetest. I'm sorry to hear that the user "Rui" has deleted her posts and is no longer present on this forum.

To say that it is "horribly slow, ugly and more" is not cute. Each developing project has bugs, optimization problems, and more. Minetest was born in 2010 and is still "almost" comparable to an alpha version today.

I'm sorry about Rui, he was good and he was busy in his job, without asking for anything in return.

At least he tried to improve Minetest by including a new feature.

Not following. Rui's posts are still visible, I see no mentions of "ugly" other than yours and the mod is already in the collectively maintained repo group minetest-mods.
 

Rui
Member
 
Posts: 261
Joined: Wed Oct 01, 2014 12:59
Location: Japan

Re: [Mod] Bone-Based Animation [playeranim]

by Rui » Mon May 29, 2017 14:43

I want to implement this feature in the engine, but I can't because I don't know about C++... (´・ω・`)

This is "horribly slow, ugly and more".
This should be implemented in the engine.

P.S.
The reason why I deleted some topics of mine is because I don't want to leave my poor English messages.
Although I'm still not good at English :D
I speak Engrish.
 

User avatar
LordStephen77
Member
 
Posts: 33
Joined: Mon May 22, 2017 15:26

Re: [Mod] Bone-Based Animation [playeranim]

by LordStephen77 » Mon May 29, 2017 14:46

Rui wrote:I want to implement this feature in the engine, but I can't because I don't know about C++... (´・ω・`)

This is "horribly slow, ugly and more".
This should be implemented in the engine.

P.S.
The reason why I deleted some topics of mine is because I don't want to leave my poor English messages.
Although I'm still not good at English :D


I see. However you did a good job, your fashion I like. Continue this, thank you for your answer :D
 

User avatar
ForgiveAndromedalol
Member
 
Posts: 225
Joined: Tue Apr 11, 2017 12:34
GitHub: ForgiveAndromedalol
IRC: Andromeda
In-game: Yam

Re: [Mod] Bone-Based Animation [playeranim]

by ForgiveAndromedalol » Sun Jun 18, 2017 19:44

Image
I've not upgraded 3d_armor - I know. But it's funny this glitch XD.
Attachments
screenshot_20170618_164226.png
(407.19 KiB) Not downloaded yet
My MODS: Water Colors - viewtopic.php?f=9&t=18241
BTW BLOCKS - viewtopic.php?f=9&t=17654
 

Rui
Member
 
Posts: 261
Joined: Wed Oct 01, 2014 12:59
Location: Japan

Re: [Mod] Bone-Based Animation [playeranim]

by Rui » Sat Jul 01, 2017 11:58

ForgiveAndromedalol wrote:[img]
I've not upgraded 3d_armor - I know. But it's funny this glitch XD.

Please try adding "player_model_version = default_character_v1" in minetest.conf.
I speak Engrish.
 

User avatar
maikerumine
Member
 
Posts: 1348
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Bone-Based Animation MT 0.5 [playeranim]

by maikerumine » Wed Sep 13, 2017 15:18

FIXED!!!
Image

Here is the updated source code if you are using minetest 0.5 and up:

Code: Select all
local model = minetest.get_modpath("3d_armor") and "armor" or "normal"

-- Localize functions to avoid table lookups (better performance)
local vector_new = vector.new
local vector_add = vector.add
local vector_equals = vector.equals
local math_sin = math.sin
local math_deg = math.deg
local table_copy = table.copy
local get_animation = default.player_get_animation--mt4
local get_animation = player_api.player_get_animation--mt5

-- Animation alias
local STAND = 1
local WALK = 2
local MINE = 3
local WALK_MINE = 4
local SIT = 5
local LAY = 6
local SNEAK = 7
local RESET_BODY = 8

-- Bone alias
local BODY = "Body"
local HEAD = "Head"
local CAPE = "Cape"
local LARM = "Arm_Left"
local RARM = "Arm_Right"
local LLEG = "Leg_Left"
local RLEG = "Leg_Right"

local bone_position = {
   normal = {
      [BODY] = vector_new(0, 6.5, 0),
      [HEAD] = vector_new(0, 6.5, 0),
      [CAPE] = vector_new(0, 6.5, 1.5),
      [LARM] = vector_new(-3, 5.5, 0),
      [RARM] = vector_new(3, 5.5, 0),
      [LLEG] = vector_new(-1, 0, 0),
      [RLEG] = vector_new(1, 0, 0)
   },
   armor = {
      [BODY] = vector_new(0, 6.5, 0),
      [HEAD] = vector_new(0, 6.75, 0),
      [CAPE] = vector_new(0, 6.75, 1.5),
      [LARM] = vector_new(3, 5.5, 0),
      [RARM] = vector_new(-3, 5.5, 0),
      [LLEG] = vector_new(1, 0, 0),
      [RLEG] = vector_new(-1, 0, 0)
   }
}

local bone_rotation = {
   normal = {
      [BODY] = vector_new(0, 0, 0),
      [HEAD] = vector_new(0, 0, 0),
      [CAPE] = vector_new(0, 0, 180),
      [LARM] = vector_new(0, 0, -4),
      [RARM] = vector_new(0, 0, 4),
      [LLEG] = vector_new(0, 0, -3),
      [RLEG] = vector_new(0, 0, 3)
   },
   armor = {
      [BODY] = vector_new(0, 0, 0),
      [HEAD] = vector_new(0, 0, 0),
      [CAPE] = vector_new(180, 0, 180),
      [LARM] = vector_new(0, 0, 4),
      [RARM] = vector_new(0, 0, -4),
      [LLEG] = vector_new(0, 0, 3),
      [RLEG] = vector_new(0, 0, -3)
   }
}

-- Bone rotate
local function rotate(player, bone, x, y, z)
   local rotation = vector_add(vector_new(x or 0, y or 0, z or 0), bone_rotation[model][bone])
   player:set_bone_position(bone, bone_position[model][bone], rotation)
end

local step = 0
local animation_speed = {}
local animations = {
   [STAND] = function(player)
      rotate(player, BODY)
      rotate(player, CAPE)
      rotate(player, LARM)
      rotate(player, RARM)
      rotate(player, LLEG)
      rotate(player, RLEG)
   end,
   [WALK] = function(player)
      local name = player:get_player_name()
      local swing = math_sin(step * 4 * animation_speed[name])
      rotate(player, CAPE, swing * 30 + 35)
      rotate(player, LARM, swing * -40)
      rotate(player, RARM, swing * 40)
      rotate(player, LLEG, swing * 40)
      rotate(player, RLEG, swing * -40)
   end,
   [MINE] = function(player)
      local name = player:get_player_name()
      local pitch = math_deg(player:get_look_pitch())
      local swing = math_sin(step * 4 * animation_speed[name])
      local hand_swing = math_sin(step * 8 * animation_speed[name])
      rotate(player, CAPE, swing * 5 + 10)
      rotate(player, LARM)
      rotate(player, RARM, hand_swing * 20 + 80 + pitch)
      rotate(player, LLEG)
      rotate(player, RLEG)
   end,
   [WALK_MINE] = function(player)
      local name = player:get_player_name()
      local pitch = math_deg(player:get_look_pitch())
      local swing = math_sin(step * 4 * animation_speed[name])
      local hand_swing = math_sin(step * 8 * animation_speed[name])
      rotate(player, CAPE, swing * 30 + 35)
      rotate(player, LARM, swing * -40)
      rotate(player, RARM, hand_swing * 20 + 80 + pitch)
      rotate(player, LLEG, swing * 40)
      rotate(player, RLEG, swing * -40)
   end,
   [SIT] = function(player)
      local body_pos = table_copy(bone_position[model][BODY])
      body_pos.y = body_pos.y - 6
      player:set_bone_position(BODY, body_pos, vector_new(0, 0, 0))
      rotate(player, LARM)
      rotate(player, RARM)
      rotate(player, LLEG, 90)
      rotate(player, RLEG, 90)
   end,
   [LAY] = function(player)
      player:set_bone_position(BODY, vector_new(0, -9, 0), vector_new(270, 0, 0))
      rotate(player, HEAD)
   end,
   [SNEAK] = function(player)
      rotate(player, BODY, 5)
   end,
   [RESET_BODY] = function(player)
      rotate(player, BODY)
   end
}

-- Set animation speed
local function set_speed(player, bool_sneak)
   local name = player:get_player_name()
   local n = bool_sneak and 0.75 or 2
   if n ~= animation_speed[name] then
      animation_speed[name] = n
   end
end

-- Set animation
local current_animation = {}
local function set_animation(player, anim)
   local name = player:get_player_name()
   if anim == LAY or anim == SNEAK or anim == RESET_BODY then
      if current_animation[name][1] ~= anim then
         current_animation[name][1] = anim
         animations[anim](player)
      end
   elseif anim == WALK or anim == MINE or anim == WALK_MINE
   or current_animation[name][2] ~= anim then
      current_animation[name][2] = anim
      animations[anim](player)
   end
end

-- Head rotate
local current_head = {}
local function head_rotate(player, controls)
   local pitch = math_deg(player:get_look_pitch())
   local look = vector_new(pitch, 0, 0)
   if controls.left ~= controls.right then
      look.y = controls.right and 10 or -10
   end

   local name = player:get_player_name()
   local old_pitch, old_look = current_head[name][1], current_head[name][2]
   if old_pitch ~= pitch or (not old_look or not vector_equals(old_look, look)) then
      current_head[name] = {pitch, look}
      rotate(player, HEAD, look.x, look.y, look.z)
   end
end

-- Sneak animation
local function set_sneak(player, bool_sneak)
   set_animation(player, bool_sneak and SNEAK or RESET_BODY)
end

minetest.register_on_joinplayer(function(player)
   local name = player:get_player_name()
   current_head[name] = {}
   current_animation[name] = {}
end)

minetest.register_on_leaveplayer(function(player)
   local name = player:get_player_name()
   animation_speed[name] = nil
   current_head[name] = nil
   current_animation[name] = nil
end)

minetest.register_globalstep(function(dtime)
   step = dtime + step
   if step >= 3600 then
      step = 0
   end

   for _, player in ipairs(minetest.get_connected_players()) do
      --local animation = get_animation(player).animation--mt4
      local animation = player_api.get_animation(player).animation--mt5

      if animation == "lay" then -- No head rotate
         set_animation(player, STAND) -- Reset
         set_animation(player, LAY)
      else
         local controls = player:get_player_control()
         local bool_sneak = controls.sneak

         if animation == "walk" then
            set_speed(player, bool_sneak)
            set_animation(player, WALK)
            set_sneak(player, bool_sneak)
         elseif animation == "mine" then
            set_speed(player, bool_sneak)
            set_animation(player, MINE)
            set_sneak(player, bool_sneak)
         elseif animation == "walk_mine" then
            set_speed(player, bool_sneak)
            set_animation(player, WALK_MINE)
            set_sneak(player, bool_sneak)
         elseif animation == "sit" then
            set_animation(player, SIT)
         else
            set_animation(player, STAND)
            set_sneak(player, bool_sneak)
         end

         head_rotate(player, controls)
      end
   end
end)


--[[
# playeranim
Makes the head, and the right arm when you’re mining, face the way you’re facing, similar to Minecraft. Compatible with 3d_armor. Forked from the animplus mod, which was an ugly hack.

The head only turns up and down relative to the body, except it turns slightly to the right/left when you strafe right/left. When you turn the body turns with the head.

Works in multiplayer, I tested it on a local server.

Created by Rui914, this document was written by sloantothebone.
Updated to Minetest engint 0.5++  by maikerumine


            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.
]]


I tweaked the stance a little bit as well.
Attachments
screenshot_20170913_111643.png
(379.25 KiB) Not downloaded yet
 

User avatar
Stix
Member
 
Posts: 1368
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [Mod] Bone-Based Animation MT 0.5 [playeranim]

by Stix » Wed Sep 13, 2017 16:01

maikerumine wrote:FIXED!!!
Image

Here is the updated source code if you are using minetest 0.5 and up:

Code: Select all
local model = minetest.get_modpath("3d_armor") and "armor" or "normal"

-- Localize functions to avoid table lookups (better performance)
local vector_new = vector.new
local vector_add = vector.add
local vector_equals = vector.equals
local math_sin = math.sin
local math_deg = math.deg
local table_copy = table.copy
local get_animation = default.player_get_animation--mt4
local get_animation = player_api.player_get_animation--mt5

-- Animation alias
local STAND = 1
local WALK = 2
local MINE = 3
local WALK_MINE = 4
local SIT = 5
local LAY = 6
local SNEAK = 7
local RESET_BODY = 8

-- Bone alias
local BODY = "Body"
local HEAD = "Head"
local CAPE = "Cape"
local LARM = "Arm_Left"
local RARM = "Arm_Right"
local LLEG = "Leg_Left"
local RLEG = "Leg_Right"

local bone_position = {
   normal = {
      [BODY] = vector_new(0, 6.5, 0),
      [HEAD] = vector_new(0, 6.5, 0),
      [CAPE] = vector_new(0, 6.5, 1.5),
      [LARM] = vector_new(-3, 5.5, 0),
      [RARM] = vector_new(3, 5.5, 0),
      [LLEG] = vector_new(-1, 0, 0),
      [RLEG] = vector_new(1, 0, 0)
   },
   armor = {
      [BODY] = vector_new(0, 6.5, 0),
      [HEAD] = vector_new(0, 6.75, 0),
      [CAPE] = vector_new(0, 6.75, 1.5),
      [LARM] = vector_new(3, 5.5, 0),
      [RARM] = vector_new(-3, 5.5, 0),
      [LLEG] = vector_new(1, 0, 0),
      [RLEG] = vector_new(-1, 0, 0)
   }
}

local bone_rotation = {
   normal = {
      [BODY] = vector_new(0, 0, 0),
      [HEAD] = vector_new(0, 0, 0),
      [CAPE] = vector_new(0, 0, 180),
      [LARM] = vector_new(0, 0, -4),
      [RARM] = vector_new(0, 0, 4),
      [LLEG] = vector_new(0, 0, -3),
      [RLEG] = vector_new(0, 0, 3)
   },
   armor = {
      [BODY] = vector_new(0, 0, 0),
      [HEAD] = vector_new(0, 0, 0),
      [CAPE] = vector_new(180, 0, 180),
      [LARM] = vector_new(0, 0, 4),
      [RARM] = vector_new(0, 0, -4),
      [LLEG] = vector_new(0, 0, 3),
      [RLEG] = vector_new(0, 0, -3)
   }
}

-- Bone rotate
local function rotate(player, bone, x, y, z)
   local rotation = vector_add(vector_new(x or 0, y or 0, z or 0), bone_rotation[model][bone])
   player:set_bone_position(bone, bone_position[model][bone], rotation)
end

local step = 0
local animation_speed = {}
local animations = {
   [STAND] = function(player)
      rotate(player, BODY)
      rotate(player, CAPE)
      rotate(player, LARM)
      rotate(player, RARM)
      rotate(player, LLEG)
      rotate(player, RLEG)
   end,
   [WALK] = function(player)
      local name = player:get_player_name()
      local swing = math_sin(step * 4 * animation_speed[name])
      rotate(player, CAPE, swing * 30 + 35)
      rotate(player, LARM, swing * -40)
      rotate(player, RARM, swing * 40)
      rotate(player, LLEG, swing * 40)
      rotate(player, RLEG, swing * -40)
   end,
   [MINE] = function(player)
      local name = player:get_player_name()
      local pitch = math_deg(player:get_look_pitch())
      local swing = math_sin(step * 4 * animation_speed[name])
      local hand_swing = math_sin(step * 8 * animation_speed[name])
      rotate(player, CAPE, swing * 5 + 10)
      rotate(player, LARM)
      rotate(player, RARM, hand_swing * 20 + 80 + pitch)
      rotate(player, LLEG)
      rotate(player, RLEG)
   end,
   [WALK_MINE] = function(player)
      local name = player:get_player_name()
      local pitch = math_deg(player:get_look_pitch())
      local swing = math_sin(step * 4 * animation_speed[name])
      local hand_swing = math_sin(step * 8 * animation_speed[name])
      rotate(player, CAPE, swing * 30 + 35)
      rotate(player, LARM, swing * -40)
      rotate(player, RARM, hand_swing * 20 + 80 + pitch)
      rotate(player, LLEG, swing * 40)
      rotate(player, RLEG, swing * -40)
   end,
   [SIT] = function(player)
      local body_pos = table_copy(bone_position[model][BODY])
      body_pos.y = body_pos.y - 6
      player:set_bone_position(BODY, body_pos, vector_new(0, 0, 0))
      rotate(player, LARM)
      rotate(player, RARM)
      rotate(player, LLEG, 90)
      rotate(player, RLEG, 90)
   end,
   [LAY] = function(player)
      player:set_bone_position(BODY, vector_new(0, -9, 0), vector_new(270, 0, 0))
      rotate(player, HEAD)
   end,
   [SNEAK] = function(player)
      rotate(player, BODY, 5)
   end,
   [RESET_BODY] = function(player)
      rotate(player, BODY)
   end
}

-- Set animation speed
local function set_speed(player, bool_sneak)
   local name = player:get_player_name()
   local n = bool_sneak and 0.75 or 2
   if n ~= animation_speed[name] then
      animation_speed[name] = n
   end
end

-- Set animation
local current_animation = {}
local function set_animation(player, anim)
   local name = player:get_player_name()
   if anim == LAY or anim == SNEAK or anim == RESET_BODY then
      if current_animation[name][1] ~= anim then
         current_animation[name][1] = anim
         animations[anim](player)
      end
   elseif anim == WALK or anim == MINE or anim == WALK_MINE
   or current_animation[name][2] ~= anim then
      current_animation[name][2] = anim
      animations[anim](player)
   end
end

-- Head rotate
local current_head = {}
local function head_rotate(player, controls)
   local pitch = math_deg(player:get_look_pitch())
   local look = vector_new(pitch, 0, 0)
   if controls.left ~= controls.right then
      look.y = controls.right and 10 or -10
   end

   local name = player:get_player_name()
   local old_pitch, old_look = current_head[name][1], current_head[name][2]
   if old_pitch ~= pitch or (not old_look or not vector_equals(old_look, look)) then
      current_head[name] = {pitch, look}
      rotate(player, HEAD, look.x, look.y, look.z)
   end
end

-- Sneak animation
local function set_sneak(player, bool_sneak)
   set_animation(player, bool_sneak and SNEAK or RESET_BODY)
end

minetest.register_on_joinplayer(function(player)
   local name = player:get_player_name()
   current_head[name] = {}
   current_animation[name] = {}
end)

minetest.register_on_leaveplayer(function(player)
   local name = player:get_player_name()
   animation_speed[name] = nil
   current_head[name] = nil
   current_animation[name] = nil
end)

minetest.register_globalstep(function(dtime)
   step = dtime + step
   if step >= 3600 then
      step = 0
   end

   for _, player in ipairs(minetest.get_connected_players()) do
      --local animation = get_animation(player).animation--mt4
      local animation = player_api.get_animation(player).animation--mt5

      if animation == "lay" then -- No head rotate
         set_animation(player, STAND) -- Reset
         set_animation(player, LAY)
      else
         local controls = player:get_player_control()
         local bool_sneak = controls.sneak

         if animation == "walk" then
            set_speed(player, bool_sneak)
            set_animation(player, WALK)
            set_sneak(player, bool_sneak)
         elseif animation == "mine" then
            set_speed(player, bool_sneak)
            set_animation(player, MINE)
            set_sneak(player, bool_sneak)
         elseif animation == "walk_mine" then
            set_speed(player, bool_sneak)
            set_animation(player, WALK_MINE)
            set_sneak(player, bool_sneak)
         elseif animation == "sit" then
            set_animation(player, SIT)
         else
            set_animation(player, STAND)
            set_sneak(player, bool_sneak)
         end

         head_rotate(player, controls)
      end
   end
end)


--[[
# playeranim
Makes the head, and the right arm when you’re mining, face the way you’re facing, similar to Minecraft. Compatible with 3d_armor. Forked from the animplus mod, which was an ugly hack.

The head only turns up and down relative to the body, except it turns slightly to the right/left when you strafe right/left. When you turn the body turns with the head.

Works in multiplayer, I tested it on a local server.

Created by Rui914, this document was written by sloantothebone.
Updated to Minetest engint 0.5++  by maikerumine


            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.
]]


I tweaked the stance a little bit as well.

Thank-you! I will try this as soon as i update my MT version to 0.5-dev
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
Stix
Member
 
Posts: 1368
Joined: Fri Aug 04, 2017 14:19
Location: USA
IRC: nil
In-game: Stix [+alts]

Re: [Mod] Bone-Based Animation [playeranim]

by Stix » Wed Sep 13, 2017 16:10

maike i hopped on your server and realized that the head doesnt spin, thats because you modified the github version, but the more updated one in the zip.
Hey, what can i say? I'm the bad guy.
Next release of your favorite game? "Bugfixes" --Wuzzy
[OLD]The new Minetest-offtopic can be found here: https://minetestoftopic.createaforum.com/index.php
 

User avatar
maikerumine
Member
 
Posts: 1348
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Bone-Based Animation [playeranim]

by maikerumine » Wed Sep 13, 2017 17:36

Stix wrote:maike i hopped on your server and realized that the head doesnt spin, thats because you modified the github version, but the more updated one in the zip.

My server isnt updated yet. :)
 

User avatar
maikerumine
Member
 
Posts: 1348
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Bone-Based Animation [playeranim]

by maikerumine » Wed Sep 13, 2017 17:39

Stix wrote:maike i hopped on your server and realized that the head doesnt spin, thats because you modified the github version, but the more updated one in the zip.

EDIT, the zip doesnt work for mt5 yet
 

User avatar
sparky
Member
 
Posts: 132
Joined: Sun Oct 05, 2014 00:54
Location: USA
GitHub: Elkien3
IRC: ircSparky
In-game: sparky

Re: [Mod] Bone-Based Animation [playeranim]

by sparky » Tue Sep 26, 2017 19:20

Have you looked at making this a Client-side mod, Rui?
 

User avatar
kingoscargames
Member
 
Posts: 216
Joined: Fri Jul 28, 2017 12:06
Location: Netherlands
GitHub: kingoscargames
In-game: kingoscargames

Re: [Mod] Bone-Based Animation [playeranim]

by kingoscargames » Tue Sep 26, 2017 21:58

sparky wrote:Have you looked at making this a Client-side mod, Rui?

I don't think thats possible.
 

Rui
Member
 
Posts: 261
Joined: Wed Oct 01, 2014 12:59
Location: Japan

Re: [Mod] Bone-Based Animation [playeranim]

by Rui » Wed Sep 27, 2017 16:56

sparky wrote:Have you looked at making this a Client-side mod, Rui?

It's not possible.
"set_bone_position" isn't implemented in client-side API.
I speak Engrish.
 

User avatar
sparky
Member
 
Posts: 132
Joined: Sun Oct 05, 2014 00:54
Location: USA
GitHub: Elkien3
IRC: ircSparky
In-game: sparky
 

User avatar
jordan4ibanez
Member
 
Posts: 1895
Joined: Tue Sep 27, 2011 18:44
Location: Rhode Island, USA
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

Re: [Mod] Bone-Based Animation [playeranim]

by jordan4ibanez » Sun Nov 26, 2017 10:54

I hate to revive a dead thread, but this doesn't work correctly in latest, the player is visually halfway into the ground. :(
I've been gone for a long time
 

User avatar
azekill_DIABLO
Member
 
Posts: 7487
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO
 

PreviousNext

Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 4 guests