timetocode Posted August 20, 2018 Share Posted August 20, 2018 How do I play animations created in the blender action editor? I'm trying to organize walk, run, idle, etc animations and start/stop them by name. Also is there a particularly good way to import the blender objects that don't have any world position when the game begins? I noticed there are many different ways to load things. Objects in this game are spawned in after a receiving a network message, so there's no pre-existing concept of a scene (or my brain just isn't used to thinking about scenes). Even the terrain itself is chosen by the server. Which loading strategy should I employ? Blender scene: Action editor from under the dopesheet: Loading and positioning the character (exported with blender/babylon exporter 5.6.4): BABYLON.SceneLoader.LoadAssetContainer("./", "blocky.babylon", this.scene, function (container) { console.log('CONTAINER', container) var meshes = container.meshes var materials = container.materials // manually position the object somewhere that i can see it when the game starts up let whatever = meshes[0] whatever.position.y = 21 whatever.position.z = 4 container.addAllToScene() // can i just get rid of this somehow? // would prefer something like scene.add(new BlockyEntity()), executed later }) When inspecting the loaded `container` object, none of the animations arrays are populated. There does appear to be a `container.skeletons[0]._ranges` that has properties that match the names of my animations (crazy, walk, walkdss, etc). I'm not sure how to play them. Here is the character (appears to be hovering on the last frame of one of one of the animations? or maybe this is just the pose it is in in blender not sure) Thanks Quote Link to comment Share on other sites More sharing options...
brianzinn Posted August 20, 2018 Share Posted August 20, 2018 1 hour ago, timetocode said: There does appear to be a `container.skeletons[0]._ranges` that has properties that match the names of my animations (crazy, walk, walkdss, etc). I'm not sure how to play them. Have you tried this? scene.beginAnimation(container.skeletons[0], 0, 100, true, 0.8); There's a bunch of info on this page, too: https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons Quote Link to comment Share on other sites More sharing options...
timetocode Posted August 21, 2018 Author Share Posted August 21, 2018 Thanks that got things moving, which is a big improvement. My animation however looks very different. Any idea what settings I'm missing? In Blender: In Babylon: Quote Link to comment Share on other sites More sharing options...
brianzinn Posted August 21, 2018 Share Posted August 21, 2018 I wish I could help - I have never made 3D rigs. Somebody will chime in for sure, but if you can share your blend/model would probably help the most. Quote Link to comment Share on other sites More sharing options...
timetocode Posted August 21, 2018 Author Share Posted August 21, 2018 Looks like it has something to do with applying transforms. I went into object mode and hit Ctrl + A and then "applied" transforms for location, rotation, and scale. I have no idea what that does... or rather I know that it sets the xyz, scale and rotation to 0, but I don't know what the implication is. The end result for me is pretty much scrambled (like even the original is a mess now). HOWEVER, i think they now look the same between blender and babylon.js. So I think this is part of the equation of how to get these things working. Presumably there was a way to do this that didn't scramble the model. The mesh+rig I was testing is a freely available "Minecraft Simple Rig" that comes from https://sites.google.com/view/boxscape-studios . Perhaps someone could shine some light on how to make a rig+model from scratch that plays nicely with bablyon, or how to convert an existing mesh+rig+animation. (Maybe I just applied one transform too many..) I'm going to be making these things from scratch anyways, so even if the answer is a lot of work, I'd like to know. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 21, 2018 Share Posted August 21, 2018 I bet @JCPalmer could help with that he is a blender master. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted August 21, 2018 Share Posted August 21, 2018 First, none of your attachments equals an export log file. 2nd, the exporter does nothing with NLA tracks. It only exports actions. You have the choice of exporting either the currently assigned action of every object that has one assigned, or all actions to every object which has a currently assigned action. Things get a little messy when doing the later with multiple objects with an action. In that case, if a certain action only applies to one of the objects, then use the name pattern 'object name-action' to isolate that action in the export to only one object. 3rd, babylonJS only supports one animation (though it can be against multiple properties). When actions are exported, they are all contained in that one babylonJS animation. There are some frame gaps between them for sanity purposes, but when exporting more than one action, you cannot just run all the frames of the scene or even the object. You, however, also do not need to know the range of frames where everything gets put. You can start each BABYLON.AnimationRange by name, which is also the action name. skeleton = scene.getSkeletonByName("bonesCharacter"); skeleton.beginAnimation("Walk"); You could also have other problems, but making these adjustments & checking what is actually happening in the log file is start. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 21, 2018 Share Posted August 21, 2018 Thanks @JCPalmer ? Quote Link to comment Share on other sites More sharing options...
timetocode Posted August 21, 2018 Author Share Posted August 21, 2018 Thanks, that fixed everything! It looks like the mesh and rig itself had been made in a way where a scale transform on the bones had not been applied, and applying it scrambled the whole thing. So I've now made a few custom meshes (essentially just chains of bones and cubes) with transforms applied, and I can certainly play the test animations by name. I have a follow-up question regarding rotations that preserve volume, but I'll make a new topic for that. Edit: new thread 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.