Adjust bones, animations slightly from b3d data.

Initialize bones on spawn.

Note: to obatin bone values, try in Blender

"%.3f, %.3f, %.3f" % tuple((bpy.context.object.pose.bones["head.control"].head - bpy.context.object.pose.bones["head.control"].tail) * Vector((1,-1,1)))

or

"{0:.3f}, {1:.3f}, {2:.3f}".format(*(bpy.context.object.pose.bones["head.control"].head - bpy.context.object.pose.bones["head.control"].tail) @ bpy.context.object.pose.bones["head.control"].matrix * Vector((1,-1,1)))
This commit is contained in:
kno10 2024-11-19 21:48:21 +01:00
parent b84c06b9c2
commit 55f48bd5ce
12 changed files with 26 additions and 14 deletions

@ -399,7 +399,7 @@ function mob_class:check_head_swivel(dtime)
end
-- 0.02 is about 1.14 degrees tolerance, to update less often
if math.abs(oldr.x-newr.x) + math.abs(oldr.y-newr.y) + math.abs(oldr.z-newr.z) < 0.02 and vector.equals(oldp, vector.zero()) then return end
if math.abs(oldr.x-newr.x) + math.abs(oldr.y-newr.y) + math.abs(oldr.z-newr.z) < 0.02 then return end
if self.object.get_bone_override then -- minetest >= 5.9
self.object:set_bone_override(self.head_swivel, {

@ -701,7 +701,19 @@ function mcl_mobs.spawn(pos,id)
local def = minetest.registered_entities[id] or minetest.registered_entities["mobs_mc:"..id] or minetest.registered_entities["extra_mobs:"..id]
if not def or not def.is_mob or (def.can_spawn and not def.can_spawn(pos)) then return false end
if not has_room(def, pos) then return false end
return minetest.add_entity(pos, def.name)
local obj = minetest.add_entity(pos, def.name)
-- initialize head bone
if def.head_swivel and def.head_bone_position then
if obj and obj.get_bone_override then -- minetest >= 5.9
obj:set_bone_override(def.head_swivel, {
position = { vec = def.head_bone_position, absolute = true },
rotation = { vec = vector.zero(), absolute = true }
})
else -- minetest < 5.9
self.object:set_bone_position(def.head_swivel, def.head_bone_position, vector.zero)
end
end
return obj
end
local function spawn_group(p,mob,spawn_on,amount_to_spawn)

@ -32,7 +32,7 @@ mcl_mobs.register_mob("mobs_mc:blaze", {
mesh = "mobs_mc_blaze.b3d",
head_swivel = "head.control",
head_eye_height = 1.4,
head_bone_position = vector.new( 0, 4, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 3.9, 0 ), -- for minetest <= 5.8
curiosity = 10,
head_pitch_multiplier=-1,
textures = {

@ -22,7 +22,7 @@ mcl_mobs.register_mob("mobs_mc:chicken", {
floats = 1,
head_swivel = "head.control",
head_eye_height = 0.5,
head_bone_position = vector.new(0, 4, -.3), -- for minetest <= 5.8
head_bone_position = vector.new(0, 3.72, -.472), -- for minetest <= 5.8
curiosity = 10,
head_yaw="z",
visual_size = {x=1,y=1},

@ -23,7 +23,7 @@ local cow_def = {
}, },
head_swivel = "head.control",
head_eye_height = 1.1,
head_bone_position = vector.new( 0, 10, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 10.07, -1.744 ), -- for minetest <= 5.8
curiosity = 2,
head_yaw="z",
makes_footstep_sound = true,

@ -62,7 +62,7 @@ mcl_mobs.register_mob("mobs_mc:llama", {
head_swivel = "head.control",
head_eye_height = 1.5,
head_yaw = "z",
head_bone_position = vector.new( 0, 11, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 10.62, 0 ), -- for minetest <= 5.8
curiosity = 60,
hp_min = 15,

@ -38,7 +38,7 @@ local ocelot = {
xp_max = 3,
head_swivel = "head.control",
head_eye_height = 0.4,
head_bone_position = vector.new( 0, 6.2, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 6.44, -0.42 ), -- for minetest <= 5.8
head_yaw="z",
curiosity = 4,
collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.69, 0.3},

@ -136,7 +136,7 @@ mcl_mobs.register_mob("mobs_mc:parrot", {
xp_min = 1,
xp_max = 3,
head_swivel = "head.control",
head_bone_position = vector.new( 0, 1.1, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 1.211, 0 ), -- for minetest <= 5.8
curiosity = 10,
collisionbox = {-0.25, -0.01, -0.25, 0.25, 0.89, 0.25},
visual = "mesh",
@ -165,8 +165,8 @@ mcl_mobs.register_mob("mobs_mc:parrot", {
fly_speed = 50,
stand_start = 0,
stand_end = 0,
fly_start = 30,
fly_end = 45,
fly_start = 60,
fly_end = 120,
walk_start = 0,
walk_end = 20,
-- TODO: actual walk animation

@ -21,7 +21,7 @@ mcl_mobs.register_mob("mobs_mc:pig", {
}},
head_swivel = "head.control",
head_eye_height = 0.7,
head_bone_position = vector.new( 0, 7.5, -1 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 7.23, -1.03 ), -- for minetest <= 5.8
curiosity = 3,
head_yaw="z",
makes_footstep_sound = true,

@ -252,7 +252,7 @@ local zombified_piglin = {
damage = 9,
reach = 2,
head_swivel = "head.control",
head_bone_position = vector.new( 0, 2.4, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 2.417, 0 ), -- for minetest <= 5.8
head_eye_height = 1.4,
curiosity = 15,
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3}, -- same

@ -26,7 +26,7 @@ mcl_mobs.register_mob("mobs_mc:polar_bear", {
},
head_swivel = "head.control",
head_eye_height = 1,
head_bone_position = vector.new( 0, 2.6, 0 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 2.396, 0 ), -- for minetest <= 5.8
curiosity = 20,
head_yaw="z",
visual_size = {x=3.0, y=3.0},

@ -66,7 +66,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", {
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45},
head_swivel = "head.control",
head_eye_height = 1.0,
head_bone_position = vector.new( 0, 3.3, -.7 ), -- for minetest <= 5.8
head_bone_position = vector.new( 0, 3.7, -.9 ), -- for minetest <= 5.8
curiosity = 6,
head_yaw="z",
visual = "mesh",