joshcamas

Play animation but start at specific frame

Recommended Posts

Hallo guys!

Is it possible to play an animation, but instead of starting at the first frame of the anim, start at another? I'm building a little animating software thingy, and building a basic scrubber. :D
Thanks!

Share this post


Link to post
Share on other sites

@joshcamas -

For what you're trying to do, I assume you'll need to call many animation functions wthin the BJS animation framework. First, I recommend you use scene.registerBeforeRender(function () { }); for much of your setup to first store keyframes in arrays to make available in functions later.

So for most of your "scrubber" functions to work within your render loop, you'll need to first push your keyframes to an array (or to arrays) first - and if you require skeletal animation, then you need to import your skeletons[0] in addition to your NewMeshes[0] (this is simply an example of a single model with skeletons as children) when you call your SceneLoader. But once you have your keyframes stored, it's simple to use scene.beginAnimation(skeletons[0], var, 60, true, 1.0); where "var" is simply a variable representing your starting frame (any existing frame) from within your skeleton array. Then if you want to begin your animation back at frame 0, use animatable.reset()

Also, if you need to set your animation (skeleton or other), I recommend something like scene.beginAnimation(mesh, 3.9999, 4) to set your animation to frame 4  which looks odd at first, but works. There's lots of other "tricks" you'll need to use, but it's all available and documented - and simple once you push your keyframes to seperate arrays for use within your "scrubber" functions in your main script.

I hope this helps.

DB

Share this post


Link to post
Share on other sites

Aight, thanks so much for the reply! Still stuck on something tho!

So Ima use blender as an example:
WD52i4U.png

So the animation is 0-60. This is what I wanna play!
But my little frame line thing is at frame 46.

So if I did as you followed, and then pressed the play button,the code would be run as:

scene.beginAnimation(skeletons[0], 46, 60, true, 1.0);

Which would result in looping from 46 to 60. Which I do not want! :o
Basically, how can I run the animation 0-60, but start the animation at 46 and loop back to 0 after that?

I hope that makes sense! ;_;
Thanks! Aren't you the guy that did animation on the Hobbit or something? I think I remember you from like 2 years ago haha!

Share this post


Link to post
Share on other sites

@joshcamas -

@Nabroski and @adam have both provided you with great info and examples you can and certainly will use. As for your question:

On 11/19/2016 at 0:18 AM, joshcamas said:

Basically, how can I run the animation 0-60, but start the animation at 46 and loop back to 0 after that?

I would personally use variables for your frame #s, and then you can create functions to change these variables to represent whatever frames you wish to run, loop, etc. And as I mentioned previously, if you use  animatable.reset() , this will reset your animation to the first keyed frame of your animation. So if you begin playing your animation at frame 46 and through to the end of your animation - and then want to loop from frames 0 to 60 (assuming your scene has keyframed values set at frame 0 and also keyed values set at frame 60), then using animatable.reset() before playing your animation again will reset your animation to the first frame at frame 0 - and you should see the result you're trying to accomplish. Once again, there are ALLOT of functions for playing animations in BJS - for proceedurally created, as well as exported from applications such as Blender; but I rarely see many of these discussed on this forum. I just mentioned a few in my last post, and I can't see where you'll find any limitations in accomplishing what you're trying to build. The only limitations exist in WebGL - and more specifically in your browser, and not in babylon.js.

On 11/19/2016 at 0:18 AM, joshcamas said:

Thanks! Aren't you the guy that did animation on the Hobbit or something? I think I remember you from like 2 years ago haha!

And yeah, I've been INCREDIBLY lucky in the projects and people I've had the good fortune in which to work. An IMDB search (first name David) will show you a small sample of my good fortune in finding interesting work. And thanks to @Deltakosh, @davrous, and so many others who spend vast amounts of time and effort building babylon.js and expanding WebGL; I again find my work interesting and exciting, as working in WebGL is just as interesting - if not more so -  than many of the "popular" productions I've worked on - especially since film, TV, and video game work is simply pressing buttons these days - which I find incredibly boring and requires little talent. So when I use the word "lucky", I mean it - as The Hobbit would have been just another boring project filling some small role and collecting a paycheck - but the task I was given was to build the animatronics control systems for the hero and other characters such as "The Scribe", lots of Trolls, and other characters in the films - which I still have no idea how I was able to pull that one off. And since I knew the controls and control systems better than anyone else - because I built them - I was given the opportunity by Pete to puppetteer the Scribe and other characters in real time on set for the films. Now that was a blast, and that's what I would call "lucky." ;)

Cheers,

DB

Share this post


Link to post
Share on other sites

@joshcamas I've had the same question in my discovering of Blender and Babylon.js, have you noticed the "onAnimationEnd" parameter of the scene.beginAnimation function ?

In order to start animation at frame 46, then go back to the frame 0 I would write :

scene.beginAnimation(skeletons[0], 46, 60, false, 1.0, function() {
     scene.beginAnimation(skeletons[0], 0, 60, true, 1);
});

 

Share this post


Link to post
Share on other sites
1 hour ago, meteoritool said:

@joshcamas I've had the same question in my discovering of Blender and Babylon.js, have you noticed the "onAnimationEnd" parameter of the scene.beginAnimation function ?

In order to start animation at frame 46, then go back to the frame 0 I would write :

scene.beginAnimation(skeletons[0], 46, 60, false, 1.0, function() {
     scene.beginAnimation(skeletons[0], 0, 60, true, 1);
});

 

AH!! WHY DID I NOT THINK OF THIS!

Thank you my friend, this is 100% what I am looking for :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.