Snouto

Help! Animating object along a curve from Blender?

Recommended Posts

Hey dudes

So I'm continuing along with my 3d project and I've been building a prototype scene in babylon in order to test the final experience and make a few decisions. Part of my test scene involves a helicopter going around in a circle, so in blender i created a bezierCircle, parented the helicopter to it and set the parenting mode to follow path. In blender this works great when running the animation.

The big problem is of course (I soon discovered) that the babylon exporter does not support beziercircles and therefore ignores the path and the helicopter model (since it is now a child object of the beziercircle).

So my question is; what is the expected way to set up things like follow path animations in Blender such that the babylon exporter will support it and babylon can play the animations automatically?

Cheers!

Share this post


Link to post
Share on other sites

I just had the same problem(s), Blender not exporting Bezier curves (the path of the middle of the track in a racing game)
My solution was to make a triangle, add an array modifier and a curve modifier (makes triangles along the curve)

Then in babylon, I had an avarage of every three vertice positions, and made a Ray downwards to the surface of the road to get the final point.
The curve (a BABYLON.Path3D) is shown here in white, the triangles exported are in red.

Exporting bezier curves as a Path3D would be prettier :)
Also there is no option to "ignore this object" setting in the exporter, so I have to edit the .babylon file with a JSON editor...
 

track.jpg

Share this post


Link to post
Share on other sites

Path3D class in Math.ts is not serializable, so it not possible to put it in a .babylon file.   Even if it were, I am not sure how well it lines up.  I think you will need to bake this.  Here is a .blend where this is done.  I did not make this test scene, but it might help you.  Gryff is no-longer with us, basically.

Share this post


Link to post
Share on other sites
12 hours ago, BitOfGold said:

I just had the same problem(s), Blender not exporting Bezier curves (the path of the middle of the track in a racing game)
My solution was to make a triangle, add an array modifier and a curve modifier (makes triangles along the curve)

Then in babylon, I had an avarage of every three vertice positions, and made a Ray downwards to the surface of the road to get the final point.
The curve (a BABYLON.Path3D) is shown here in white, the triangles exported are in red.

Exporting bezier curves as a Path3D would be prettier :)
Also there is no option to "ignore this object" setting in the exporter, so I have to edit the .babylon file with a JSON editor...
 

 

wow that sounds horrible! Thanks for the tip, but hopefully I can find a much simpler approach.

Share this post


Link to post
Share on other sites
8 hours ago, JCPalmer said:

Path3D class in Math.ts is not serializable, so it not possible to put it in a .babylon file.   Even if it were, I am not sure how well it lines up.  I think you will need to bake this.  Here is a .blend where this is done.  I did not make this test scene, but it might help you.  Gryff is no-longer with us, basically.

Thanks for that!

I've had a look at that and extrapolated what I needed to do (bake animations along a path).

Problem 1: If I only bake animations for one object, since it is following a path, the Z euler is updated to keep the object pointing in the correct direction. However after completing one full pass of the baked animation it looks like the object "unwinds", that is to say it spins on the spot 360 degrees and then continues to repeat the animation. It does this twice, and on the third pass simply keeps following the path like I expected it would in the first place. 

Problem 2: I actually have two simple animations in my scene, both using curves to generate movement along a path for two separate objects. Using animation baking I have baked the animations of each object and i can see both objects in the dope sheet as separate animation keyframe actions. Running the animation in Blender works fine, everything as you would expect. When i export to babylon however, both objects are combined in to one and they begin following the first path. When complete, both objects move to the position of the second object (as it was in blender) and start the second animation. 

Feels like I'm missing an important step or three here, and it is essential I get animations working smoothly for my 3d piece otherwise the whole thing will fail and I'll be in a world of pain. FYI to create the keyframes I first pick the object i want to animate (which is parented to the curve i want it to follow), then pick Object -> Animation -> Bake Action. From the bake sheet I sent frames 0-100 and checkbox the first 4 options. I've attached a grab to visualise this.

I've also attached the blend files if someone can take a look; test_scene is the scene before any animation baking so you can see the original setup. Test_scene2 is after baking the helicopter animation so you can see my process. I've also added both exported babylon scenes online so you can visualise my issues:

http://snou.to/tests/babylonjs/animation/test1/ - this is just the helicopter animating (problem 1)

http://snou.to/tests/babylonjs/animation/test2/ - this is both the helicopter and the ferris wheel (which is just a squashed sphere) animating. (problem 2)

I'm concerned babylon isn't going to do what I need it to do. I suppose I could always look to animate these things directly in babylon instead but it feels like a huge PITA compared to getting everything set up nicely in one place (blender) and exporting.

Would really appreciate any insight and help here. The example scene provided by @JCPalmer is great but without any context it's difficult to use as a teaching aid.

test_scene.blend

test_scene2.blend

test_scene.log

test_scene2_blend_and_Animating_object_along_a_curve_from_Blender__-_Questions___Answers_-_HTML5_Game_Devs_Forum_and_leesibbald_com.jpg

Edited by Snouto
Test feedback

Share this post


Link to post
Share on other sites

Slight update, I checked an additional animation option in the blender exporter "Only Current Assigned Actions" and surprisingly (to me) the helicopter and ferris wheel animations are now seperate and working... sorta...

Here's the latest version:

http://snou.to/tests/babylonjs/animation/test3/

The helicopter actually looks spot on, however for some reason or other the ferris wheel freaks out a couple times per cycle. If anyone can suggest what's going on there i'd appreciate being hit with the knowledge.

Cheers!

Share this post


Link to post
Share on other sites

Out of interest is it possible to create seperate baked animations such that some can be started automatically and others only when I want via JS code? It seems to me everything I bake ends up in the same timeline, which for the chopper and wheel is fine but there's going to be other situations where this is not desirable.

Share this post


Link to post
Share on other sites
5 hours ago, Snouto said:

Out of interest is it possible to create seperate baked animations such that some can be started automatically and others only when I want via JS code? It seems to me everything I bake ends up in the same timeline, which for the chopper and wheel is fine but there's going to be other situations where this is not desirable.

Look into multiple Blender actions, which get exported as separate-able BABYLON.AnimationRanges.  The caveats with this route are:

  • starting automatically is not really an option, so just start them yourself.
  • If multiple meshes participate in actions, you need to give each action a name in the pattern 'objName-actionName'

Share this post


Link to post
Share on other sites
8 hours ago, JCPalmer said:

Look into multiple Blender actions, which get exported as separate-able BABYLON.AnimationRanges.  The caveats with this route are:

  • starting automatically is not really an option, so just start them yourself.
  • If multiple meshes participate in actions, you need to give each action a name in the pattern 'objName-actionName'

Great thanks, so it looks like I need to go in to the dope editor then change to Action Editor, where I can then pick and choose different animations and create new ones. sweet. I still have no idea why the ferris wheel animation is spazzing out though, doesn't appear to be anything wrong in blender. 

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.