Jump to content

Animation State Machine Progress


MackeyK24
 Share

Recommended Posts

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 :)

 

Link to comment
Share on other sites

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 :)

 

Link to comment
Share on other sites

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! ?

Link to comment
Share on other sites

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 :(

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...