getzel Posted October 22, 2016 Share Posted October 22, 2016 Hello ! Is it possible to play a bone animation (created in Blender) backward ? For example : we make strafe right and want to play strafe left via code. I imagine something like : scene.beginAnimation(skeleton, 40, 0, true, 1.0); Do you think it's a cool feature ? Implemeting all reverse animations in Blender is not complicated but heavy. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 23, 2016 Share Posted October 23, 2016 Hiya getzel! Yeah, it's a cool feature idea, for sure, but BJS animation keys need to be in ascending order, according to Deltakosh. In a different post, I pondered (long-winded) a CYCLEMODE_PINGPONG for animations... so they could run forward, then backward, then forward, then backward, etc. In the next post, Deltakosh kindly told me some excellent info, and fixed my poorly-coded pingpong function. Playground: http://www.babylonjs-playground.com/#1LNWLE#3 Lines 39-59 are the pingpong func, as you can see. Essentially, it just reverses all the keys on the animations of all bones, and calls beginAnimation again. So, although an invertKeys parameter/flag for our animation system might be a decent new feature, it might not be used often enough to warrant the change/mod. Perhaps a wiser move would be to code/steal a very fast/efficient array-reverser... for reversing animation keys. The reverser in the pingpong func is pretty good, but it could be tightened-up a bit. See line 61 in that #3 playground above? The pingpong func is set as the onAnimationEnd parameter. You would not be doing that. What you might do... is create/maintain two different arrays of keys... one for strafe left, one for strafe-right. Able is my abbreviation for animatable. On our rabbit, there are 4 bones (each with animation), and line 42 is for looping through all 4 bones. Line 54 installs the new keys on each bone's animation. Rudy the Rabbit... is doing ping-pong animation pretty well, there. Still, mesh.invertAnimationKeys() or perhaps Animatable.reverseAnimationKeys()... might be worthy of PR. Not sure. I usually delegate framework feature decisions... to Deltakosh. He sees 'the big picture' far-better than I. Maybe Deltakosh will comment. Hey, thanks for the idea, Getzel. It is worthy of some consideration, for sure. Party on! PS: The #8 playground puts some texture back-onto Rudy. It might be interesting to note that the boundingBox does not follow Rudy's reclining. Know why? Sure we do. Rudy the Model... never changed rotation. He/She stayed in one place, but the animation on his/her non-mesh "bones"... moved all his/her body parts. Rudy never fell. Only his/her body parts moved to horizontal (and back). getzel 1 Quote Link to comment Share on other sites More sharing options...
getzel Posted October 23, 2016 Author Share Posted October 23, 2016 @Wingnut Thank you for your answer. In fact reverse wouldn't work for strafe I think. I tried on my model with an animation where the left leg rotates left (x direction). And with your fonction, it rotates toward z direction although it should rotate right (x direction). Not the desired effect for the moment. But at least it has an effect. Maybe i have to do more tests and study on that function. 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.