Snouto Posted January 4, 2018 Share Posted January 4, 2018 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 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 4, 2018 Share Posted January 4, 2018 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2018 Share Posted January 4, 2018 Hey! Did you try to import it in Blender? we have a pretty robust exporter to babylon there (including animation) Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 4, 2018 Author Share Posted January 4, 2018 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2018 Share Posted January 5, 2018 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 Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 5, 2018 Share Posted January 5, 2018 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 5, 2018 Share Posted January 5, 2018 LOL Just because of you: https://github.com/BabylonJS/Exporters/issues/56 Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 8, 2018 Author Share Posted January 8, 2018 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 8, 2018 Share Posted January 8, 2018 Pinging our experts: @JCPalmer and @gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 9, 2018 Share Posted January 9, 2018 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(); }); Snouto 1 Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 9, 2018 Author Share Posted January 9, 2018 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2018 Share Posted January 10, 2018 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) Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 10, 2018 Author Share Posted January 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 11, 2018 Share Posted January 11, 2018 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. GameMonetize and Snouto 1 1 Quote Link to comment Share on other sites More sharing options...
Snouto Posted January 11, 2018 Author Share Posted January 11, 2018 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 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.