max123 Posted October 26, 2016 Share Posted October 26, 2016 Hi, Is there a way to extract a bone's World position? I need an actor to pick up a rock and throw it. ELI5, please! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 26, 2016 Share Posted October 26, 2016 hey you can call bone.getWordmatrix(). getTranslation () Quote Link to comment Share on other sites More sharing options...
max123 Posted October 26, 2016 Author Share Posted October 26, 2016 Hmmm.... Doesn't work. I get really strange results. Quote Link to comment Share on other sites More sharing options...
max123 Posted October 26, 2016 Author Share Posted October 26, 2016 I mean, I'd really appreciate it if someone gave me a hint on how they would approach this problem. Quote Link to comment Share on other sites More sharing options...
adam Posted October 26, 2016 Share Posted October 26, 2016 http://www.babylonjs-playground.com/#11BH6Z#94 Quote Link to comment Share on other sites More sharing options...
adam Posted October 26, 2016 Share Posted October 26, 2016 Here is a Bone.getAbsolutePositionToRef function that could be added to the Bone class: http://www.babylonjs-playground.com/#11BH6Z#153 It's tricky because the absoluteTransforms don't get updated when an animation is playing. That's why I call updateBoneMatrix before getting the position. Also, the bone doesn't have a reference to the mesh, so I had to make it an option. max123 1 Quote Link to comment Share on other sites More sharing options...
max123 Posted October 26, 2016 Author Share Posted October 26, 2016 Hey @adam, thanks! It works great. Why don't you do a PR? This feature is so useful, it would be great if it was part of the lib. Something like bone.getTranformedWorldPosition() getzel 1 Quote Link to comment Share on other sites More sharing options...
adam Posted October 26, 2016 Share Posted October 26, 2016 I probably will. I don't like how you need to call the updateBoneMatrices function, though. Maybe someone can suggest a better way to handle that. I'm going to be submitting a PR for Bone.rotate and Bone.scale today or tomorrow. Wingnut and getzel 2 Quote Link to comment Share on other sites More sharing options...
getzel Posted October 26, 2016 Share Posted October 26, 2016 Cool Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 26, 2016 Share Posted October 26, 2016 Unfortunately you have to to get all the bones chain updated Quote Link to comment Share on other sites More sharing options...
adam Posted October 26, 2016 Share Posted October 26, 2016 @Deltakosh What do you think about doing something like this? http://www.babylonjs-playground.com/#11BH6Z#157 I created a computeAbsoluteTransforms in Skeleton that bone.getAbsolutePosition calls. computeAbsoluteTranforms would keep track of the renderId whenever it's called so that it doesn't get computed more than once each render unless forced. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 27, 2016 Share Posted October 27, 2016 like it! 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.