Jump to content

Camera Animation - odd behaviour


Recommended Posts

JCPalmer asked me if I could create some Blender files that demonstrated specific features of babylon.js that he could use for his TOB project - including camera animation and multi-materials. This was relatively easy to do, but before I said I was finished, I wanted to test them with BJS.


Here is the original:


Camera Animation with multi-materials



As you can see objects pop in and out - and it is the objects with multi-materials (the 8 sided cylinders with 4 different colours, and the oblong boxes 2 materials, one with a texture).


With Babylon.1.13-beta.js it is now working fine - displaying the multi-material 8 sided cylinders and the oblong boxes with 2 materials and one one textured face. :)





So, my first thought was I had an issue with the multi-material objects, so I created a babylon file that had no multi-materials :


Camera Animation with no mulltimaterials


It works fine, no popping in and out - same animation, same objects but just one material on each object.


If you look at the javascript in the HTML file you will see that there is an animated cube that the camera is attached to. I can in Blender drive the camera animationdirectly, but that produces another issue which I can save for later.


Any thoughts on this multi-material issue?


Ohh and I'm using Blender 2.69, Babylon.1.12.js (downloaded last night),  Babylon.1.13-beta.js and the latest exporter.


cheers, gryff :)

Link to comment
Share on other sites

gryff:  Thanks!  Having these kind of regression testing blend files can be useful downstream, in BabylonJS itself, as well.  References to animation not related to bones is pretty sparse.  The only place I found it was in the actual code of the blender export script.  Having some tests at the ready to run thru before a new version goes to production is vital to have.


I am guessing from your note that you tried the direct camera animation in the man1 blend.  I am assuming, when it had some other issue, then you went to this new blend. right?  Sometimes issues only show when multiple things are taking place.  That's why I suggested all that stuff go into the one model.


Deltakosh:  That was quick.  I see 5 files have changed since yesterday.  Ignoring the two 1.13s, scene & babylonFileLoader were changed.  Have you pushed yet?



Link to comment
Share on other sites

Just diffed it.  The part of my python script where the Javascript class is being written for a mesh, I was only just setting a .useFlatShading property.  I missed this:

        if (mesh._shouldGenerateFlatShading) {            mesh.convertToFlatShadedMesh();            delete mesh._shouldGenerateFlatShading;        }

Are .useFlatShading & ._shouldGenerateFlatShading eqivalent?  Should I be adding this code?  See you moved computeWorldMatrix() to after the code above.  I was not even doing it at all.  Should I do it.  FYI, this python code is based on babylonFileLoeader to a great degree,  the resemblance is pretty noticeable.  The difference is all the branching is done in python.  There is not an if to be found in the .js other than to ensure things like materials or skeletons do not get loaded more than once.



Link to comment
Share on other sites

I am guessing from your note that you tried the direct camera animation in the man1 blend.  I am assuming, when it had some other issue, then you went to this new blend. right?


Not really Jeff. I started off with a new file just to see how doable it was with the Babylon system - export and running./loading the scene.


In addition, I knew that I was going to face an issue illustrated in the image below.


Now this is a simple example but it will illustrate the issue. In the scene there are two fans - both are animated but the animation lengths are different - 30 and 180 frames (see red boxes). Now if you export as a babylon file with the end box reading 180 then you get two animations in the file with the proper keys for frames except that the 30 frame animation ends like this:


and at the end of the 30 frame animation stuff you also get :


which will screw up the 30 frame animation - it won't loop until frame 180.


Now there are several workarounds 


1. Edit the babylon file manually - not useful to you.

2. Load the scene containing only one fan then import a mesh containing the other fan.

3. Create both animations on one timeline. Stop the animation on loading then get each mesh and animate them using the appropriate range on the single timeline for each fan.


While it is an issue that can be handled - it is to my way of thinking messy. Think of the walking man with some additional animations - say idle, run and jump. Do I want to add the camera animation to that timeline as I may decide later to add a punch and kick animation? And if the scene changes, do I want this guy burdened with the camera animation when no such animation is called for?


To my way of thinking it would be nice to have the autoAnimateTo to be based on the last frame in the animation (frame 30 in this case ) and not calculate a value for frame 180.


So those were my thoughts that led to the way I approached creating a camera animation.


cheers, gryff :)





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.

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.


  • Recently Browsing   0 members

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