santarcade Posted May 7, 2016 Share Posted May 7, 2016 Hi guys, after beating my head against this for a while, I came to the conclusion that I need a break and possibly some support. I want to calculate the position of theObject mesh in the local space of theBone which is attached to theMesh. The code I write for it is: // combine the bone World Matrix with the transform of the mesh var boneInverse = theBone.getWorldMatrix().multiply(theMesh.getWorldMatrix()); boneInverse.invert(); // calculate object position relative to the bone joint console.log('object world position: '+objectMesh.position); var relPos = BABYLON.Vector3.TransformCoordinates(objectMesh.position, boneInverse); console.log('object rel position: '+relPos); But the problem is I keep getting weird results... I tried switching theBone.getWorldMatrix() with theBone.getAbsoluteMatrix() with no luck. It is still unclear the difference between the two me and I could not find anything in the doc. Halp! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 9, 2016 Share Posted May 9, 2016 Hey this class could be helpful: https://github.com/BabylonJS/Babylon.js/blob/master/src/Debug/babylon.skeletonViewer.ts (mainly this function: https://github.com/BabylonJS/Babylon.js/blob/master/src/Debug/babylon.skeletonViewer.ts#L40) Quote Link to comment Share on other sites More sharing options...
santarcade Posted May 10, 2016 Author Share Posted May 10, 2016 Deltakosh! Thank you very much for the reply: this is exactly what I ended up coding, a skeleton visualizer and a bone matrix updater. Turned out, my calculations were correct the problem I experienced instead was related to how I override bone matrixes while an animation is playing: basically when calculating how to dynamically adjust the rotation of a bone, I was using theBone.getWorldMatrix() but the resulting matrix was not up-to-date. So my bone adjustment looked wrong, while it was just the matrix that was out-dated: so a small function such as this one https://github.com/BabylonJS/Babylon.js/blob/master/src/Debug/babylon.skeletonViewer.ts#L119 solved! Now I'm experiencing a new issue though: I have an additional mesh attached to a bone of the skeleton for which I override the matrix of the animation: while the main mesh animates using my adjusted values, the attached mesh plays the original animation, without my overrides. I'm running 2.3.0: any clue? I will try to update to 2.4.0 preview, just to see if it changes. Thanks so far! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 10, 2016 Share Posted May 10, 2016 hard to tell but if you can provide a PG it's gonna help me a lot Quote Link to comment Share on other sites More sharing options...
santarcade Posted May 11, 2016 Author Share Posted May 11, 2016 Ok, I will try to extract an example as soon as I can. Thanks so far! 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.