How can I export/convert an explosion as animated mesh?

I created an exploding mesh animation in blender (2.61) by using the Explode modifier. The animation looks just fine, but now I’m looking for a way to export this animation to use it in the Unity game-engine. When I export as FBX, the explosion doesn’t get exported, so I wondered if there’s a way to convert the simulation to a sequence of meshes which will then be my animation?

I tried different exporters/importers, but the only way that seems to work is to export the animation as sequence of obj files. But then I can’t find an option to import such a sequence of obj files back into blender…

So I guess my main question is: Is it possible to convert an animation like this to a “mesh animation” within blender? If not, is there a way to import a sequence of obj files into blender?

well, this is what I often do when I sometimes upset the user interface. I create a new file, make sure that my interface is the way I want it then fo to file>append, or shift+f1. Once you browse to the part of the file you want hit okay or enter. I hope it helps. I’ve often recovered my personalized UI or extracted one model from a group of models for study. I dont know much about games but perhaps the same thing applies.

@InsaneXade: Thanks for your reply, but it’s not an UI issue at all. I have an animation that uses modifiers. These modifiers distort (explode) the mesh and I’d like to get this animation exported. All exporters I tried just export my base-mesh and don’t apply the explosion effect at all. So therefore I’m looking for a way to either: Convert the animation to separate meshes in blender (one mesh per frame) or some way to import an OBJ sequence as an animation, because that seems to be the only way the animation gets exported properly (export as OBJ sequence that is).

well, I had assumed that since you can append anything from meshes to armatures that, it might apply to animations too. I have not gotten to the animation parts I just thought my suggestion might help. Have you opened the blend file from within your game blend and tried to import the object with the animation? I know when I append a model with a rig that it includes the rig. I appended just the male from so I could study it and he still had his rig, which I deleted because I wasnt ready to rig it my model yet and knew I could just reappend.

@InsaneXade: I think we’re talking about two different things. I don’t use any armatures… it’s a simulation (Explode). Also I want to export for Unity and not the blender game engine.

oh, sorry, thought I could help, I havent gotten that far. Try they have lots of things and the owners are very nice and knowledgable.

bummzack: I don’t know the status of the exporter for 2.5x/2.6x, but in earlier versions, physics sims like cloth could be exported to vertex keyframe animation (aka shape animation, aka morphs) in .mdd format. These could be re-imported into Blender as shape key sequences, which I’m sure Unity recognizes. Some engines permit direct import of .mdd as well. An avenue to explore, at least.

@chipmasque: I tried that (the MDD addon can be enabled in 2.61) but sadly this horribly garbles my mesh when I try to re-import. What I did: Export my animation to MDD, remove all modifiers/simulation from the base-mesh, tried to import/apply the exported MDD to said base-mesh. But as I said, the result wasn’t even close :frowning: I assume it’s because during the explosion some parts of the mesh disappear (when particles die) until there’s nothing left. As far as I understood, MDD assumes a constant vertex count over all frames, which might be exactly the root of the problem.

Yes, that sounds like a problem. I’m not familiar with Explode’s operation in detail, but for .mdd you do need a constant vertex count and a constant vertex index.

It may make the explosion other than what you want, but can you extend the particle lifetime to make sure none vanish during the .mdd export frame range? I’m assuming you’re using objects as particles. If that’s the case, I wonder why they disappear to begin with? Debris from an explosion scatters but doesn’t really vanish. I should look into the Explode modifier and see what’s what.

EDIT: Taking a look at Explode now, I’ll see what I can do with it. For my test, the debris isn’t vanishing(?) though the particles do. Instead, the debris stops its motion when the particles die.

After looking at how it works, I think the problem is that the individual mesh faces are apparently disconnected from one another during the explosion, creating the debris. This will also change the vertex count during the sim, making the .mdd option null. Not sure if there’s a workaround.

@chipmasque: Yeah, I know that that type of behavior (disappearing debris) isn’t really accurate, but I chose it for aesthetical reasons :). You can toggle that behavior using the “Dead” checkbox in the Explode modifier btw.

You’re right. The disconnected mesh parts is probably another reason why the MDD approach doesn’t work… This problem sounded so easy at the start (export explosion animation from blender to unity) and has turned into quite an obstacle. Right now I’m even trying to do something procedural in Unity (splitting the mesh into parts in code and animate them) as there’s apparently no easy way to get this working otherwise.

Just a small update based on some tests I did trying to get the MDD to shapekey pipeline worked out. Since it seems the Explode modifier separates faces from a mesh to create the “shrapnel” faces, I tried working around the vertex count change this would cause by actually separating the faces of my test cube from each other before setting up the Explode modifier. The idea is that the mesh would already have the proper vertex count, same as its “exploded” form.

The result I got was not a success but still enlightening, I think. Exporting the explode mesh to .mdd and then importing it as shape keys on a dupe, the animation was preserved in a weird sort of way. Portions of the duped cube fell away from the source cube in what appears to be the same pattern as the original, but at right angles, as if there is an axis-shift issue. But worse than that, the shrapnel faces were highly distorted. This would have been a total failure except that I’ve seen this kind of distortion before, in trying to create shape keys by copying then from one object to another using a script, in 2.49b. I found then that vertex count is not the only factor that must be matched between objects for shape-key copying – vertex order, i.e., their indexing in the mesh data, is also critical. When the indexing does not match, you get highly distorted versions of the shape keys, but the shape animation is preserved. What I surmise is happening is that the vertices are being translated according to the shape key data, but because they don’t have matching indices, the “wrong” vertices" are being translated by any particular data in the shape key set, leading to the distortion.

For the Explode modifier, getting similar results leads me to think that the faces used for the shrapnel are actually generated by the modifier as new faces, and the originals deleted in some fashion. This would result in a matching vertex count for originals with pre-separated faces, but the indexing would get slapped around pretty bad, leaving the shape key data to affect the wrong vertices when imported.

This is all speculation, of course, based on only a few empirical tests, but it does seem to indicate that a workaround isn’t something that’s just going to jump up and introduce itself in an “Aha!” moment.

@chipmasque Wow, thanks for examining this so thoroughly! I just performed a test with an object that has an armature and exported/imported that as MDD. It works, but it seems to flip to another handed coordinate system… resulting in a mesh that is rotated 90 degrees (around X) and all normals are flipped.

I just tried with pc2 export where you can specify the “up-axis” in the export settings. Using pc2 exports the armature animation correctly. There’s no import addon bundled with the normal blender release, but I downloaded the one from here: and it worked fine.

Since I already tried pc2 with the explode modifier (and it didn’t work), I guess you’re right about your assumption that the explode modifier shuffles vertex indices somehow…

@enzyme69: cool that there is a fix/workaround for this. A little arcane but that’s OK, magic is magic :wink:

One question about steps 3 & 4 – to what app are you importing the BASE Mesh OBJ file and the MDD data? Into Blender? Or Unity?

BTW, the ordering issue was just a surmise on my part, as I said, since it looked much like a similar issue with shape keys on different objects that I ran into earlier. Interesting that using an OBJ import seems to work around that, because importing the MDD as shapes on the original mesh in Blender leads to heavy distortion. I’ll give your idea a try with my test file, see what the result is.

Until “Meshcache Modifier” officially released (if ever), MDD and PC2 is pretty good.

One question about steps 3 & 4 – to what app are you importing the BASE Mesh OBJ file and the MDD data? Into Blender? Or Unity?

Back into Blender actually. But should not be problem if you import it into Unity, I supposed. Should I try?

BTW, the ordering issue was just a surmise on my part, as I said, since it looked much like a similar issue with shape keys on different objects that I ran into earlier. Interesting that using an OBJ import seems to work around that, because importing the MDD as shapes on the original mesh in Blender leads to heavy distortion. I’ll give your idea a try with my test file, see what the result is.

I didn’t know MDD can be imported as is into Blender, must give that a try :slight_smile: But normally for MDD, I will load the OBJ first and then import MDD (to be applied into that base mesh).

I should download Unity to test …

I’m not sure about getting the MDD data into Unity directly, I haven;t really tried much with that. The .mdd file from my tests was not directly recognized by Unity as an animation asset, though, but I’m fairly certain shapes from Blender would be.

It’s too late here in the U.S. to be starting experiments, but on the morrow I’ll give your OBJ/MDD pipeline a test, and if it works, then see how it fares as a Unity asset.

If you manage to get the mesh vertex animation working, please let me know. You use FBX right?

I have Unity here and it does not read Blend natively, so I use Blender FBX Exporter. The mesh got in, but the animation is not (?)

Do you use “Metamorph Animation Toolkit” or just simply export and import FBX?

I am checking this now…

Actually I’m brand new at trying this, but it seems that the path has already been well-blazed, so no sense re-inventing the wheel (how’s that for a pack o’ mixed metafers? :wink: ). MetaMorph seems to have identified and addressed all the relevant issues, so I’ll probably use it for the Blender -> Unity pipeline.

enzyme69 and chipmasque: You guys are awesome. Thanks for investing so much research effort into this. MetaMorph looks exactly like the thing that’s needed here, but I’m not able to get an explosion exported/imported as shape-keys. I tried with a simple cube (where I separated each side, so that the vertices aren’t connected). Both pc2 and MDD (even the updated version) failed at this. So chipmasques assumption about the explode modifier doing something wonky seems to be correct.

It works fine for a mesh that was animated with an armature… so I’m using the export/import correctly.

Initially I asked this question on the gamedev stackexchange site. I also posted a solution there, but it’s far from perfect. But if you ever need something like an explosion done in Unity, you might want to check it out:

Same here. I sort of working out export-import between 3D packages, but never really tried it on Unity or UDK until yesterday. Apparently joint animation is still preferable than blend shapes. I am surprised.

Might want to check this as well:

It’s a paid add-on for Unity, but looks solid.