AndyBeaulieu Posted March 21, 2014 Share Posted March 21, 2014 OK, so this is somewhat related to this previous thread which I was going to give up on, but my stubbornness brought me back to it I am trying to get a rag doll working and here is a lame jsfiddle of where I am at: http://jsfiddle.net/andybeaulieu/9Ffv5/42/ If you go there and click the button at the top, you will see that the skeleton of the guy mesh is copied to a series of box meshes on the left. physics is added to the "arm copies" using box imposters and joints I am trying to apply the same position and rotation for the "arm copies" on the left to the equivalent skeleton bones on the right, thus creating a rag doll effect.As you can see, I have the POSITION of the bones being copied ok, using a Translation. But I cannot get the Rotation to work, and the guy's arms are all bent wrong Near the top of the code, at line 58, is where I need help I think - I have the starting Quaternion of the bone mesh, and the current Quaternion, and I want to apply the difference in those to the bone matrix. Because this causes some really bizzarre rotations and problems, I have the code to do that commented out. What am I missing here to do this rotation? // ******************** // // THIS IS WHERE I NEED HELP! // Apply the difference in Rotation between the Start Mesh Rotation // and the current Rotation to the bone // // ******************** // rotation TEST ONLY if (boneMeshParent) { var matrixRotationStart = new BABYLON.Matrix(); boneMesh.saveStartRotationQuaternion.toRotationMatrix(matrixRotationStart); var matrixRotationCurrent = new BABYLON.Matrix(); boneMesh.rotationQuaternion.toRotationMatrix(matrixRotationCurrent); // I must have this matrix multiply out of order? I dunno //matrixRotationStart.invert(); //var matrixRotation = matrixRotationStart.multiply(matrixRotationCurrent); //boneMatrix = boneMatrix.multiply(matrixRotation); } Quote Link to comment Share on other sites More sharing options...
AndyBeaulieu Posted March 22, 2014 Author Share Posted March 22, 2014 Just to be a bit more clear on this - if you run the jsfiddle here - http://jsfiddle.net/andybeaulieu/9Ffv5/42/ You will see the issue I have, circled in red below - I need to rotate the bones in the arms equal to the rotation of the bone meshes to the left. My thought is to use the difference in the rotation quaternions at the rest position and the current position, but that doesn't work. By the way, I think if I can get past this rotation issue, I can create a generic rag doll helper for Babylon, which would very cool - basically you could just pass in a mesh with a skeleton, and have a pretty good rag doll automatically generated from it. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 24, 2014 Share Posted March 24, 2014 Sounds more than promising!!! Had you have a chance to check how the bones are computed and transmitted to the shaders? If you think we could do thinks differently to accommodate your needs, I will be happy to fix the code! Quote Link to comment Share on other sites More sharing options...
AlbertoBonn Posted March 25, 2014 Share Posted March 25, 2014 This demo is nice for me! But I think you not align the z-axle (or y if when u think in babylon.js coordinates) with the parent elementIm not shure, but this problem I know from my first blender bone studies. Maybe this video will clear some questions. Its Blender, but the concept is the samehttp://www.blenderguru.com/videos/introduction-to-rigging/ 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.