Some people complained that morph animations were very hard to do, so I thought I'd share a way to create morph animations from rigged ones that I sort of stumbled upon during my searches through forums and tutorials. I didn't actually find tutorials on how to do this whole process--just bits and pieces of information that I pasted together and experimented with. So this is my own way of doing it, and it's somewhat rough. Anyone who knows how to do it better, please correct me if you want! If this is already common knowledge, then this might come in handy for people new to Blender.
I tried to do a walk cycle without using a rig--just manipulating the vertices--and I realized that it would take one hundred years for me to do it. Then I had the thought that maybe I could somehow capture rigged poses with Blender's shape keys and paste them into an animation timeline. Sure enough, it's possible, but there are a few tricks to doing it fairly fast and well. And there's also the question of how to do multiple morph animations in a single .json file, add more animations to the same file as you need them, and rename them as separate animations so that they can be called and tweened in Q3D. I might talk about how to do that in another post, because I'm still trying to figure out how to simplify that process. I've been able to do it so far, mostly by copying and pasting animations from one .json file into another, but it's a tedious and sometimes confusing process. For now I'll just concentrate on a single morph animation, with a suggestion for how to do multiple ones in a single file later in this post.
It turns out that the morph animations run pretty smoothly and well in Q3D and, as QuaziGNRLnose has said, they are less costly for the hard drive to handle. So far it's working so well that I've decided to make my scenes as boneless as possible.
Here's how to do it:
1. First create your model, rig and skeletal animation as you normally would.
2. Save your original skeletal anim file (you wouldn't want to lose it) and do a "save as" to create a separate morph animation file using the same model.
3. While you're in Object Mode, count the number of poses in your animation cycle (not including the first pose), select both the model and its skeleton, and use shift + D to duplicate the model that many times. If your last pose is the same as the first--as in a walk cycle--don't count the last one either. For instance, if you have nine poses in your walk cycle, create 7 clones of the model. In the case of the walk cycle I just mentioned, you should now have 8 identical models. Place them in a row, next to each other, from left to right. You're going to be using the first model (the one you cloned from) as the final, boneless, morph animation model, while you're going to use the other models for capturing each pose and transferring the pose to the first model. It's important that you keep that model in its original centered spot. I made the mistake of using one of the cloned models as the final one (not centered in the Blender 3D view), and the exported version was off-center in Q3D.
4. Start with your first (original) model. We'll call this model 1. Select model 1 (not its skeleton) in Object Mode and set the timeline to the first frame, the first pose. This pose will be the Shape Key "basis" for all of the shape keys that you will create. Once the model is in this pose, open the Modifier window (click the wrench icon in the Properties window), and the first thing you will see is the Armature Modifier. Click Apply to capture the first pose, and the Armature Modifier disappears.
5. While still in Object Mode, select model 1's skeleton (only) and then switch to Edit Mode. Press X to delete the bones.
6. Now we're going to create model 1's first Shape Key: Switch back to Object Mode and select model 1. Open the Data window by clicking the vertex triangle icon (next to the wrench). Scroll down to the Shape Key section and click the plus sign (the add button) to create the first Shape Key, which is named "Basis" by default.
7. Now proceed to the second model in line. This model will represent and capture the second pose in the timeline, and will be used to transfer that pose--as a Shape Key--to model 1. Select model 2 (not its skeleton) in Object Mode and set the timeline to the second pose. As you did in #4 above, open the Modifier window and apply the the Armature Modifier.
8. Repeat what you did in #5 to delete the bones of model 2.
9. Repeat what you did in #6 to create model 2's first Shape Key, which will also be named "Basis." You don't have to change the name of this key.
10. Keeping model 2 selected in Object Mode, select model 1. In model 1's Shape Key window, click the dark triangle button underneath the add and subtract buttons. (I think you can also press W) to bring up the Specials list. Select "Join as Shapes." This will automatically transfer model 2's Shape Key to model 1. You don't have to rename this key either.
You can test whether or not the transfer worked by selecting only model 1 and switching to Edit Mode. Click on the Basis key and the new key, and you should see the model switch from pose to pose. You can also switch to Object Mode and use the "value" slider underneath the Shape Keys to shift from 0 to 1, to see model 1 morph from the basis pose to the second pose. 0 always references the basis pose, while 1 references the target pose for that particular Shape Key.
11. Repeat #'s 7 through 10 for each of the models, capturing each pose as they're arranged on the timeline and transferring each, as Shape Keys, to model 1. Test each Shape Key, just in case.
12. Once you're finished with all the models, delete all of them except for model 1.
13, Switch from Action Editor to Shape Key Editor. Create and name a new animation by clicking the add button in the field next to "summary." You will see that the timeline is divided into one channel per pose, not including the first pose (or the last pose, if it's the same as the first). Why the first (or last) pose wasn't included confused me at first, but the reason became clear after I stumbled through the recording process--as you will also see in the next step:
14. To record the first pose, the Basis, set the timeline at frame 1, set all of the channels at 0, click Key, select Insert Keyframes, and select All Channels. Setting 0 in all channels is exactly the same as setting and recording the first pose--which is why a first pose channel is unnecessary. If the last pose is the same as the first, repeat this process for the last frame of your animation.
15. For the second pose, set the timeline at whatever the next frame is going to be, set channel 1 at 1, and set all of the other channels at 0. Record the keyframes for all channels as you did in #14. For the third pose, move the timeline to the next frame, set only channel 2 at 1 and all the others at 0. Record. For the fourth pose, move the timeline to the next frame, set only channel 3 at 1 and all the others at 0. Do this for all of the poses (except, of course, for the last pose if it's the same as the first).
16. Make sure that you save often as you go through this process, and save the model when its animation is finished. Now you can export the model, choosing the three.js exporter (File>Export>Three.js). Here's how I set up the export page. I don't exactly know if this part is correct, but it works in Q3D:
I checked Vertices, Faces, Normals, UVs (but not bones or skinning)
I checked FaceMaterials and Vertex Colors.
I checked Morph Animation and kept Skeletal Animations off
I'm not sure if it's necessary, but I checked Frame Index As Time and Embed Animation
I didn't check any of the Scene boxes.
For Settings, I checked Textures and Copy Textures, and I kept Enable Precision checked.
Within your Construct 2 project, import the .json file into your Files file in the Projects window. Double-click the newly imported .json to open it in Notepad or Wordpad (or whatever program it opens into) and change the name of your animation to what you want by doing the following. I use Notepad, so I'm not sure how this is done in Wordpad:
1. Click Edit>Replace. In the Find What field, enter "animation_". In the Replace With field, enter "walk" or whatever name you choose. Then click "Replace All."
4. Save the file.
That's it! The animation is renamed.
For multiple animations in a single file, so far I have created separate .json files of the same model with single animations in each of them. I just renamed and copied the animation part of each file and pasted it into the original model/morph animation file within Construct 2. That sounds straightforward enough, but it's somewhat tedious, because the files are so large. It's a little tricky selecting such a large portion of the script, because you have to know where the animation portion begins and ends. I marked the beginning and end of that section by creating a large gap between it and the rest of the script.
What I haven't tried yet is to place all of the morph animations on a single timeline. That would work, I think, but you'd have to know where each animation begins and ends, and go through a more complex renaming process. Also, I'm not sure if each separate animation has to begin with the 000000 frame or not???
Then there's something I just started exploring (but haven't figured out yet), and that's how to parent objects to this boneless mesh so that you can have your character carry things, wear helmets, etc. I know that in Blender you can attach a single bone to a single vertex while still preserving the morph animation--and I was able to do that--but I don't know if it's possible to parent an object to that bone. Is that hierarchy preserved in the .json file? I remember QuaziGNRLnose mentioning something about that somewhere--I think....
Another thing I wondered about is the huge .json file size. Does that hurt the game's performance? Is skeletal animation the better choice? I know that QuaziGNRLnose said that skeletal animation is more costly to performance, but is that still true in version 2.4?
Thanks for reading!