getzel Posted January 23, 2016 Share Posted January 23, 2016 Hi guys ! I wonder if it's possible to manually rotate a bone ? Like : skeleton.bones[5].rotation.x = 2; (in three.js) It seems to doesn't work on skinned mesh. Thanks in advance Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 23, 2016 Share Posted January 23, 2016 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); getzel 1 Quote Link to comment Share on other sites More sharing options...
getzel Posted January 23, 2016 Author Share Posted January 23, 2016 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. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 25, 2016 Share Posted January 25, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 25, 2016 Share Posted January 25, 2016 To complete what @aWeirdo is saying: * you can call skeleton.createAnimationrange("wave", 26, 40) *then you can call: skeleton.beginAnimation("wave") Quote Link to comment Share on other sites More sharing options...
getzel Posted January 26, 2016 Author Share Posted January 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 26, 2016 Share Posted January 26, 2016 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 Quote Link to comment Share on other sites More sharing options...
getzel Posted January 27, 2016 Author Share Posted January 27, 2016 Ok nice to hear that Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 27, 2016 Share Posted January 27, 2016 I have finished. Both Blender exporters 4.2.1 support multiple actions. The action names become the range name on import. Blender IK is also now easily accomplished. Quote Link to comment Share on other sites More sharing options...
getzel Posted October 8, 2016 Author Share Posted October 8, 2016 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 Quote Link to comment Share on other sites More sharing options...
adam Posted October 8, 2016 Share Posted October 8, 2016 http://www.babylonjs-playground.com/#11BH6Z#92 Wingnut 1 Quote Link to comment Share on other sites More sharing options...
getzel Posted October 8, 2016 Author Share Posted October 8, 2016 @adam Thank you Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 9, 2016 Share Posted October 9, 2016 That guy gives the phrase "looking around"... a whole new meaning, huh? Quote Link to comment Share on other sites More sharing options...
getzel Posted October 10, 2016 Author Share Posted October 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 10, 2016 Share Posted October 10, 2016 Hey can you elaborate more about why attachToBone does not work? Quote Link to comment Share on other sites More sharing options...
getzel Posted October 10, 2016 Author Share Posted October 10, 2016 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 ? Quote Link to comment Share on other sites More sharing options...
adam Posted October 10, 2016 Share Posted October 10, 2016 Here is an example that works. http://www.babylonjs-playground.com/#OCCLB#16 getzel 1 Quote Link to comment Share on other sites More sharing options...
getzel Posted October 13, 2016 Author Share Posted October 13, 2016 @adam Thanks, i will try that. I tried submesh (material) but no position params. Quote Link to comment Share on other sites More sharing options...
getzel Posted October 15, 2016 Author Share Posted October 15, 2016 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) } Quote Link to comment Share on other sites More sharing options...
adam Posted October 15, 2016 Share Posted October 15, 2016 3 hours ago, getzel said: Why in this one, we don't need to use scene.beginAnimation ? That PG is not using an BJS animation. https://github.com/BabylonJS/Babylon.js/blob/master/src/Animations/babylon.animation.ts It's rotating the bone on the local z axis by Math.PI*.5*Math.sin(t) every frame. getzel 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 24, 2016 Share Posted October 24, 2016 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! getzel 1 Quote Link to comment Share on other sites More sharing options...
adam Posted October 24, 2016 Share Posted October 24, 2016 2 minutes ago, Wingnut said: Look how much code it takes... to activate simple dynamic movement on Mister Elbow. Most of that code has nothing to do with the bone rotation. The code for bone rotation is in the rotateBone function. Quote Link to comment Share on other sites More sharing options...
adam Posted October 24, 2016 Share Posted October 24, 2016 I think the code for rotating a bone should go in the Bone class. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 24, 2016 Share Posted October 24, 2016 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. Quote Link to comment Share on other sites More sharing options...
adam Posted October 24, 2016 Share Posted October 24, 2016 Maybe there should be the equivalent of Mesh.rotate for a bone: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L369 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.