amorgan Posted January 29, 2015 Share Posted January 29, 2015 Hey All, pretty much going full out on using Blender for animations. But I am having some more troubles. 1) I now have two meshes (in one file), the first mesh animates as it is supposed to, but the second (sword) mesh does not follow. What is the correct way to import this in so that they associate together correctly. Do I set the sword as a parent (which I am doing)? or how do I get them to move together, etc. In addition to animate correctly. 2) How do I import multiple animations? I have tried to google and look up videos on how to do it (which come up for Unity) and what not by using the Action Manager and making them attach to a fake user, but still only one imports into Babylon. Thanks! I Haven't found any tutorials in depth about this. So once if I figure out this, I would like to make one.Blender.zip Quote Link to comment Share on other sites More sharing options...
amorgan Posted January 29, 2015 Author Share Posted January 29, 2015 Looking through the Blender to Babylon Exporter ( https://github.com/BabylonJS/Babylon.js/blob/master/Exporters/Blender/io_export_babylon.py ), I don't see any code that seems to be getting multiple animations or multiple meshes for one bone. Not really knowing much about it, it at least didn't jump out to me. So I'm not sure if this is supported yet, which would be limiting. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 29, 2015 Share Posted January 29, 2015 Skeletons (armatures in Blender) are separated from Meshes on both systems. Exporter assigns each mesh that is parented to a armature, a skeleton id. See no reason why that skeleton id could not be the same. Looked at your .babylon. Only "Body" is assigned a skeletonId. Do not even see a mesh named "sword". A skeleton only has one animation exported, though animations is an array in Babylon.Bone. You can specify a start - end frame, so you could make a combined animation in Blender, & call them as 2, with different frame ranges. Meshes can also export position, rotation, & scaling animations from Blender. You can have multiples. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 29, 2015 Share Posted January 29, 2015 I'm not a Blender guru but as far as exporter is concerned, we are only exporting one animation track per mesh Quote Link to comment Share on other sites More sharing options...
gryff Posted January 29, 2015 Share Posted January 29, 2015 I now have two meshes (in one file), the first mesh animates as it is supposed to, but the second (sword) mesh does not follow. Afternoon amorgan This, I assume is what you are getting: Figure and Sword 1 And this is what you want: Figure and Sword 2 Your problem lies in the fact that you have parented the sword to the armature and not the hand bone. In my next post I will write up a method to fix it. cheers, gryff PS: One of those days from hell - can't go 5 minutes without something comes up amorgan 1 Quote Link to comment Share on other sites More sharing options...
amorgan Posted January 29, 2015 Author Share Posted January 29, 2015 Thanks for the replies! Gryff you hit on the head with my first question, I will test it when I get home, but I don't have any doubts there. Also, not good to hear about your day, hope it gets better! As far as the other question about multiple animations, I was afraid that was the answer. So I can definitely do that, put multiple animations on one track, but that gets very clunky if I need to modify frames with multiple animations. The Action Manager system that blender has is very nice for handling this issue. Which searching, Unity seems to be doing this, so it seems it's at least possible from some aspect. Is there anyway for someone to look into this? Using the Actions Manager seems like a much more elegant solution as one expands out and maintainability. I have a work around for now. My plan would be to use the Action Manager to combine and manipulate the actions/animations, then one that is just all of them combined. Not ideal, but will probably be the best way to do it for now. Thanks again! Edit: Doing animations this way will also allow me to easily convert my model so that if the exporter does use actions in the future, it will be easy peasy. Quote Link to comment Share on other sites More sharing options...
gryff Posted January 29, 2015 Share Posted January 29, 2015 Ok amorgan here is how to fix you sword animation: 1. Click on the armature and put it in the "Rest Position"2. In the "Outliner Panel" hide the "body" mesh. Not essential but makes it less likely you click on the wrong item in the following steps.3. Click on the "sword" (Cube) in the 3D window then ALT + P ->Clear Parent. The "sword" (Cube) is no longer attached to the armature.4. Click on "sword: in the 3D window now Shift + click on the bone for the right hand. The Ctrl + P ->Automatic weights. The "sword" should now be a child of the armature again. (If at this point you but the armature back in to "Pose Position" and exported as a .babylon file - you would really see a magic sword ) 5. Select the "sword" and go into Edit Mode and Select All the vertices. Over in the Properties Panel chose the tab with the triangle then look for vertex groups and find and highlight the "hand.R" vertex group and with all the vertices of the sword selected, click the assign button. Exit Edit Mode.6.Unhide the body mesh.7. Put the armature into Pose Position and export to a .babylon file. And unless I have left a step out - you should have your little guy marching along with a sword. cheers, gryff amorgan 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 29, 2015 Share Posted January 29, 2015 OMG, Gryff your knowledge is invaluable! amorgan 1 Quote Link to comment Share on other sites More sharing options...
amorgan Posted January 30, 2015 Author Share Posted January 30, 2015 Awesome! Gryff that worked. Looks like before I just bound the sword to the bone and not armature (though that is the opposite of what you said haha). Also I was able to combine my animations into a single track called All and just copied them over. If I get some time this weekend I will try to make a tutorial showing what I learned here, since I don't believe any exist for this specific topic. Two things further: 1) The bounding boxes do not seem to translate with the animation? 2) Can I not set a mesh as a parent, if itself has a parent? For example mesh2.parent = mesh1;mesh3.parent = mesh2; When I do this mesh3. does not translate with mesh 2? Quote Link to comment Share on other sites More sharing options...
gryff Posted January 30, 2015 Share Posted January 30, 2015 Glad it worked amorgan - I'm always afraid I will leave out a step or take one for granted. Looks like before I just bound the sword to the bone and not armature (though that is the opposite of what you said haha) Not sure why you think that. What bone did you think you parented it to? I could not find a connection to any bone. If I tried to weight paint it - rather than give me a bone to paint - it gives me the whole armature.Perhaps I should have said the it was parented to the object you have named "Skeleton" As for the "two further things": 1) The bounding boxes do not seem to translate with the animation? As far as I know that is correct. Try this example: Desk and Book Click to the left of the closed book - the book opens!. This is because the book mesh was created as an open book (easier to rig) - so its bounding box is for the open book. That was made with BJS v1.12 - things may have changed since then. When you animate an object with a rig you are rotating various groups of vertices of that object with each bone not the object itself. Think about this example: You attach an object to the hand bone just like you did the sword - a gauntlet - and it moves happily with the animation. Now you try to parent the sword to the gauntlet withsword.parent = gauntlet;In the animation, the vertices of the object are being changed not the position of the object itself - the bounding box is still the same - so the sword does not move with the animation. So when rigging you must attach each object to the appropriate bones - so for a backpack, use the spine bones. That is how I understand the animation process in BJS - now it is based on an older version 1.12. Maybe the code experts can explain it in a better way cheers, gryff amorgan 1 Quote Link to comment Share on other sites More sharing options...
amorgan Posted January 30, 2015 Author Share Posted January 30, 2015 Ahhhh. That makes sense. Understood now. And of course I answered my parenting question by actually testing it in the playground, you can parent a mesh who has a parent! Haha. My issues stemmed from Gryff's point and the fact I was parenting to an object that was being manipulated by the bones. Hmm. I will have to think about how I will achieve what I want. So I was using the just the sword as a collision object with OnIntersectEnter, but I was using native animations and actually rotating/moving the sword itself. Now that I'm using bones and only animating the vertices I understand why the bounding box does not move. I will have to think about how to change this. I was using this for detecting if I hit an enemy. I could do a more rudimentary scheme like check for distances or using more of a spherical collision mesh for attacking distance and assign variables such as Attacking, Blocking, Idle and based off of that determine if a "hit" was successful. I was hoping to get a little more "physical" with this and use the actual weapon meshes colliding with an enemy mesh. I'll see what I can come up with. Quote Link to comment Share on other sites More sharing options...
gryff Posted January 30, 2015 Share Posted January 30, 2015 I was hoping to get a little more "physical" with this and use the actual weapon meshes colliding with an enemy mesh. I'll see what I can come up with. Perhaps you should start a new thread just on the coding aspect of objects that are part of rigs colliding in some way during rig animation with other objects. Basically it is not a Blender problem - rather a coding issue What I wrote above is just the way I see things - maybe coders will have a different take on the issue and have a solution. It is an interesting little problem though. I had been thinking you wanted to have a sword in a stone which when clicked could be added to the rig - guess that is a different problem. Will watch the threads - as it is something I might find useful. cheers, gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 30, 2015 Share Posted January 30, 2015 As far as the other question about multiple animations, I was afraid that was the answer. So I can definitely do that, put multiple animations on one track, but that gets very clunky if I need to modify frames with multiple animations. The Action Manager system that blender has is very nice for handling this issue. Which searching, Unity seems to be doing this, so it seems it's at least possible from some aspect. Think there is a way to use the current "single track" bone animation that is both easy to maintain and efficient. Thing to remember is that an animation is not an array of Frames from 0 to the highest frame in Babylon (& probably Blender). An animation is an array of frame records, each with a frame # field. You can then have a single animation where there are multiple tracks starting at predictable places, like: 0, 500, 1000,...,5000. I think you can specify start and stop frames in Babylon that do not actually exist. This would allow for code like this:var MAX_TRACK_SIZE = 500;public playTrack(scene : BABYLON.Scene, skeleton : BABYLON.Skeleton, track = 0){ scene.beginAnimation(skeleton, track * MAX_TRACK_SIZE, (++track * MAX_TRACK_SIZE) - 1);}If the first animation is 57 frames, and you need to add 3 more, there is no need to change the Javascript call. Never tried this, but think it will work. Playing the whole thing in Blender might look stupid, but so what? Adding every feature has a development / maintenance cost. The maintenance cost could be higher than you think, because Blender can change on you. Better to treat Blender as BabylonJS's bitch. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
wikiwiggs Posted February 4, 2015 Share Posted February 4, 2015 As far as your multiple animations go, I believe that you may be able to live with what you can actually get out of blender.I'm not sure how much you have used the NLA editor, but that allows you to manage and combine animation sequences.Specifically in the context of armature animation, you can first use the Dopesheet to define (record) different actions. The quick tutorial on this is to do the following:1. put your armature in pose mode2. set your main timeline keying set to LocRotScale, or LocRot, depends on the complexity of the armature rig.3. split your screen (Dopesheet editor one side, 3D view the other).4. set mode dropdown to Action in the Dopesheet view.5. in the next dropdown this is where you store your different pose actions. a. I recommend your first one being your rest pose, so you can always have a good starting point. b. but at least create a new action even if you disagree with me.6. turn on the properties panel on the 3D view if it is not on already (press N on the keyboard to toggle it).7. begin posing each frame as you normally would, except instead of adding keyframes to the main timeline: a. in the properties panel go through each of the Location (x, y, z) and Rotation fields (x, y, z) and hit the i key. b. over in your dopesheet view, you should start seeing the keyframes popping up.8. after you are done, you can use the NLA editor to sequence these actions in the main timeline.9. Then you can do what these guys are saying regarding managing the timeline at different time ranges. a. This might not be the most desirable, but at least you can manage it according to context this way. i. for example, you may want your first action to be "whistling", and your second action to be "walking", ii. well now based on game properties, you can set the time such as frames 1-10 = whistling, 15-35 = walking, 40-60 = walking+whistling, etc... iii. Then you can almost use a property bit flag to get all possible scenarios and call the proper frame range. b. The cool part is, is that you can still manage all of this in Blender, and get one big timeline in BabylonJS, without having to rewrite/repose the same actions each time. I'd like to share some blend files for you, but I can't seem to figure out how to attach them. Anyway, I hope this added value to your pursuit. Kind Regards 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.