OpenGL Animation: Skeletal and Morph Target

Tags

, , , , , , , , , , , , ,

Crack nuts. Then add some Skeletal Animation.

In my post Blender animation: skin modifier I built a seahorse in Blender with a surface and armature. And I added an animation timeline, with keyframes of the seahorse’s bones in different poses.

My next job was to export the seahorse from Blender as a collada file, and import it into my C++ virtual reality engine (with OpenGL graphics library and the Oculus SDK for Windows) using Assimp. I could then investigate how best to animate it in a virtual world, similar to how I brought to life the skeletal cowboy.

Turned out to be fairly straightforward. Pressing Alt + C in Blender turned the surface into a mesh with normals. Ctrl + P then set the parent of the mesh to the armature with automatic weights. I also had to move the first keyframe from position 1 to 0 on the animation timeline, as my engine was blowing up with a previous and next frame interpolation on the same frame.

Here’s a video of the animated seahorse, with a nice green colour applied:

Even though the seahorse is low poly, its squirming movements are eerie and unnerving. I throw off the Oculus Rift virtual reality headset and run upstairs to cry in a bath.

Once composed, I return to my PC and add some more animation. This time, Morph Target Animation.

In my post OpenGL Morph Target Animation with C++ I exported a cube and a deformed cube from Blender into my VR engine and interpolated between them, thus morphing the cube into a squished shape.

But it turns out that Blender can create deformed meshes through the use of Shape Keys. Simply add a Basis and Key of the mesh, and deform the Key to your heart’s content. You’ll then be able to slide the value of the Key from 0 to 1 and witness the mesh morphing into some hideous deformation.

I export my Shape Key cube and its deformed target from Blender as before, making sure the Triangulate Faces option for each .obj file is not selected (otherwise the morphing animation will exhibit gaps). Assimp will import the .obj files into my VR engine with the aiProcess_Triangulate flag set.

Here’s a video of the animated cube:

The cube crushing like a sponge put me on edge, and I scuttled into the kitchen to blubber by the electric hob.

Ciao!

Advertisements