Forum

API: scale bone in armature?

05 December 2018 09:38
Hello guys,

i did some research, but i am too stupid, to figure it out.
I am trying to make a project, to scale a bone via slider.
The problem is. I dont know, how to get this done.
I know how to scale an object with sliders (javascript), but i dont know, how I can do it with bones.
(look at the Image, to seeing my concept)
I am also not a very good programmer. So do somebody have any advise for me? Or any example?
That would be very nice.
Kind regards,

Bani
05 December 2018 23:23
IMO, you cannot scale the cube on one axis only with bones because armatures do not provide scaling for single axes. This only exists for mesh objects (m_transform), and only in the latest B4W (v18.05).

In m_armature, you still have the TSR format:

[X, Y, Z, SCALE, QUAT_X, QUAT_Y, QUAT_Z, QUAT_W]

where scale is a single float for all axes. Additionally, there seems to be a bug because I got weird results for animating scale with bones in 18.05, and another user complained that get_bone_tsr may return a 9-element array instead of 8 (I got that as well). But since we get no more support, nobody knows what this means…

However, if using bones is not a must for you, you can get the result from your screenshot with other methods (m_transform.set_scale or shape keys).
06 December 2018 09:46
Oh,
that is sad. I thought that as well, but hopped, there will be another way.
Hmmm
And I got the 9-element too. I dont know why but i got an array from 0-8 (9-element).
And is the support shutted down?
Kind regards,

Bani
06 December 2018 09:48
Ah I have an Idea, but dont know if it works:

Can I make a scale animation in blender and push the animation frames with the slider forward and backwards?
Kind regards,

Bani
06 December 2018 10:19
Can I make a scale animation in blender and push the animation frames with the slider forward and backwards?
That's the first thing I tried.

This works, but as mentioned, not for a single axis. In other words, the cube will stretch out to the right in Blender, but in B4W the cube will simply grow bigger (stretch out in ALL axes). And in B4W 18.05, I got a weird result where the cube increased on the X axis, but in both directions (which is the result I did not quite understand and which is possibly buggy).
06 December 2018 14:41
I found a solution!

I had one Bone, wich I wanted zu use, to scale my object.
Now I made two bones, with some weight painting and blurring, i could change the position of one bone, so it looks like, i would scaling my object.
Its not the best solution, but the endresult looks the same.



Kind regards,

Bani
06 December 2018 20:13
Yes, that'll do the trick.

So for anyone interested, you make an armature with two bones B1 (left) and B2 (right), and for the Cube you make the respective vertex group B1, assign weight=1 to the left wall, the other vertices weight=0, and then make a vertex group B2, assign weight=1 to the right wall, the other vertices weight=0. Parent the Cube to the Armature with the "bone" option.

Now, when you move the right bone to the right, the Cube stretches out to the right.

You can sync the movement to an HTML slider with m_armature.set_bone_tsr() or m_tsr.set_trans() or by putting keyframes on the right bone and m_animation.set_frame().
07 December 2018 09:12
Thanks :)
Kind regards,

Bani
 
Please register or log in to leave a reply.