2006-08-22

Doing a little bit of everything lately

Where to begin? I guess chronological order is the easiest, so here goes.

I finished the initial version of the animation engine not too long after my last post. So the next logical step was to create a path from Blender to a binary file recognized by my engine. Minimally I need files with skeleton data and animation data, and eventually skinned mesh data.

As a small break from coding I first sketched out the skeleton ("rig") for the main character in my game. I tried to get the proportions as close to a real person as I could so I used an 'Anatomy for Artists' book for reference. It wasn't a quick sketch in an hour or so. It took a day or two and what I've learned so far will help when I start doing my first real animations.

Once the layout for the skeleton was drawn up on paper I then proceeded to learn how to build it in Blender. I was familiar with how "rigging" works in general and how it should be built, but I wasn't familiar with the specifics of how to do it, in any modeling package. I'd played around with Blender a little bit in the past but not much. To familiarize myself with it again I went through the "Gingerbread Man" tutorial for my second time. Once I was reacquainted with Blenders interface I built the skeleton I had sketched out. Which turned out not to be too difficult. I also created a very simple animation.

Next was to export the skeleton and animation data. My intention was always to use the DirectX text file as my export format and then write a Ruby program to convert it into my own data format. I'd already created a similar program for extracting mesh data from a DirectX file when I was writing my 3D demo for Stardock. But I quickly learned that the DirectX exporters that are supplied with Blender leave something to be desired. Thus begins my first distraction from working on my game (not entirely a bad thing, but not expected.)

I tried exporting the skeleton and animation, and the output didn't look correct. First the exporter's output isn't as clean looking as I'd prefer, and all the keyframes only contained the matrix for one frame repeated for all frames. Not sure what to do, I began by looking at the export script.

All scripting in Blender is written in Python so I hoped I could at least understand it in general. Turns out that Python and Ruby are syntactically very similar so I felt right at home almost immediately. That's when I decided I would try to fix the script and possibly improve it.

Long story short(er), I started learning some Python and the Blender Python API. I eventually got the data I wanted to export properly, and in the process I cleaned up the exporter a bit and rewrote some code. I may finish the cleanup and release a new version of the exporter to the public (no offense to the original author of the script, but the code was pretty ugly. The community might appreciate a cleaner, working version).

The next step was to write a Ruby program to translate a DirectX file into the binary format expected by the engine (eventually I plan to generate an intermediate text format of my own, but I haven't begun the specification yet so I'm skipping that step for now.) This is more or less the phase I'm in now. I'm writing the code and in the process learning new things about Ruby and getting more comfortable with it.

My latest tangent started after I began parsing (technically I was doing lexical analysis ("scanning") and syntactic analysis ("parsing") but at the time I hadn't yet learned the difference) the DirectX file. I began to wonder how a compiler manages the parsing (and scanning) of text files. I visited the University library and checked out a few books. I'm now reading up on compiler construction (very interesting, I might take a class on it) and trying to use this knowledge to better scan and parse the DirectX file. Also learning about how Lex (Flex) and Yacc (Bison) work. Right now I'm investigating the Ruby versions called Rex and Racc in hopes of possibly using them to do my scanning and parsing. Depending on how difficult or practical it is I may just write my own less elegant solution in Ruby that just gets the job done, but I like the idea of using these programs to scan and parse the data.


School starts two weeks from today. I'm looking forward to getting back to class but I also know that I'm going to miss being able to code as much as I have been lately. I'm going to try and get as much out of the next two weeks as I can.

0 Comments:

Post a Comment

<< Home