Example #1
0
exports.copy = function(obj, name, deep_copy) {

    if (!m_obj_util.is_mesh(obj)) {
        m_print.error("object \"" + obj.name + "\" is not of type \"MESH\".");
        return false;
    }

    if (!m_obj_util.is_dynamic(obj)) {
        m_print.error("object \"" + obj.name + "\" is not dynamic.");
        return false;
    }
    if (!(m_geom.has_dyn_geom(obj) || m_geom.check_shape_keys(obj)) && deep_copy) {
        m_print.error("object \"" + obj.name + "\" has not dynamic " 
                + "geometry for deep copying.");
        return false;
    }
    // HACK: a temporary (provisional) solution
    var objs = m_obj.get_scene_objs(m_scenes.get_active(), "MESH", m_obj.DATA_ID_ALL);
    if (objs.indexOf(obj) == - 1) {
        m_print.error("object \"" + obj.name + "\" does not belong to the " 
                + "active scene.");
        return false;
    }
    name = name || "";
    return m_obj.copy(obj, name, deep_copy);
}
Example #2
0
exports.set_nodemat_value = function(obj, name_list, value) {

    if (!m_obj_util.is_mesh(obj)) {
        m_print.error("The type of the object \"" + obj.name +
            "\" is not \"MESH\".");
        return;
    }

    m_obj.set_nodemat_value(obj, name_list, value)
}
Example #3
0
exports.update_canvas_ctx = function(obj, text_name) {

    if (!m_obj_util.is_mesh(obj))
        m_print.error("Object must be type of mesh.");
    else {
        if (m_textures.update_canvas_context_by_object(obj, text_name))
            return true;
        m_print.error("Couldn't find canvas texture with this name: " + text_name);
    }
    return false;
}
Example #4
0
exports.show_object = function(obj, ignore_children) {
    ignore_children = ignore_children || false;
    if ((m_obj_util.is_mesh(obj) || m_obj_util.is_empty(obj))
            && !m_obj_util.is_dynamic(obj))
        m_print.error("show/hide is only supported for dynamic objects.");
    else
        if (ignore_children)
            m_scenes.change_visibility(obj, false);
        else
            m_scenes.change_visibility_rec(obj, false);
}
Example #5
0
exports.get_canvas_ctx = function(obj, text_name) {

    if (!m_obj_util.is_mesh(obj))
        m_print.error("Object must be type of mesh.");
    else {
        var canvas_context = m_textures.get_canvas_context_by_object(obj, text_name);
        if (canvas_context)
            return canvas_context;
        m_print.error("Couldn't find canvas texture with this name: " + text_name);
    }
    return null;
}
Example #6
0
exports.remove_object = function(obj) {
    if (!m_obj_util.is_mesh(obj) && !m_obj_util.is_empty(obj)
            || !m_obj_util.is_dynamic(obj)) {
        m_print.error("Can't remove object \"" + obj.name + "\". It must be " +
                "dynamic and type of MESH or EMPTY.");
        return;
    }
    var scenes_data = obj.scenes_data;
    for (var j = 0; j < scenes_data.length; j++) {
        var scene = scenes_data[j].scene;
        m_data.prepare_object_unloading(scene, obj, false);
    }
    m_obj.remove_object(obj);
}
Example #7
0
exports.update_boundings = function(obj) {

    if (!m_obj_util.is_mesh(obj)) {
        m_print.error("The type of the object \"" + obj.name +
            "\" is not \"MESH\".");
        return;
    }

    if (!(m_geom.has_dyn_geom(obj) || m_geom.check_shape_keys(obj))) {
        m_print.error("object \"" + obj.name + "\" has not dynamic " 
                + "geometry.");
        return;
    }
    m_obj.update_boundings(obj);
}
Example #8
0
exports.get_type_mesh_object = function(obj) {
    if (m_obj_util.is_mesh(obj))
        return obj.render.type;
    return null;
}