diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2012-10-25 23:29:07 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-11-25 18:14:15 +0200 |
commit | fb0c43186422ad985e70f73bc70eeb07cc194909 (patch) | |
tree | 2e02bdbe9e9abb6d2ee392ee895fa0b73f000f03 /src/scriptapi.cpp | |
parent | 9c8ba427503cbf73f0263495a791656b905c2efc (diff) | |
download | minetest-fb0c43186422ad985e70f73bc70eeb07cc194909.tar.gz minetest-fb0c43186422ad985e70f73bc70eeb07cc194909.tar.bz2 minetest-fb0c43186422ad985e70f73bc70eeb07cc194909.zip |
Allow the LUA API to set animations to meshes as well as the animation speed. Also update animations only when needed.
Support for animation blending, though for some reason it doesn't work.
Don't enable animation transitions by default for many reaosons
Object property to store individual bone positions. LUA can specify a bone name followed by a bone position. No functionality yet. Bone rotation to be added in the following commit
Same system for bone rotation, plus a few other things I missed
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r-- | src/scriptapi.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 9293e2b65..74de50ef8 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -944,6 +944,45 @@ static void read_object_properties(lua_State *L, int index, prop->visual_size = read_v2f(L, -1); lua_pop(L, 1); + lua_getfield(L, -1, "animation_frames"); + if(lua_istable(L, -1)) + { + lua_rawgeti (L, -1, 1); + lua_rawgeti (L, -2, 2); + prop->animation_frames.X = lua_tonumber(L, -2); + prop->animation_frames.Y = lua_tonumber(L, -1); + lua_pop(L, 2); + } + lua_pop(L, 1); + + getfloatfield(L, -1, "animation_speed", prop->animation_speed); + + getfloatfield(L, -1, "animation_blend", prop->animation_blend); + + lua_getfield(L, -1, "animation_bone_position"); + if(lua_istable(L, -1)) + { + lua_rawgeti (L, -1, 1); + lua_rawgeti (L, -2, 2); + std::string bone_name = lua_tostring(L, -2); + v3f bone_pos = read_v3f(L, -1); + prop->animation_bone_position[bone_name] = bone_pos; + lua_pop(L, 2); + } + lua_pop(L, 1); + + lua_getfield(L, -1, "animation_bone_rotation"); + if(lua_istable(L, -1)) + { + lua_rawgeti (L, -1, 1); + lua_rawgeti (L, -2, 2); + std::string bone_name = lua_tostring(L, -2); + v3f bone_rot = read_v3f(L, -1); + prop->animation_bone_rotation[bone_name] = bone_rot; + lua_pop(L, 2); + } + lua_pop(L, 1); + lua_getfield(L, -1, "textures"); if(lua_istable(L, -1)){ prop->textures.clear(); |