Heads up, I did a weekend post on project frontier, so if you’re one of the many Monday-Friday readers (aren’t you supposed to be working?) then you might have missed it. In that post, Reader Jordi asks:
Hi Shamus, why don't you make your own file formats that are maximally efficient for your situation? Although writing a compiler/converter from a third party file format to your own takes some extra effort (although I imagine this would be fairly easy), I think it has 2 major advantages:
1) You get to select the third party format purely based on what modeling/animation tools you want to use, or how easy the format is to parse without having to worry about efficiency (both in terms of extra data/memory and parsing speed).
2) In your game you get to use maximally efficient and flexible file formats because you can custom tailor them to your own unique situation.
Ah. I really wanted to take this route. But my art path begins with Blender. (I’ll get into why later. I’m not planning on using it myself, I’ll tell you that.) If I knew Python and knew how to make Python talk to Blender, then I’d do this in a heartbeat. But I don’t and “learn a new language so you can avoid learning a new file format” isn’t really the most efficient way of doing things. Particularly since I’d still have to write the Python scripts, and then write C++ code to read the resulting files.
So we’re stuck with whatever goofball lame-brain files we can wring out of Blender. Now, my first instinct is to write a model importer and replace Sticky the Stickman with proper geometry. But, I remind myself, we’re working backwards this time. So instead of bringing in a model, we’re going to bring in an animation and have Sticky perform it.
I search around and find this Creative Commons character: http://opengameart.org/content/very-low-poly-human
He’s perfect for my tests:
- He’s low poly. Later, when I’m working on a model importer, it will be a lot easier to test on this 400 polygon guy than on some 10,000 polygon beast. When points go out of place, I’ll have a sporting chance at being able to spot the problem, instead of finding myself looking at a dense tangle of visually indecipherable geometry.
- He comes with several animations. In Blender, he can run, punch, and stand. This gives me a variety of animations for testing.
- He’s a minimalist humanoid. No guns, armor, furry sidekicks, fancy clothing, or wild anime hair. It’s just a guy, and nothing else. Again, simplicity is clarity.
Note that this is NOT something to be used in the game. This is only for research. My research begins with the following highly rigorous scientific approach:
I open the guy up in Blender. After just ten minutes I figure out how to select his animations, and then I go to File » Export and save the animation in every format available. COLLADA, Stanford .ply, Motion Capture .bvh, Stl, 3ds, obj, fbx, and x3d. Once I have a nice, even coating of random files spewed all over my desktop, I start opening up the files in a text editor. Most files are binary. (And thus gibberish in a text editor.) I set those aside. Text files are far easier to work with than binary files. You can read a text file yourself, which lets you know what the file “really” says. This makes it fairly easy to spot the difference between a design problem (I’m misunderstanding the format) and an implementation problem. (A regular old software bug.)
I inspect the files, and find that .bvh files look very, very straightforward. It’s a description of a skeleton (which I don’t need, because I already have one) followed by a pure list of rotations. “Turn the shoulder 30 degrees. Twist the spine -15 degrees. Rotate the knee 20 degrees.” Smashing. This is exactly what I want. Some animations files (perhaps most animation files) are inextricably linked to a particular skeleton. So every skeleton in the game (say, men and women) needs to have its own animations. That’s fine if you’re a big studio and you can solve problems with money, but indies can’t go around doubling their workload on a whim.
There’s a bit of ambiguity that confuses me for a while. The designer of this model has joints for both “shoulders” and “upper arms”, and my model has a single joint for the shoulders. This leads to some puzzling movement until I discover the problem. The coordinate systems don’t agree, either. My world is set up so that positive X is east, positive Y is south, and positive Z is up. Better than half of the graphics engines out there use use Y for vertical and Z for north / south. (Notch is a loose cannon. He uses Z for east / west. I’ve NEVER seen that before.) My coordinate system was chosen carefully. 1 unit = 1 meter = 1 square of terrain detail. I can covert between “map coords” and “world coords” by just throwing away the Z value. (In my previous job where Y was “up”, this was done by throwing away Y, then making Z the new Y, then dividing the new X, Y values by 10. I’m sure you can see how this could lead to occasional confusion.)
But the person who made this animation has another system in mind, and so I have to sort that out. The shoulders rotate on the wrong axis for me. Instead of swinging forward, they rotate in place. (Imagine your arms at your sides. Now turn your arm so that the palm of your hand faces forward, then behind you, etc.) The knees move backwards for a while and things are generally creepy and strange until I get it all sorted. I really wish I’d taken a screenshot of the process.
In any event, I manage to figure it out. I have an animation system, and Sticky the Stickman can now run in place. I forgot to take screenshots, but he’re’s a shot of Sticky doing the sine-wave animations from earlier, which we can pretend is a victory dance.
Just one step left. I have to read in a skeleton, vertex points, and polygons. It’s the hardest step, but at least i know everything underneath it works properly.
MMO Population Problems
Computers keep getting more powerful. So why do the population caps for massively multiplayer games stay about the same?
The Witch Watch
My first REAL published book, about a guy who comes back from the dead due to a misunderstanding.
Mass Effect 3 Ending Deconstruction
Did you dislike the ending to the Mass Effect trilogy? Here's my list of where it failed logically, thematically, and tonally.
Final Fantasy X
A game about the ghost of an underwater football player who travels through time to save the world from a tick that controls kaiju satan. Really.
Please Help I Can’t Stop Playing Cities: Skylines
What makes this borderline indie title so much better than the AAA juggernauts that came before?