Jump to content

[Solved] Animations in models


Snouto
 Share

Recommended Posts

Hi

I'm wondering if there's a particular technique I need to follow in order to import a model and its animations? I have an FBX that I know has an animation inside, and I have tried loading directly, by converting to an OBJ via Cheetah, and by importing to a Unity scene and then exporting to a .babylon file. No approach has worked. 

Directly via FBX or OBJ:

BABYLON.SceneLoader.ImportMesh("spider", "model/", "spideranimated.obj", scene, function (meshes) { 
});


When I say "no approach has worked" what I mean is that, by tracing out the meshes and looking at the animation object they're always empty. Should I be looking somewhere else?

Model attached for reference.

Cheers

SpiderAnimated.fbx

Link to comment
Share on other sites

Hiya Snouto, and welcome.  Sorry for the slow replies, especially for your Unity GameObject questions.  Be patient, if possible.

http://www.html5gamedevs.com/search/?&q="fbx file"&type=forums_topic&nodes=16,28,29,30,31

There's a forum search for FBX.  It returns quite a pile of results.

I only read 1-2 of them, but this one seemed somewhat pertinent.  I hope it helps.

I wish I had more experience with this issue.  Perhaps others will comment soon.  Stay tuned.  :)

Link to comment
Share on other sites

Thanks guys. @Deltakosh I've noticed many of the help articles refer to exporting from Blender. I haven't tried this yet because the last time I tried to understand the awful UI of blender my eyes exploded. I'll give it another go though, even if just to prove the process works. Is there a recommended path coming from Cinema4D? Presumably export to FBX and then bring in to Blender; there's no exported for Cinema4D is there?

Link to comment
Share on other sites

3 hours ago, Deltakosh said:

I know that a lot of people will appreciate exporting from Cinema4D and I plan to support it this year (probably early June)

My god... I would be more then appreciative.  Like drive up to Seattle to buy you a beer appreciative.

Link to comment
Share on other sites

On 06/01/2018 at 4:59 AM, Deltakosh said:

Correct

I know that a lot of people will appreciate exporting from Cinema4D and I plan to support it this year (probably early June)

In the meantime using FBX to go to Blender seems the best option

Okay so I've just tried exporting from Blender. I fired up blender, spent about 5 minutes watching my eyes bleed at the awful UI, then deleted the cube Blender creates for no good reason before importing the Spider FBX I included in my OP. Even without changing anything else, I went to the BJS exporter and tried to export. Tried this twice but both times Blender just hung. It does create a log file, but that remains at zero bytes so I'm guessing the hang is caused almost immediately.  

So I decided to try the attached ant model. Initially I get an error when exporting because of some rotations, so after resetting those and exporting I got a babylon file produced. Hurray, I thought! I loaded this in to BJS and indeed can see the ant model, however there's no obvious way to try the animations. Tracing out the model shows animations property as being empty. Would someone be kind enough to check the model and see if there's something untoward going on? It's likely just my inexperience of Blender, and I can see that the rotation resetting screws the appearance of the model in Blender, but right now I'm just trying to a) prove animations can be created and exported from Blender, and b ) I can load in to BJS and animate in my scene.

Running on a late 2013 MBP 15", High Sierra 10.13.2, Blender 2.7.9, BJS Exporter 5.5

ant.babylon

AntWarriorAnimations.fbx

Link to comment
Share on other sites

I usually prefer a .log file to a .babylon file.  I do not even the acknowledge the existence of .fbx.  (Not my problem to work out every bodies workflow).

From my standpoint it worked.  An animation range, 'Armature.001' was created:

,"ranges":[{"name":"Armature.001|Armature|ArmatureAction|Armature|ArmatureAction","from":0,"to":246}]}],

Since there is only one range, you could start it as a range, or just give start & stop of 0 to 246.

FYI, this .babylon already has a camera & light, so you do not need to do an ImportMesh, unless the light or camera is pointer wrong.  Use Append something like this:

var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);

var scene = new BABYLON.Scene(engine);
var url = "./"; 
        
BABYLON.SceneLoader.loggingLevel = BABYLON.SceneLoader.DETAILED_LOGGING;
BABYLON.SceneLoader.Append(url, "ant.babylon", scene);
scene.executeWhenReady(function () {
    var skeleton = scene.getSkeletonByName("Armature.001");
    skeleton.beginAnimation("Armature.001");
            
    // Attach camera to canvas inputs
    scene.activeCamera.attachControl(canvas);

    // Once the scene is loaded, register a render loop
    engine.runRenderLoop(function() {
        scene.render();
    });
});


//Resize
window.addEventListener("resize", function () {
    engine.resize();
});

 

Link to comment
Share on other sites

thanks for that excellent reply @JCPalmer - I always knew there would be a way to get the model's camera and animations but couldnt quite get to that point, and your example code will surely help me there.

I've attached the .log file for prosperity should it be looked at by other people in the future. Hi, future people!

One note: I took your code and slapped it in to my test page, but whilst the ant itself loaded it did not animate. I have a strong feeling that's caused by me having to reset rotations on the model so that the BJS exporter would work, but in doing so made the model itself in one orientation whilst the linkage was in another. At least that's how it looked in blender; only difference to the BJS scene and blender is that the ant would still animate in Blender. I'll hunt down a better animated model. This is all just to prove the point that animations in an FBX can work, because ultimately we'll be modelling in C4D, exporting to Blender via FBX, then onwards to BJS.

One finally question - are there any negative consequences to BJS when it can't read a model's manifest file - for example, if it doesn't exist? I see the error trace in the console but other than that - to  me - everything else seems fine.

ant.log

Link to comment
Share on other sites

5 hours ago, Deltakosh said:

Hello the manifest is only used to detect if you want to store your assets in the local indexed DB so there is no problem to see this line

(you can turn it off completely with engine.enableOfflineSupport = false)

Okay so are you saying by default BJS will save assets to the HTML5 LocalStore (or similar) so that they are available when the page does not have an internet connection? That's pretty cool

Link to comment
Share on other sites

  • Snouto changed the title to [Solved] Animations in models

After looking at your .log file, my code for the name of the action was not quite right (.log files are easier to read), so that is why it did not animate. change

 skeleton.beginAnimation("Armature.001");

to

 skeleton.beginAnimation("Armature.001|Armature|ArmatureAction|Armature|ArmatureAction");

I do not know if this name results from the .fbx or the Blender .fbx importer.

Link to comment
Share on other sites

7 hours ago, JCPalmer said:

I do not know if this name results from the .fbx or the Blender .fbx importer.

Yep that got it moving, nice one thanks! God knows where that name comes from, but it's not as important as seeing the end result working. cheers

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...