From fb0c43186422ad985e70f73bc70eeb07cc194909 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Thu, 25 Oct 2012 23:29:07 +0300 Subject: 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 --- src/scriptapi.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/scriptapi.cpp') 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(); -- cgit v1.2.3