Bone animation help please
21 March 2015 22:41
And that's how easy it is to work with Blend4Web!
21 March 2015 23:23
this no longer works as a way to position the JSON file in the main scene, any info appreciated yet again!
function load_alex_cb(data_id) {
var alex= m_scenes.get_object_by_name("alex", data_id);
m_trans.set_translation(alex, 111, 0, 0); //xzy
m_trans.set_scale(alex, 5);
m_scenes.apply_glow_anim(alex, .95, 1, 0);
}
the Glow does work, but translation and scale do not. Model is called "alex", armature is "alexArmature". I am assuming I have to do scale and translation to the armature, but I currently do not know how to implement it.
function load_alex_cb(data_id) {
var alex= m_scenes.get_object_by_name("alex", data_id);
m_trans.set_translation(alex, 111, 0, 0); //xzy
m_trans.set_scale(alex, 5);
m_scenes.apply_glow_anim(alex, .95, 1, 0);
}
the Glow does work, but translation and scale do not. Model is called "alex", armature is "alexArmature". I am assuming I have to do scale and translation to the armature, but I currently do not know how to implement it.
22 March 2015 13:26
22 March 2015 19:35
Here is the scene JS, feel free to toss in the bit required if you have a moment. If I figure it out before this post is noticed, I will post the solution. However, chores first…
"use strict";
b4w.register("example_main", function(exports, require) {
var m_app = require("app");
var m_data = require("data");
var m_main = require("main");
var m_scenes = require("scenes");
var m_trans = require("transform");
var _previous_selected_obj = null;
exports.init = function() {
m_app.init({
canvas_container_id: "canvas3d",
callback: init_cb,
physics_enabled: false,
force_selectable: true,
background_color: [0.7, 0.9, 1.0, 1.0],//rgba
alpha: true
});
}
function init_cb(canvas_elem, success) {
if (!success) {
console.log("b4w init failure");
return;
}
m_app.enable_controls(canvas_elem);
canvas_elem.addEventListener("mousedown", main_canvas_click, false);
window.onresize = on_resize;
on_resize();
load();
}
var m_mouse = require("mouse");
function load() {
m_data.load("json/dyn_load_pos.json", load_cb);
m_data.load("json/alex.json", load_alex_cb);
}
function load_cb(data_id) {
m_app.enable_camera_controls();
}
function load_alex_cb(data_id) {
var alex= m_scenes.get_object_by_name("alex", data_id);
m_trans.set_translation(alex, 111, 0, 0);
m_scenes.apply_glow_anim(alex, .95, 1, 0);
}
function main_canvas_click(e) {
if (epreventDefault)
epreventDefault();
var x = e.clientX;
var y = e.clientY;
var obj = m_scenes.pick_object(x, y);
var alex= m_scenes.get_object_by_name("alex");
if (obj && obj.name == "alex") window.open("http://www.blend4web.com/");
;
}
function on_resize() {
var w = window.innerWidth;
var h = window.innerHeight;
m_main.resize(w, h);
};
});
b4w.require("example_main")init();
23 March 2015 12:22
Hi,
You can just replace
with
And make all the translation stuff with it:
[EDIT]
But you need to keep in mind that in this case alex had to be parented to alexArmature.
You can just replace
var alex = m_scenes.get_object_by_name("alex", data_id);
with
var alex_arm = m_scenes.get_object_by_name("alexArmature", data_id);
And make all the translation stuff with it:
m_trans.set_translation(alex_arm, 111, 0, 0); //xzy
m_trans.set_scale(alex_arm, 5);
[EDIT]
But you need to keep in mind that in this case alex had to be parented to alexArmature.
23 March 2015 19:02
Thanks for the info, I have actually tried various versions of what you wrote and have not been successful. Perhaps it is the model I am using, as the bikini dance girl in this thread was just for the sake of this thread, "alex" is actually one of the models from the Junk music video. The mesh called "alex" is skinned to the armature called "alexArmature". That armature, in turn, is parented to "alexEmpty", which allowed me to place the linked model in a main scene. Could "alexEmpty" be preventing anything? I will try this with the blender dance girl later and see if it works. I ASSUME the mesh being parented with automatic weights is what you mean by parented to the armature. Also, I will still need to have a reference to "alex" for the sake of GLOW. Once I have figured out placement of skeletal animated meshes, I am pretty much done with the studies and can go full production.
23 March 2015 19:16
All I had to do to be successful was test with the blender bikini girl. All works fine. I am off and running, thanks!
24 March 2015 02:09
One more issue, with Transform animated mesh: Is there any reason why this Transform animated mesh will not Scale or Transform? The Glow works.
function load_lampFan_cb(data_id) {
var lampFan= m_scenes.get_object_by_name("lampFan", data_id);
m_trans.set_translation(lampFan, -.5, 2, 0.45); //xzy
m_trans.set_scale(lampFan, 0.2);
m_scenes.apply_glow_anim(lampFan, 1, 1, 0);
}
24 March 2015 12:31
Ответ на сообщение пользователя trepaning
One more issue, with Transform animated mesh: Is there any reason why this Transform animated mesh will not Scale or Transform? The Glow works.
Hello! Unfortunately, there is a reason. This mesh is animated with object animation. Blender object animation and animation through the engine API use the same model matrix. So, Blender object animation has a priority and you can't use both.
But you can make armature animation for an object and animate the object through the engine API. It works. For example: https://www.blend4web.com/en/article/54 (see "Character animation" section; you can make it without proxy)
24 March 2015 19:32
Okay good to know.
Just for complete info, I tested vertex animated mesh and it can be translated and scaled as per the above code, so only object animated objects needs special attention.
transform, scale?
bone animated mesh- yes
vertex animated mesh - yes
static mesh - yes
object animated mesh - no
With that, I am pretty much up to speed!
Until the next bump in the road, of course…
Just for complete info, I tested vertex animated mesh and it can be translated and scaled as per the above code, so only object animated objects needs special attention.
transform, scale?
bone animated mesh- yes
vertex animated mesh - yes
static mesh - yes
object animated mesh - no
With that, I am pretty much up to speed!
Until the next bump in the road, of course…