MackeyK24 Posted May 14, 2018 Share Posted May 14, 2018 Hi Guys... Here is a quick video to show the progress of my animation state machine for the the Babylon Toolkit. Basically i need help in calculating 2D blend tree child position weights. Please watch the video: Animation State Progress Listed are the signatures of the three computation functions i need help with. Yo @Sebavan and @Deltakosh and @davrous ... Please Watch this video and see if you can help with the three calculations... PLEASE private computeSimpleDirectionalWeight(parentTree:BABYLON.IBlendTree, inputPosition:BABYLON.Vector2, childPosition:BABYLON.Vector2):number { var weight:number = 0; var inputDistance:number = inputPosition.subtract(childPosition).lengthSquared(); // var inputAngle:number = BABYLON.Vector2.Angle(inputPosition, childPosition); // cosinus similarity from -1f to -1f shifted to 0 to 1f( same angle cosinus similarity=0f and max opposite direction -1f) // 1/d1+1/d2+1/d3... // .. // var inputAngle:number = (BABYLON.Scalar.Clamp(BABYLON.Vector2.Dot(inputPosition.normalize(), childPosition.normalize()), -1, 1)-1) * (-0.5); // .. // TODO: Calculate Weight based on input distance and angle - ??? // .. return weight; } private computeFreeformDirectionalWeight(parentTree:BABYLON.IBlendTree, inputPosition:BABYLON.Vector2, childPosition:BABYLON.Vector2):number { var weight:number = 0; var inputDistance:number = inputPosition.subtract(childPosition).lengthSquared(); // var inputAngle:number = BABYLON.Vector2.Angle(inputPosition, childPosition); // cosinus similarity from -1f to -1f shifted to 0 to 1f( same angle cosinus similarity=0f and max opposite direction -1f) // 1/d1+1/d2+1/d3... // .. // var inputAngle:number = (BABYLON.Scalar.Clamp(BABYLON.Vector2.Dot(inputPosition.normalize(), childPosition.normalize()), -1, 1)-1) * (-0.5); // .. // TODO: Calculate Weight based on input distance and angle - ??? // .. return weight; } private computeFreeformCartesianWeight(parentTree:BABYLON.IBlendTree, inputPosition:BABYLON.Vector2, childPosition:BABYLON.Vector2):number { var weight:number = 0; var inputDistance:number = inputPosition.subtract(childPosition).lengthSquared(); // var inputAngle:number = BABYLON.Vector2.Angle(inputPosition, childPosition); // cosinus similarity from -1f to -1f shifted to 0 to 1f( same angle cosinus similarity=0f and max opposite direction -1f) // 1/d1+1/d2+1/d3... // .. // var inputAngle:number = (BABYLON.Scalar.Clamp(BABYLON.Vector2.Dot(inputPosition.normalize(), childPosition.normalize()), -1, 1)-1) * (-0.5); // .. // TODO: Calculate Weight based on input distance and angle - ??? // .. return weight; } Thanks soo much Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted May 17, 2018 Author Share Posted May 17, 2018 Yo... There is gotta be someone, one of you BabylonJS / Unity big dogs that gotta see where i am trying to go with the Animation State. All i need to know is how to calculate the input weight for each 2D Blend Tree Child Position (Vector2) based on the the current X and Y input parameter (Vector2). Thats all i need to re-create the a Unity-Like Mechanim Animation State machine for use in our BabylonJS game projects. Just a little help from the big dogs and we can get it out for everyone to use Help a brotha out community, remember its for community toolkit use Quote Link to comment Share on other sites More sharing options...
Guest Posted May 17, 2018 Share Posted May 17, 2018 No one? I can't be the only one willing to help @MackeyK24 Quote Link to comment Share on other sites More sharing options...
Gijs Posted May 17, 2018 Share Posted May 17, 2018 Hi Mackey, I watched the video, and I tried some things, but to no avail... but then I found this: https://answers.unity.com/questions/1206428/how-weights-of-2d-blending-are-calculated.html Seems like the answer is somewhere in there, now you just gotta make sense of it ? I wish I could be of more help, because it's a really nice project you are working on! Keep it up! ? Quote Link to comment Share on other sites More sharing options...
MackeyK24 Posted May 17, 2018 Author Share Posted May 17, 2018 Yeah i found the same article. That is how i am trying to calculate the inputAngle... But the C# code listed in the example does not seem to work. And those guys at Unity have that calculation code NESTED down in the C++ layer and cant see what they doing to calculate those input weights... That just sucks 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.