Jump to content

Rotate a bone ?


getzel
 Share

Recommended Posts

Thank you for your answer. Is it a fast process for computers ?

It would be cool in the next version of babylon.js a method rotate in bone class.

 

And the Babylon model exporter for Blender handles mutiple animations ?

Because i often see the function "beginAnimation" with the arguments : skeleton and time but not the name of the animation.

 

Is it possible also to mix animations (layers), for example "walk" and raise the hand to say hi or shoot with a gun ?

And blending animations would be the last point.

 

Thank you in advance.

Link to comment
Share on other sites

getzel, a good and easy way to handle the animations is to have them on the same timeline,

example:

/*
before the mesh import.
var skeleton;

Inside the mesh import.
skeleton = skeletons[0]; 
*/

example:

walk animation from frame 1 - 25

scene.beginAnimation(skeleton, 1, 25, true, 1.0);

wave animation from 26 - 40

scene.beginAnimation(skeleton, 26, 40, false, 1.0);

and so on.

Link to comment
Share on other sites

Thx for your advices.

 

old thought updated :

Quote

 

 

But it's not very handy, is it too difficult for the creators to develop an exporter which handle mulitple animations ?

 

And it doesnt answer to some questions : how to mix animations ?

It is an important feature in a game engine.

For example in a fps : walking or running and shoot at the same time.

 

Babylon.js could be the best game framework if it would have more profesional features and examples :) .

 

 

edit :

 

Thank you aWeirdo, it's a good practice to select only the bones we want to mix animations.

 

Link to comment
Share on other sites

Quote

Babylon.js could be the best game framework if it would have more professional features and examples

Working on it :) But we already have the best community out there !

Quote

But it's not very handy, is it too difficult for the creators to develop an exporter which handle mulitple animations ?

Guess what? it is. But this is an open source framework so please help yourself and contribute. @JCPalmer is working on such a thing for Blender

 

Regarding mixed animations, this is not supported so far but we can think about it

 

 

Link to comment
Share on other sites

  • 8 months later...
On 23/01/2016 at 5:17 PM, Deltakosh said:

You can update bone matrix with bone.updateMatrix(mat);

So you can do something like: 


var mat = bone.getLocalMatrix();
mat = mat.multiply(BABYLON.Matrix.RotateY(0.5);

bone.updateMatrix(mat);

 

 

Hello, it's been a long time.

 

var mat = skeletonMan.bones[9].getLocalMatrix();
    mat = mat.multiply(BABYLON.Matrix.RotationX(0.5));
    skeletonMan.bones[9].updateMatrix(mat);

 

It works if we activate : scene.beginAnimation

 

 

Link to comment
Share on other sites

Hehe 

 

Is there a way to make a mesh follow a bone (copy the position) when I rotate the skeleton through the matrix code ?

The function attachToBone() doesn't work in this case.

Do you know some matrix operations and functions that would work for that please ?

 

Use example :

A man mesh with skeleton can rotate his shoulder through the matrix code of Deltakosh, following the direction of the cursor.

A gun mesh is loaded after. And i want the gun to be in the same position as the hand bone.

 

So I tried some random things :

If I do gun.parent = skeleton.bones[12] it does nothing.

I can create a box at the same position as the soulder, make the same rotation as the shoulder and do gun.parent = box, then move a bit the position.z of the gun to be forward,

But the position won't match exactly cause maybe the rotation of the bone shoulder is different in z axis or something else.

 

Link to comment
Share on other sites

Hello,

I use the function gun.attachToBone(skeleton.bones[12], man);

and the gun follows the man like if I did gun.parent = man  but it doesn't follow the hand bone which is moving with the code.

 

I don't know good the matrix.

Is there a function to get the location of a bone and to copy that into a mesh ?

Link to comment
Share on other sites

On 10/10/2016 at 7:30 PM, adam said:

Here is an example that works.

http://www.babylonjs-playground.com/#OCCLB#16

Your code is very complex to me. Can you make it easier to understand or explain to me ?

What is the resut of bone.markAsDirty() ?

Why in this one, we don't need to use scene.beginAnimation ? compared to :

 

function updateLoop() {

var mat = skeletonMan.bones[9].getLocalMatrix();
    mat = mat.multiply(BABYLON.Matrix.RotationX(0.01));
    skeletonMan.bones[9].updateMatrix(mat);

scene.beginAnimation(skeleton.bones[9],0,1,false,1)

}

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi guys.  Okay, I would like to understand better... why bone.rotate or bone.rotation (coded on bone class) would be unwanted or undesirable.

1.  Is there an "approved" API to a bone... that is commonly used in modelers... and BJS shouldn't deviate from that?

2.  By adding some "handy features" to the bone class, would we be adding lots of unwanted size to our skeletons?

3.  Would adding things like bone.rotation... make users treat bones as mesh, when they really are not a mesh?  Confusion factor?

4.  Are there other drawbacks to "loading-up" the bone class... with functions/properties similar to mesh .rotation/.position/.scaling?

Thanks for info, guys.  I am newbie about bones/skeletons, and I want to see if there are problems with "powering-up" the bone class.  If there are no issues, or only tiny issues, then perhaps I will join getzel in requesting/coding more bone features.  (Wingy, coding typescript?  Get real.)  heh.

Look how much code it takes... to activate simple dynamic movement on Mister Elbow. 

5. Even though bones are not mesh, is there any reasons why we can't make them "act" like mesh, in a limited way?  Why not bone.rotation.z = euler-whatever?

6.  Would it be wiser to put bone-manipulation tools.... on BABYLON.Tools? 

7. Thoughts, anyone?  :)  Thx!

Link to comment
Share on other sites

I know. That's the code I am speaking-of.  Quats and matrices... just to rotate a bone?  erf.

Not a very "easy and simple" interface/facade (API) to expose-to the bone-experimenters... of the easiest framework ever.  ;)  "More power!"  - Tim Taylor - Home Improvement TV show.  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...