Forum

Update Group Duplication to Latest State of Original Object

22 April 2016 13:45
Hi all.

I am manipulating a "Sphere"s shape key values using baked fcruve data from an object called "properties".
This is being done using a timeline sensor with values being updated in sensor's callback. So far so good, everything works!

I have anempty called "Dupli" who is responsible for showing a duplicate of "Sphere" through the duplicate group option in the object panel of "Dupli". How can I update "Dupli" so it reflects the latest state of "Sphere" with correct shape key values? I have looked all over the API but can't seem to find a solution.



Duplication updates properly if I bake the vertex animation for shape keys on "Sphere", but this makes the .bin file grow very large, so it's not a feasible solution for me. Thank you in advance

The code for applying new shape key values:
function get_prop(obj, prop ,frame){
    switch(prop) {
    case 0:
        return obj.actions[0].fcurves['["prop"]'][0]._pierced_points[frame];
        break;
    case 1:
        return obj.actions[0].fcurves['["prop1"]'][0]._pierced_points[frame];
        break;
    case 2:
        return obj.actions[0].fcurves['["prop2"]'][0]._pierced_points[frame];
        break;
    case 3:
        return obj.actions[0].fcurves['["prop3"]'][0]._pierced_points[frame];
        break;
    case 4:
        return obj.actions[0].fcurves['["prop4"]'][0]._pierced_points[frame];
        break;
    case 5:
        return obj.actions[0].fcurves['["prop5"]'][0]._pierced_points[frame];
        break;
    case 6:
        return obj.actions[0].fcurves['["prop6"]'][0]._pierced_points[frame];
        break;
    case 7:
        return obj.actions[0].fcurves['["prop7"]'][0]._pierced_points[frame];
        break;
    }
}

function setup_anim() {
    var elapsed = m_ctl.create_timeline_sensor();
    var sens_array = [elapsed];
    var logic = function(s) {return (s[0])};


    function anim_cb(obj, id, pulse) {

        var time = m_ctl.get_sensor_value(obj, id, 0);
        var timeToFrame = parseInt(m_anim.get_frame(properties, 0), 10);
        var prop    = get_prop(properties, 0 ,timeToFrame);
        var prop1   = get_prop(properties, 1 ,timeToFrame);
        var prop2   = get_prop(properties, 2 ,timeToFrame);
        var prop3   = get_prop(properties, 3 ,timeToFrame);
        var prop4   = get_prop(properties, 4 ,timeToFrame);
        var prop5   = get_prop(properties, 5 ,timeToFrame);
        var prop6   = get_prop(properties, 6 ,timeToFrame);
        var prop7   = get_prop(properties, 7 ,timeToFrame);
        // Below is where I update the shape key values:
        m_geom.set_shape_key_value(sphere, "dispOne", prop);
        m_geom.set_shape_key_value(sphere, "dispFour", prop3);
        m_geom.set_shape_key_value(sphere, "defTwo", prop1);
        m_geom.set_shape_key_value(sphere, "defThree", prop2+prop7);
        m_trans.set_rotation_euler(sphere, prop1, prop2, prop3);
    }

    m_ctl.create_sensor_manifold(properties, "ANIM", m_ctl.CT_CONTINUOUS,
                sens_array, logic, anim_cb);
}


If you want more insight into my previous discussion regarding drivers and shape keys read this.
22 April 2016 14:09
I've been trying a few things, but I dont think shape keys actually change the vertex arrays :(

        var position = m_geom.extract_vertex_array(sphere, "Material.002", "a_position");
        var normal = m_geom.extract_vertex_array(sphere, "Material.002", "a_normal");
        var index = m_geom.extract_index_array(sphere, "Material.002");
        m_geom.update_vertex_array(sphere, "a_position", position);
        m_geom.update_vertex_array(sphere, "a_normal", normal);
        m_geom.override_geometry(sphere, "Material.002", index, position, false);


No luck! Would really appreciate some help

Edit: tried the following with no luck:
m_geom.override_geometry(sphere, "Material.002", sphere.scenes_data[0].batches[0].bufs_data.ibo_array, sphere.scenes_data[0].batches[0].bufs_data.vbo_array, false);
22 April 2016 18:26
Hello.

When you use dupli groups, the engine creates a new objects. Can you use an object coping? For example:

23 April 2016 05:09
Thank you so much. This does indeed work when using the API. However I need to duplicate the object many times, and wanted to do this in blender by creating empty objects and assigning duplication to Sphere Group. Is there anyway that this can be done through blender by shape keys are modified through script, yet it is properly displayed on all dupli objects?
25 April 2016 12:13
Currently, It is not supported, but in future we are planning to add this feature.
 
Please register or log in to leave a reply.