Friday, June 30, 2006
Forrest Gump Meets The Avatar of Virtue
The Avatar of Ultima VII now has a new party member...

Yeah, this is a silly bit of Forrest Gump-ery. Though I did a little bit more than just photoshop an image in (or manipilate Richard Nixon's lips).
As many horrible ideas do, it began with the question, "How Hard Would It Be...?" If you are an indie game developer, these questions could lead to many months of painstaking labor, so they are dangerous to ask. But I'd been wanting to play around with the full-release version of Torque Game Builder Pro, and I hadn't had a chance since my "first impression" review a month ago.
So the horrible idea was, "How hard would it be to create an Ultima 7 - style engine with 3D animated characters in TGB?" It's a question that will likely never be answered, but I wanted to get it out of my system. Finding myself with a few minutes before going to see "Superman Returns" (and a couple of hours afterwards), I threw together a new project in TGB to test out some ideas. I called it "Hackenslash 2" after one of my horrible ideas from last year - whipping out an RPG from scratch in only one week. Hey, you never know!
I used Exult and my old Ultima 7 games (yep, still got 'em, and proud of 'em!) to rip the graphics so I could try and get the 3D model to match the perspective of the Ultima VII games. I used Cubix Studio's female content pack (one of the BEST DEALS in indie gaming content packs BTW; I recommend it highly!) . I thought it would be fun to get the camo-clad lady running around in Brittania.
3D shapes are still missing a bit of functionality in TGB, but I still consider them to be one of the great strengths of the engine. They are also incredibly easy to use, and can be mixed freely with 2D imagery. My initial attempt to drop her into some Ultima 7 imagery didn't work well, because mere 3D rotations wouldn't do the trick. I could get her facing north just fine, but walking around never looked right. Part of the reason why is that the perspective in Ultima VII is not "perspective correct" - every object is displayed as if the camera was looking about a foot or two to the right of the center of EVERY object. Naturally, in a true 3D world, the camera is looking at only one spot at a time. It's very slightly M.C. Escher-esque, but that's always the case of 2D games trying to represent a 3D world with a simulation of angles.
So I had to force the 3D shapes to behave incorrectly. To do this, I recalled a little-used tool called a shear (or skew) matrix. I had to look up how to do it in Moller and Haines' excellent book, "Real-Time Rendering." It was trivial to set up the matrix, but I once again had to dig into the C++ source code under TGB's hood to add this functionality. So I have a "local projection" matrix added to the t2dShape3D object, which is disabled by default. I added console functions accessible via TorqueScript for enabling, rotating, and adding shear to this matrix. At render time, the object's true rotation matrix is multiplied by the local projection matrix and the result is concatenated to the rendering matrix chain.
The first time I tried it, the female character got twisted all over the place, because I'd multiplied the matrices in the wrong order. I do that ALL the time. It was the bane of my existance when I was working on Void War's engine. I try to pretend to be a genius coder and all that, but when it comes to 3D I really do tend to program by Braille. I keep a copy of Real-Time Rendering handy and just keep fiddling with things until they behave correctly.
By the end of the night (time that SHOULD have been spent working on Apocalypse Cow, if I'd had any sense at all), I had camo-girl running around looking like she belonged in Brittania circa 1991. Okay, so her animation was about 1000 times better, and she doesn't have the black outline (I could do that by doubling her poly count, but that wasn't the POINT). But I bet she could kick the Guardian's butt any day! Especially if I outfitted her with a magical M-16.... VAS CORP that, sucker!
So that's part 1 of what will likely be a 100-part engine if I move any further on it. Tiles of different sizes, layered tiles for different elevations, a seamless "full world," a conversation system, an inventory system, a quest system, combat, stats, massive game-state tracking... all fun, busy projects. Not to mention trying to produce REAL art assets instead of borrowing from one of the best PC RPGs of all time. But this was an amusing, nostalgic little diversion.
BTW, having never finished Ultima 8 or even ever playing Ultima 9 --- can someone tell me if the Guardian finally got what was coming to him? He was an awesome villain in Ultima 7, and I regretted never being able to kick his stony butt once and for all.
Incidentally: Superman Returns? My wife really liked it, but I thought it was dissapointing. I didn't dislike it, but I didn't think it was in the same league as Batman Begins or Spiderman 2. I found myself more interested in Richard White's character (dude, stick with Lois Lane --- because getting involved with the Dark Phoenix will lead to nothing but pain!) than any of the principles.
Labels: programming, retro, Torque
