Home       About Me       Contact       Downloads       Part 61    Part 63   

Part 62: Character Animation

August 30, 2012

To implement my Avatar class, I'm reading through Game Engine Architecture by Jason Gregory. It has a good chapter on Character Animation. It's all more complicated and sophisticated than I need if my avatars are made of cubes, but there are things there I can use.

He advocates using Quaternions for all the rotation specifications. I've heard of them over the years, but never used them for anything. I wasn't sold initially, since using ordinary transform matricies works fine. But there was a comment that you can do smooth interpolation between any two positions. I can see the advantage of this in animation, as well as other parts of my code.

For example, in the current SeaOfMemes demo, you can hit "L" when near an object to transition from the "space" coordinate system to the planet, ring, etc. coordinate system. I never got that to work correctly, and interpolation was the problem. So I implemented the Quaternion methods he lists and played with it a bit. It seems to work! I'll go back and try fixing SeaOfMemes at some point.

The book also talks about animation "clips", which move some portion of the skeleton through a sequence. It looked like I'd need a lot of UI and infrastructure to specify even a simple walking motion, so I started looking around on the net for free animation sequences. Carnegie Mellon University has published a library of 2500 animation sequences. These have been repackaged in a number of formats, include the BVH file format. Find those here. A short writeup on the BVH format is here.

The BVH format is simple enough, so I implemented a viewer for the CMU sequences. You can see the result in this video.

The skeleton they define has 57 separate joints, with a total of 132 channels of animation information. The CMU samples are at 120 fps, so the files get large. This is obviously more data than I want to put into a game avatar.

To use these sequences for anything, I'd have to do a bit of work. I'd have to cut them down to a much smaller number of key frames, and interpolate between them. I need looping sequences for things like walking, so I'd need to find subsections of the sequence that can be looped. I also want a much simpler skeleton.

The Game Engine book talks about firing off multiple "clips" at once, so that while your character is walking, you could also move the head to look at an object, and then fire off another clip like waving the arm.

These CMU animation sequences are full body motion capture, and just aren't set up for that kind of modularity. To use them, I'll have to pull a subset of joints out (like the walking motion of the legs), simplify and loop them, and make that a named clip, stored with the avatar definition.

That's it for new code this week. If there's any interest in using this little BVH animation file viewer, I'll stick the source code into the Demos the next time I do a release.

3D Printing

I continue to think about projects to do with 3D printing. Shapeways can print their "Strong and Flexible Plastics" up to 660 by 350 by 550mm in white, or 230 by 180 by 130mm in color. This is actually large enough to enclose a Mini ITX (170 by 170mm) or Micro ATX (244 by 244mm) PC motherboard. So if I had a concept and wanted to spend the money, I could print a custom PC case.

I've always thought some of the case mods were pretty neat, but the last time I tried it myself (in 2003), it didn't go well. You can read about that here.

I'm not experienced with tools and crafts. As a programmer, I think I also have an "ok, I can go back and fix that later" attitude which keeps me from sweating all the details up front. In most construction projects I've done, I've usually cut or drilled in the wrong place at least once. I've ruined one piece of electronics because I cut myself working on it, and didn't notice I'd bled all over it until after I shorted it out.

But with 3D printing none of that would be a problem! I just have to design the thing. I fiddling around a bit more this week, uploading simple boxes of different size and thickness to check the price. That lead to three areas of frustration.

Building Models

Shapeways complains about my models and another site Ponoko won't read them at all. This despite the fact that Meshlab doesn't flag any non-manifold vertexes or edges. I finally converted my mesh to Collada then imported into SketchUp and exported it again. Both systems seem to like this version.

SketchUp meshMy mesh

Looking at the mesh in both models, I think the problem must be the way I'm breaking the faces. I just built everything with rectangles, since I was planning on doing Minecraft blocks.

On the outside edges, I have several smaller triangles adjacent to one triangle on the back face. The Collada version makes triangles meet up at the end points of the faces. Models are supposed to be "manifold", which is defined as every edge being shared between exactly two triangles. I'm not doing that, which could be the problem. I'm not sure though, since I thought the system took another model I built the same way.

To do this correctly, especially for complex models, is going to be a pain in the neck. What I think I need is a Constructive Solid Geometry package which I can use to define my shape and then create the final mesh. I found a list on Stack Overflow. I'll take a look at some of these when I have a chance. Any recommendations?

Cost

The simple shapes I've uploaded have taught me one thing for certain -- 3D printing a PC case will be expensive! I'm torn between "Oooh! I want this!" and "This is a waste of money!" I have to remind myself that if I wanted a person to build me a custom case, it would also be expensive. It's not right to compare this to buying a $35 case.

Another question is do I build a case for one of my existing systems, or build a new system. I have one Micro ATX machine with integrated graphics, but it's very slow. My laptops are faster! I don't use that system for anything other than trying new Linux distros.

I could build a complete new system with better parts, but my current main system is only two years old. So I'm dithering over that.

I'm also nervous about coming up with a design and finding that it's not strong enough or has some other problem. Then I will have spent the printing charge with no recourse. This has to be right the first time!

I decided I needed to try something smaller and less critical. Looking around, I noticed my external backup disks. I could take one out of its existing case and build a new case for it. All it needs is something the right size with feet, so it will be hard to go wrong.

Of course, there's no obvious way to remove the case from one of these Western Digital Elements drives. I started to poke at it until I remembered that the internet knows everything. Sure enough, there's a YouTube video on the subject.

A Design Concept

There are of course any number of silly things you could do for a PC case. I could make it look like a famous building or cartoon character, or etch images on the sides. Sticking with the theme of my project, I could put it inside Minecraft scenery, or inside the flying saucer or the lava asteroid from Don't Hit Me. Instead, I think I should consider the pros and cons of 3D printing.

If I want to keep the cost down, I should print something small or light, since they charge by the cc of material used. I should also keep in mind the two big advantages of 3D printing -- complexity costs nothing (since pricing is by weight), and shapes can be generated by software.

So far, I can think of three types of shape unique to 3D printing:

I could use some dense real-world data as the source. Archaeologists are doing Laser ranging on sites now, producing point clouds for an entire building. You could create an extremely detailed model from this data and print it. The result would be something that you could never afford to have done by hand.

Second, I could generate some intricate mathematical shape. There are things like the MandelBox, or these odd fractal columns created by Michael Hansmeyer and described here.

Finally, I could write an algorithm like the tree branching from Part 26 that adapts itself to system I'm trying to enclose. By specifying the cloud of target points in the shape of the components, I could make the case out of branches. Branches could support the motherboard by growing through the mounting holes. Thick hollow branches could also contain all the cables. The result would be unique and completely customized. I'm not sure how attractive it would be!

That's the state of my thinking so far. Any suggestions?

Home       About Me       Contact       Downloads       Part 61    Part 63   

blog comments powered by Disqus