Previous Blog Next Blog
Prev/Next Blog
by date

Plan for Alex "Delerium" Scarborough

Plan for Alex "Delerium" Scarborough
Name:Alex Scarborough
Date Posted:Dec 04, 2005
Rating:Not Rated
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Alex Scarborough

Blog post
A year ago today I was introduced to Torque.
So, a year ago today I was introduced to Torque. Torque Script confused me, I had forgotten all of my C, and had never known C++. Needless to say, it was an interesting start.

The first thing I did was to read the docs and resources. I think above all, that gave me a solid foundation to build off of and without the docs and community resources, I would have remained lost and only succeeded in frustrating myself trying to work with Torque. I generally put between an hour or two a day into reading the docs, typically during the computer class that I was required to take at school. I may have spent a tad too much time purusing the docs, resources, and forums in that class; there's now a district wide block to this site.

Once I fealt that I had a good grasp of Torque Script, I started on my first little project to prove to myself that I could do something a bit different and push the envelope a bit. At the time, Half Life 2 had been out for about two months, and what interested me most about it, like many people, was the gravity gun. After a bit of thought, I realized that the actual concept was a very simple one, and should be fairly easy to implement in Torque Script. And thus I set to work on writing a gravity gun into the starter.fps. This taught me a very important lesson ultimately. Just because something sounds easy, doesn't mean that it will be easy, especially if you're new to the whole thing. It took me about three days to get it to "work". It worked about 90% of the time, and when it didn't work... well... it didn't work. Objects frequently wound up stuck far above the terrain when they failed to detect that they were close enough to the player. After another week of tweaking though, I had finished, or at least had finished as much as I was going to. It worked around 99% of the time, and throwing objects at other players damaged them, so I guess for my first foray into anything resembling programming in years I couldn't ask for much more.

After that, I set aside Torque for about a month as I focussed on school and not failing. You know, the other bits of life that occasionally interrupt dev time. Then I came back to it, this time to tackle the C++ side of things, with another problem of making the engine more dynamic. The problem I wanted to tackle this time was just a really almost pointless thing: adding the ability for the player to shoot at, and blow out, tires on a wheeled vehicle. I had figured three ways of doing it. I could mount some sort of hitbox at the hub node, I could mount some sort of hitbox at a special hitbox node, like a new collision mesh of sorts, or I could just set it up so I could mount a hitbox to any node. I hadn't even started writing this when I realized that I was making a very very stupid mistake that I have endevored to not repeat. I was coming up with very broad and far reaching solutions for a very small specific problem. If I was going to write up some sort of hitboxes that could be mounted to any node on a vehicle, why not write up hitboxes that can be mounted to any node on any shape? So, naturally, I immediately began. The date on the header file says that I started on February 28th.

It proved to be a rocky start. I had never programmed in C++ yet, much less properly added a new object type into an existing game engine. A lot of it is really a blur. I know it involved a fair number of false starts, reading the source code, especially ShapeBase as I was deriving my hitbox from GameBase (a decision I have never regretted ultimately), as well as Melv's fxRenderObject and Matt's collideable object tutorial. Both of those tutorials greatly increased my understanding of the workings of TGE, something I was in desperate need of at the time.

By mid-march I had an object that could be mounted to any ShapeBase derived object and keep up with it, yet despite the prescence of collision code, and being added to the collisions masks, other objects simply would not collide with it. I asked around on the IRC channel a bit to see if anyone else had had a similar experience, and, wouldn't you know it, Ben threw out the exact problem. Just a stupid mistake on my part. I had forgotten to add my hitboxes to the scene, assuming that GameBase or SceneObject did that. After getting that little bug fixed, things worked great. I had hitboxes that could be mounted to any ShapeBase derived object in the game and other objects could collide with them. I later took the time to give the hitboxes their own damage information, their own set of particle emitters to mount as damage emitters, and explosions they could create. Every time I explored a different aspect of the engine. The explosions in particular, as my hitboxes existed only on the server, and explosions could only be created on clients. A new NetEvent proved to be a very efficient solution, and has worked quite well, and introduced me to the more advanced networking that they bring.

Fast forward a few months, in which I worked on stuff I can't talk about, and I decided to learn how to use OpenGL. It started off as just an innocent conversation I was having with another programmer I work with. He insisted that rendering was harder than anything else. I insisted that real time collision was harder. To prove my point, I took up learning how to render things in real time. The first thing I turned to was the particle engine. Armed with the MSDN docs, and the Redbook for OpenGL 1.1, I set to work optimizing it. The project lasted about a week as I tried to work in batch rendering without breaking things like animated textures. I did eventually get it down though, and it did improve performance considerably. Rather than let those extra cycles go to waste, I immediately went to work adding in improvements to the particle engine beyond optimization. The two key things I added were particle fogging, and proper particle lighting. So, just a color multiplication and calling some OpenGL commands. Easy.

This mearly whet my appetite though. I wanted to try something different, and use some of the more rare OpenGL commands to see what kind of power I could squeeze out of them. This combined with the hype surround Half Life 2: Lost Coast naturally lead to some way of improving the overall graphical look of Torque, preferably in a way that would run on my measly Rage 128 Pro and not impact performance too greatly. This is the end result of that. It took a total of about eight hours from start to finish. And because no plan is complete without an overly large picture to kill those who still use 56k modems...



That was mid september. What have I been working on since? Well, I turned back to my hitboxes. I had here an object that could now handle receiving collisions for any DTS based object in the game. Why not just finish the job, and use it to handle sending and receiving collisions for all DTS based objects in the game, effectively giving almost all Torque collisions a single consistent pipeline that they go through? And that's what I'm working on right now. The first object type I'm trying to tackle this with is Player. In fact, code for that is compiling as I type this. If that goes well, then vehicles and items should be pretty easy to work in too.

So, to all of you who have helped me, offered me advice, or given me a different way of looking at a problem I was having, thank you for helping me get where I am today, and I can't wait to see what the next year brings.

Recent Blog Posts
List:08/31/07 - Various musings
03/01/07 - Modernization Kit: Now on Windows!
01/31/07 - A couple of personal records
01/27/07 - Read a manual today!
01/04/07 - Old games and new tech
12/13/06 - Restructure, Refactor, Rewrite, Re...
11/10/06 - Just another month gone by
09/25/06 - Shiny pictures and upcoming resources

Submit ResourceSubmit your own resources!

Nick Zafiris   (Dec 04, 2005 at 16:12 GMT)
Interesting story Alex. I'd be the first to say that your projects are excellent and really useful. There was no way I could tell you didn't have any experience with C++ before this. Great progress!

Nick

You must be a member and be logged in to either append comments or rate this resource.