Into the belly of the beast
by Greg Baker · 02/25/2007 (9:01 pm) · 6 comments
The last few days have been spent with my head down inside of the source code for both TGB and TGEA, the networking sections of 3DGPAO2E, and the source code documentation for both engines produced by doxygen (great stuff btw and a huge thanks to the GG team for supporting doxygen in their source comments, no small effort there). Using these tools as my guide, and a bit of documentation provided in the TDN about integrating real-time networking with TGB (i.e. a sturdy bit of rope with a noose at one end with a tag reading 'insert head here -->() '), I've been attempting to hack together what I've begun to affectionately refer to as the Torque Game Engine : Frankenstein Edition, or TGEF.
As a complete Torque newbie, I've found myself in over my head several times being asphyxiated by inexplicable RTEs (run-time errors) or pummeled senseless by incomprehensible connections between the c++ source code and Torquescript (TS). Thankfully, my trusty companion Subversion has been there each and every time to undo my ill-conceived edits and retrieve my worn-out noodle from the cooking oil before it could be fried along with the proverbial bacon. I am now safely back at base camp, or as we like to call it 'Revision 67', a light is beginning to dawn in the far-off horizon of my mind. As the darkness reluctantly recedes and gives way to more rational musings, a thought, resting peacefully in my mental oasis, slowly rises, unfolds itself like a flower embracing the first rays of morning sunlight, and eloquently states...
"%@#!, this *$%@ is complicated!"
To which I thoughtfully respond,
"God %$@* right it is."
I've done initial proof of concepts for 2 different games in TGB within a matter of days. One is a Subspace, Cosmic Rift derivative, and the other is a standard 2D platformer. I've found getting up to speed on TS easy enough. The language syntax is familiar and the documentation is more than adequate. I even merged the TGEA networking code for datablocks, following the previously referred to article from the TDN, with little trouble (figuring out what the article meant by "Mission Load Sequence" was another matter entirely...). It would seem like everything is copasetic, so what's giving me fits? I can summarize my problem in the following question:
"How does all this stuff fit together??"
Seriously, that's my single biggest problem right now. It's a challenge faced by anyone who's ever worked with a complex software application, whether its in game development or in any other industry. In time it will all start to come together, and some pieces will be easier to pick up than others. My current area of focus is the networking, which is probably one of the more difficult and esoteric portions of the product to wrap your head around. Granted at its core we're just dealing with good old socket programming, which in and of itself isn't that difficult, I've done my share of TCP/IP socket programming before, but it's the half-ton of "HARD" aka TNL that's been layered on top of it that's difficult to grasp. People have spent, oh, a few YEARS developing, tweaking, and optimizing the TNL used by the engine. I'm not even looking to modify existing behavior, at least not yet...
In addition to just understanding the basics of TNL and how ghosting works, I'm still struggling to come up to speed with how exactly do TS and the C++ Engine fit together. My current understanding of the relationship between TS and the engine is a like a dog and its master. The dog is the engine. It happily sits there waiting to do whatever it is I tell it to. The master is TS. TS can tell the dog to sit, and the dog sits. It can tell the dog to roll over, and the dog rolls over...off a cliff and into a fiery GPF inferno. Okay, okay, maybe not a GPF inferno, but without a careful understanding of what I'm doing, I can certainly mess things up pretty good by telling the engine to do something with TS in the wrong order. So what is that order? Is it...speak, sit, roll-over? Sit, speak, sit? Speak, sit, play-dead? Well, the play-dead one I can get it to do pretty reliably, just not always at the end of the game where I want it. :)
Overall I'm thoroughly enjoying myself. It's like a mystery I'm slowly unwraveling with each bit of code I dig into, documentation I read, and game demo I write. I'm just thankful for all the tools available to help find my way. :)
I haven't stopped on my math journey either...I've moved on to brushing up on my linear math, and I'm currently studying matrix transformations and solving linear systems.
As a complete Torque newbie, I've found myself in over my head several times being asphyxiated by inexplicable RTEs (run-time errors) or pummeled senseless by incomprehensible connections between the c++ source code and Torquescript (TS). Thankfully, my trusty companion Subversion has been there each and every time to undo my ill-conceived edits and retrieve my worn-out noodle from the cooking oil before it could be fried along with the proverbial bacon. I am now safely back at base camp, or as we like to call it 'Revision 67', a light is beginning to dawn in the far-off horizon of my mind. As the darkness reluctantly recedes and gives way to more rational musings, a thought, resting peacefully in my mental oasis, slowly rises, unfolds itself like a flower embracing the first rays of morning sunlight, and eloquently states...
"%@#!, this *$%@ is complicated!"
To which I thoughtfully respond,
"God %$@* right it is."
I've done initial proof of concepts for 2 different games in TGB within a matter of days. One is a Subspace, Cosmic Rift derivative, and the other is a standard 2D platformer. I've found getting up to speed on TS easy enough. The language syntax is familiar and the documentation is more than adequate. I even merged the TGEA networking code for datablocks, following the previously referred to article from the TDN, with little trouble (figuring out what the article meant by "Mission Load Sequence" was another matter entirely...). It would seem like everything is copasetic, so what's giving me fits? I can summarize my problem in the following question:
"How does all this stuff fit together??"
Seriously, that's my single biggest problem right now. It's a challenge faced by anyone who's ever worked with a complex software application, whether its in game development or in any other industry. In time it will all start to come together, and some pieces will be easier to pick up than others. My current area of focus is the networking, which is probably one of the more difficult and esoteric portions of the product to wrap your head around. Granted at its core we're just dealing with good old socket programming, which in and of itself isn't that difficult, I've done my share of TCP/IP socket programming before, but it's the half-ton of "HARD" aka TNL that's been layered on top of it that's difficult to grasp. People have spent, oh, a few YEARS developing, tweaking, and optimizing the TNL used by the engine. I'm not even looking to modify existing behavior, at least not yet...
In addition to just understanding the basics of TNL and how ghosting works, I'm still struggling to come up to speed with how exactly do TS and the C++ Engine fit together. My current understanding of the relationship between TS and the engine is a like a dog and its master. The dog is the engine. It happily sits there waiting to do whatever it is I tell it to. The master is TS. TS can tell the dog to sit, and the dog sits. It can tell the dog to roll over, and the dog rolls over...off a cliff and into a fiery GPF inferno. Okay, okay, maybe not a GPF inferno, but without a careful understanding of what I'm doing, I can certainly mess things up pretty good by telling the engine to do something with TS in the wrong order. So what is that order? Is it...speak, sit, roll-over? Sit, speak, sit? Speak, sit, play-dead? Well, the play-dead one I can get it to do pretty reliably, just not always at the end of the game where I want it. :)
Overall I'm thoroughly enjoying myself. It's like a mystery I'm slowly unwraveling with each bit of code I dig into, documentation I read, and game demo I write. I'm just thankful for all the tools available to help find my way. :)
I haven't stopped on my math journey either...I've moved on to brushing up on my linear math, and I'm currently studying matrix transformations and solving linear systems.
About the author
#2
ps: I haven't seen copacetic in print or on the web in a loooooong time ;p
02/26/2007 (1:09 am)
You really do have a way with words, quite entertaining ;pps: I haven't seen copacetic in print or on the web in a loooooong time ;p
#3
Don't forget to come back and tell us all what you've learned!!
02/26/2007 (1:31 am)
Ha ha! Very good read. Good luck! Don't forget to come back and tell us all what you've learned!!
#4
--when the driver turns the key, it's a single consoleMethod--and to the driver, he simply expects to hear the engine start, and see some indicators change, and be able to drive once he puts it in gear...but within the engine (c++ class), hundreds and hundreds of steps occur to get the car (class) to that state.
The driver needs to have a basic understanding of how a car works, and needs to study the various things that a car can do when driven properly, but he has no need to understand things like ignition timing, theories of internal combustion, the proper ratio of fuel to air mixture, or all of the hundreds and hundreds of things that an automotive engineer needs to know to properly make a car run.
Given a steering wheel, some guages, accelerator and brake pedals, and a transmission, the driver (again, Torquescript) can go on a journey cross country and do amazing things...all without understanding how that car works internally, but simply understanding how to use the car's features and functionality to do what they want...and that is how both TorqueScript and C++ class development should be viewed: c++ provides functionality, TS calls that functionality.
02/26/2007 (5:10 am)
The analogy I like to use when teaching the relationship between TorqueScript and C++ is that of a driver (TorqueScript), and a car (C++ class):--when the driver turns the key, it's a single consoleMethod--and to the driver, he simply expects to hear the engine start, and see some indicators change, and be able to drive once he puts it in gear...but within the engine (c++ class), hundreds and hundreds of steps occur to get the car (class) to that state.
The driver needs to have a basic understanding of how a car works, and needs to study the various things that a car can do when driven properly, but he has no need to understand things like ignition timing, theories of internal combustion, the proper ratio of fuel to air mixture, or all of the hundreds and hundreds of things that an automotive engineer needs to know to properly make a car run.
Given a steering wheel, some guages, accelerator and brake pedals, and a transmission, the driver (again, Torquescript) can go on a journey cross country and do amazing things...all without understanding how that car works internally, but simply understanding how to use the car's features and functionality to do what they want...and that is how both TorqueScript and C++ class development should be viewed: c++ provides functionality, TS calls that functionality.
#5
02/26/2007 (5:13 am)
Stephen, great description!! Love it.. will use it by myself from now :) (with credits!) hehe...
#6
02/26/2007 (10:54 am)
@Beer/Stephen -- both great reads, thanks for taking the time to write them up. 
Torque 3D Owner Phil Carlisle
The fact is, its complex, but it IS understandable if youre able to spend the time and effort to do so. So keep going and you'll get there.