Forum

How to add animations in object slots in blender

04 December 2015 14:22
Hello,

i try to play different animations (rotation) of an object via the API.
But i don't know how to add the animations to the object's animation slots in blender to call them in my js?
Thanx for helping me.



04 December 2015 15:01
Hello,

For example, you've prepared actions in Blender and exported scene. Now you should apply this actions to the object:

function load_cb(data_id) {
    m_app.enable_controls();
    m_app.enable_camera_controls();

    var obj = m_scenes.get_object_by_name("NAME");
    if (obj) {
        m_anim.apply(obj, "ACTION_NAME_0", 0); // 0 -is slot num
        m_anim.apply(obj, "ACTION_NAME_1", 1); // 1 -is slot num
        m_anim.apply(obj, "ACTION_NAME_2", 2); // 2 -is slot num
    }
}


And if you want to play the 1th animation, for example, you should call the following code lines:
var obj = m_scenes.get_object_by_name("NAME");
var anim_callback = function() {};
m_anim.play(obj, anim_callback, 1); // 1 -is slot num

The "anim_callback" function will be called after animation will have finished.
04 December 2015 15:52
Ok thanx again Roman!
Seems so easy when you write it…
Maybe it should be nice to have simple example like that in the API doc…


04 December 2015 16:32
We are going to add a lot of interesting and useful examples in the future.
05 December 2015 00:12

We are going to add a lot of interesting and useful examples in the future.
Defenitly looking forwards to that!
 
Please register or log in to leave a reply.