Changes for adapted player model

The new player model is in minetest_game since 25 nov 2016,
3d_armor since 27 nov 2016

Dependency on 3d_armor was removed, as it is no longer needed

Note: the extra '.' characters in settingtypes.txt are needed to make
the help text display acceptably in the minetest settings tab. Without
them, minetest removes all leading whitespace, and makes the help text
look messy.
This commit is contained in:
Rogier-5 2016-12-07 13:03:12 +01:00 committed by Rui
parent 5814be7a98
commit 0ca8e5a3aa
4 changed files with 75 additions and 26 deletions

View File

@ -1,2 +1 @@
default
3d_armor?

View File

@ -1,4 +1,22 @@
local model = minetest.get_modpath("3d_armor") and "armor" or "normal"
-- Version of player model.
-- default_character_v1:
-- minetest_game before 25 nov 2016
-- 3d_armor before 27 nov 2016 (overrides model from minetest_game)
-- default_character_v2:
-- minetest_game after 25 nov 2016
-- 3d_armor after 27 nov 2016 (overrides model from minetest_game)
local valid_player_model_versions = {
default_character_v1 = true,
default_character_v2 = true,
}
local player_model_version = minetest.setting_get("player_model_version")
if not player_model_version or player_model_version == "" then
player_model_version = "default_character_v2"
elseif not valid_player_model_versions[player_model_version] then
error("Invalid value for player_model_version in minetest.conf: " .. player_model_version)
end
-- Localize to avoid table lookups
local vector_new = vector.new
@ -25,49 +43,52 @@ local LLEG = "Leg_Left"
local RLEG = "Leg_Right"
local bone_positions = {
normal = {
default_character_v1 = {
[BODY] = vector_new(0, -3.5, 0),
[HEAD] = vector_new(0, 6.5, 0),
[CAPE] = vector_new(0, 6.5, 1.5),
[LARM] = vector_new(-3.9, 6.5, 0),
[RARM] = vector_new(3.9, 6.5, 0),
[HEAD] = vector_new(0, 6.75, 0),
[CAPE] = vector_new(0, 6.75, 1.1),
[LARM] = vector_new(2, 6.75, 0),
[RARM] = vector_new(-2, 6.75, 0),
[LLEG] = vector_new(-1, 0, 0),
[RLEG] = vector_new(1, 0, 0)
},
armor = {
default_character_v2 = {
[BODY] = vector_new(0, -3.5, 0),
[HEAD] = vector_new(0, 6.75, 0),
[CAPE] = vector_new(0, 6.75, 1.5),
[LARM] = vector_new(2, 6.5, 0),
[RARM] = vector_new(-2, 6.5, 0),
[CAPE] = vector_new(0, 6.75, 1.2),
[LARM] = vector_new(3, 5.75, 0),
[RARM] = vector_new(-3, 5.75, 0),
[LLEG] = vector_new(1, 0, 0),
[RLEG] = vector_new(-1, 0, 0)
}
}
local bone_rotations = {
normal = {
default_character_v1 = {
[BODY] = vector_new(0, 0, 0),
[HEAD] = vector_new(0, 0, 0),
[CAPE] = vector_new(0, 0, 180),
[LARM] = vector_new(180, 0, 7.5),
[RARM] = vector_new(180, 0, -7.5),
[CAPE] = vector_new(180, 0, 0),
[LARM] = vector_new(180, 0, 9),
[RARM] = vector_new(180, 0, -9),
[LLEG] = vector_new(0, 0, 0),
[RLEG] = vector_new(0, 0, 0)
},
armor = {
default_character_v2 = {
[BODY] = vector_new(0, 0, 0),
[HEAD] = vector_new(0, 0, 0),
[CAPE] = vector_new(180, 0, 180),
[LARM] = vector_new(180, 0, 9),
[RARM] = vector_new(180, 0, -9),
[CAPE] = vector_new(0, 0, 0),
[LARM] = vector_new(0, 0, 0),
[RARM] = vector_new(0, 0, 0),
[LLEG] = vector_new(0, 0, 0),
[RLEG] = vector_new(0, 0, 0)
}
}
local bone_rotation = bone_rotations[model]
local bone_position = bone_positions[model]
local bone_rotation = bone_rotations[player_model_version]
local bone_position = bone_positions[player_model_version]
if not bone_rotation or not bone_position then
error("Internal error: invalid player_model_version: " .. player_model_version)
end
local bone_rotation_cache = {}
@ -109,7 +130,7 @@ local animations = {
[WALK] = function(player)
local swing = math_sin(step * 4 * animation_speed[player])
rotate(player, CAPE, swing * 30 + 35)
rotate(player, CAPE, swing * -30 - 35)
rotate(player, LARM, swing * -40)
rotate(player, RARM, swing * 40)
rotate(player, LLEG, swing * 40)
@ -123,9 +144,9 @@ local animations = {
local swing = math_sin(step * 4 * speed)
local hand_swing = math_sin(step * 8 * speed)
rotate(player, CAPE, swing * 5 + 10)
rotate(player, CAPE, swing * -5 - 10)
rotate(player, LARM)
rotate(player, RARM, hand_swing * 20 + 80 + pitch)
rotate(player, RARM, hand_swing * 20 + 80 + pitch, hand_swing * 5 - 3, 10)
rotate(player, LLEG)
rotate(player, RLEG)
end,
@ -137,9 +158,9 @@ local animations = {
local swing = math_sin(step * 4 * speed)
local hand_swing = math_sin(step * 8 * speed)
rotate(player, CAPE, swing * 30 + 35)
rotate(player, CAPE, swing * -30 - 35)
rotate(player, LARM, swing * -40)
rotate(player, RARM, hand_swing * 20 + 80 + pitch)
rotate(player, RARM, hand_swing * 20 + 80 + pitch, hand_swing * 5 - 3, 10)
rotate(player, LLEG, swing * 40)
rotate(player, RLEG, swing * -40)
end,

View File

@ -5,4 +5,19 @@ The head only turns up and down relative to the body, except it turns slightly t
Works in multiplayer, I tested it on a local server.
Configuration
-------------
This mod supports 2 versions of the player model:
- The old version: v1 (before nov. 2016)
- The new version: v2 (after nov. 2016)
(see also init.lua)
As there is no automatic way to determine which version is used, this must be manually configured in `init.lua`.
Symptoms of having configured the incorrect player model:
- In rest, arms are raised up, and are either detached from the body, or are too close to the body
- Cape (if visible) points upward
Created by Rui914, this document was written by sloantothebone.

14
settingtypes.txt Normal file
View File

@ -0,0 +1,14 @@
# Version of player model.
# Some fixes and improvements were made to the default player model (character.b3d)
# end of november 2016. These changes affect the way body parts are attached and
# positioned. For correct results, the version of the player model must be known.
#
# Player models known / supported by this mod:
# . -- default_character_v1; used in:
# . -- minetest_game before 25 nov 2016
# . -- 3d_armor before 27 nov 2016 (overrides model from minetest_game)
# . -- default_character_v2; used in:
# . -- minetest_game after 25 nov 2016
# . -- 3d_armor after 27 nov 2016 (overrides model from minetest_game)
player_model_version (Version of player model) enum default_character_v2 default_character_v1,default_character_v2