3d Armor - need help!

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

Nope, it wasn't ;)
I'm a student by correspondence and now I have a hard time 'cause of exams session has begun, though.
I'll put what I have atm right here, as well as make a link to DropBox https://www.dropbox.com/sh/0nkvy79fwwapkhq/eA3mZb7eTi (have models & "texture").

Code: Select all

default_model = "helmet.x"
--
-- Start of configuration area:
--

-- Player animation speed
animation_speed = 30

-- Player animation blending
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
animation_blend = 0

-- Frame ranges for each player model
function armour_get_animations(model)

        return {
        stand_START = 0,
        stand_END = 79,
        sit_START = 81,
        sit_END = 160,
        lay_START = 162,
        lay_END = 166,
        walk_START = 168,
        walk_END = 187,
        mine_START = 189,
        mine_END = 198,
        walk_mine_START = 200,
        walk_mine_END = 219
        }

end


-- Player stats and animations
local player_model = {}
local player_anim = {}
local player_sneak = {}
local ANIM_STAND = 1
local ANIM_SIT = 2
local ANIM_LAY = 3
local ANIM_WALK  = 4
local ANIM_WALK_MINE = 5
local ANIM_MINE = 6


-- Update appearance when the player joins
-- minetest.register_on_joinplayer(ar_update_visuals)



local ar = {
    physical = false,
    collisionbox = {-0.5,-1,-0.5, 0.5,1,0.5},
    visual = "mesh",
    mesh = "helmet.x",
    textures = {"ar.png"},
    visual_size = {x=1, y=1, z = 1},
    wielder = nil,
    v = 0,
    animation_speed = 30,
    animation_blend = 0,
    animation = ANIM_STAND,
}


function ar:on_rightclick(clicker)
    if not clicker or not clicker:is_player() then
        return
    end
    --if self.wielder and clicker == self.wielder then
---        self.wielder = nil
    --    clicker:set_detach()
--    elseif not self.driver then
        self.wielder = clicker
        -- self.object:set_attach(self.wielder, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
        self.object:setyaw(self.wielder:get_look_yaw())
            
      --  minetest.chat_send_all(self.mesh)
        local anim = armour_get_animations(self.mesh)
        self.object:set_animation({x=anim.stand_START, y=anim.stand_STOP}, 30, 0)

--    end
end

function ar:on_step(dtime)
  local wielder = self.wielder
  if wielder == nil then 
     return 
  end
--  local name = wielder:get_player_name()
--  if name ~=nil then 
 
        local controls = wielder:get_player_control()
        local walking = false
        local animation_speed_mod = animation_speed
        local anim = armour_get_animations(self.mesh)


        if controls.up 
        or controls.down 
        or controls.left 
        or controls.right 
        then
            walking = true
        end

        
        if  controls.sneak 
        and wielder:get_hp() ~= 0 
        and (walking or controls.LMB) 
        then
            animation_speed_mod = animation_speed_mod / 2                    
        else
            animation_speed_mod = animation_speed_mod * 2        
        end



        if wielder:get_hp() == 0 then
           if self.animation ~= ANIM_LAY then
              self.object:set_animation({x=anim.lay_START, y=anim.lay_END}, animation_speed_mod, animation_blend)
              self.animation = ANIM_LAY
           end 
           
        elseif walking and controls.LMB then
           if self.animation ~= ANIM_WALK_MINE then
              self.object:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_mod, animation_blend)
              self.animation = ANIM_WALK_MINE
           end 
           
        elseif walking then
           if self.animation ~= ANIM_WALK then
              self.object:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_mod, animation_blend)
              self.animation = ANIM_WALK
           end 
           
        elseif controls.LMB then
           if self.animation ~= ANIM_MINE then
              self.object:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed_mod, animation_blend)
              self.animation = ANIM_MINE
           end 
           
        else
           if self.animation ~= ANIM_STAND then
              self.object:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_mod, animation_blend)
              self.animation = ANIM_STAND
           end 
           
        end


end

minetest.register_entity("capes:ar", ar)


minetest.register_craftitem("capes:helmet", {
    description = "Cape",
    inventory_image = "ar.png",
    wield_image = "ar.png",
    wield_scale = {x=2, y=2, z=1},
    liquids_pointable = true,
    on_place = function(itemstack, placer, pointed_thing)
        if pointed_thing.type ~= "node" then
            return
        end
        local arm = minetest.env:add_entity(pointed_thing.above, "capes:ar")
        local prop = {mesh = "helmet.x",    }
        arm:set_properties(prop)
        itemstack:take_item()
        return itemstack
    end,
})


minetest.register_craftitem("capes:char", {
    description = "Cape",
    inventory_image = "ar.png",
    wield_image = "ar.png",
    wield_scale = {x=2, y=2, z=1},
    liquids_pointable = true,

    on_place = function(itemstack, placer, pointed_thing)
        if pointed_thing.type ~= "node" then
            return
        end
        local arm = minetest.env:add_entity(pointed_thing.above, "capes:ar")
        local prop = {mesh = "character.x",    }
        arm:set_properties(prop)
        itemstack:take_item()
        return itemstack
    end,
})
I have some problems with animation.

I opened character.blend, deleted black box around character's head and exported it. And animation worked. Then I closed blender, opened character.blend again and exported it without any changes. First time that didn't work. I tried again and got animated entity.
"Inside" the blender animation is just right in both cases, but after exporting it to *.x such things happen.

If anyone knows the reason for that weird behavior, then post here, please!
I'll post any info that may help to solve this case, 'cause I'm entirely concerned in having 3d armor in Minetest.

Also, help with "putting the armor off" is no longer needed, I have a solution now ;)

sapier
Developer
Posts: 763
Joined: Tue Aug 16, 2011 18:17

by sapier » Post

I suggest using .b3d files they are way smaller and not limited as much as .x files.

(known) Limits:
-only one animation
-exactly 1 parent bone
-all faces need to be in a vertex group to show up with animations
-choose correct flags for exporting

-have mesg and armature selected on export
-all animated frames need to be enabled on export to be exported (thats true for all export formats)

I assume when exporting second time you didn't have selected same things as first time
DON'T mention coding style!
(c) sapier all rights reserved

BZab
Member
Posts: 126
Joined: Mon Jan 28, 2013 10:04
Location: Poland

by BZab » Post

jojoa1997 wrote:make pants shoes and a helmet like in the armor mod
Won't be a better idea to make one mod with em?
(3d looks from here and GUI and items from armor mod)

4aiman
Member
Posts: 1208
Joined: Mon Jul 30, 2012 05:47

by 4aiman » Post

BZab wrote:
jojoa1997 wrote:make pants shoes and a helmet like in the armor mod
Won't be a better idea to make one mod with em?
(3d looks from here and GUI and items from armor mod)
Armor mod would be either considered (why should I invent a wheel?) or forked. Anyway, I can't do anything now - Theoretical phonetics, Economy, Special course of Psychology and many more exams to be passed till 02/09/2013 ...

User avatar
Mito551
Member
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Post

4aiman wrote:Theoretical phonetics, Economy, Special course of Psychology and many more exams to be passed till 02/09/2013 ...
good luck with that.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests