Aggregation Noob
by RealmX · in Torque X 3D · 02/28/2010 (10:56 am) · 7 replies
Been looking thru the FPS example w/ Torque X 3D and, to be honest, I don't know where to start. I am an inheritance native and all of this "component" stuff is a bit confusing so, first of all, where do you start a new game? Not literally (File->New->etc...) but code-wise. There's nothing there when you start a new project with the exception two files and a few folders. I assume that everything comes from the TorqueObject, thats fine, but coding things like projectiles, explosions, physics, ect, from scratch seems like an awful lot of coding not to mention, I'm no mathmatician. I'm used to the TGE (and I'm assuming T3D) style of engine, where theres actually an engine with base classes to start, not one class and then "YOUR ON YOUR OWN, HAVE FUN"!!! Can someone shed some light on this aggregation-thing because I'm getting the impression that it's for those that code-on-fly (i.e. people that aren't good at keeping their base and common classes generic and then building off of those class to create more-specific classes) The shapeimage in TGE would be a good example of this. It was obviously created specifically for a gun, hence the onAmmo, onNoAmmo, correct muzzle vector, and other gun-specific things. On the other hand, the vehicle class does a very good job at this with a base vehicle class and then off of that class a hover vehicle, wheeled vehicle, flying vehicle. Sorry for the rant, but I'm feelin' like I may have wasted $250.00 on a DIY (Do It Yourself) engine.
#2
So, first, add a .dts model to your project using the XNA content pipeline. Once you do that, you create a new TorqueObject, add a T3DDTSRenderComponent, T3DSceneComponent and FreeCameraComponent to it so you can see it. After that, you will want to experiment with removing the FreeCameraComponent (because it has it's own input map which gives it FPS style movement) and adding a T3DCameraComponent, a MovementComponent and a T3DRigidComponent. With these components you can do a heck of a lot of your game. There also exists light, particle, spawn and trigger components as well as a sun and sky object (these are actually inherited from TorqueObject). You'll find most of these in the Torque3D project under the T3DComponents folder.
Oh, there is also an Engine component, called... uh, TorqueEngineComponent. It's in the XNA folder of the TorqueCore project.
About Component Aggregation... It's a programming paradigm that far more efficient than inheritance. TorqueX is the first GG engine to use it, Torque3D will be moving toward it though at a slower pace. Component aggregation is used more and more in all types of programming because of the reuse factor. Don't take my word for it though, here... http://www.lmgtfy.com/?q=component+aggregation+vs+inheritance
Hope that helps.
02/28/2010 (1:21 pm)
There is no denying the the 3D part of this engine is lacking in docs presently, John's book is a must in this case. I'm sure that you don't think the FPS demo just wrote itself? Anyway, I find the FPS demo a little overwhelming as a learning tool, so let me give you a quick shake down.So, first, add a .dts model to your project using the XNA content pipeline. Once you do that, you create a new TorqueObject, add a T3DDTSRenderComponent, T3DSceneComponent and FreeCameraComponent to it so you can see it. After that, you will want to experiment with removing the FreeCameraComponent (because it has it's own input map which gives it FPS style movement) and adding a T3DCameraComponent, a MovementComponent and a T3DRigidComponent. With these components you can do a heck of a lot of your game. There also exists light, particle, spawn and trigger components as well as a sun and sky object (these are actually inherited from TorqueObject). You'll find most of these in the Torque3D project under the T3DComponents folder.
Oh, there is also an Engine component, called... uh, TorqueEngineComponent. It's in the XNA folder of the TorqueCore project.
About Component Aggregation... It's a programming paradigm that far more efficient than inheritance. TorqueX is the first GG engine to use it, Torque3D will be moving toward it though at a slower pace. Component aggregation is used more and more in all types of programming because of the reuse factor. Don't take my word for it though, here... http://www.lmgtfy.com/?q=component+aggregation+vs+inheritance
Hope that helps.
#3
The docs don't say much about the actual objec...components. From what I can gather about aggregation and components, you have to have an indepth understanding of the classes available in order to use them. Ex: I want to create a new class and include certain peices of functionality with that class. In order to achieve this I must, similar to when you use namespaces, know what functionality each class provides. Is there any documentation describing what iControllabe, Animate, iTickable(i think), etc, etc, have to offer w/ maybe an example of when one might use the class i.e. "iTickable can be used in classes where a processtick or other time related functionality is required"? Something like that?
Trent:
Not doubting your honesty, but is
03/01/2010 (7:05 am)
Henry:The docs don't say much about the actual objec...components. From what I can gather about aggregation and components, you have to have an indepth understanding of the classes available in order to use them. Ex: I want to create a new class and include certain peices of functionality with that class. In order to achieve this I must, similar to when you use namespaces, know what functionality each class provides. Is there any documentation describing what iControllabe, Animate, iTickable(i think), etc, etc, have to offer w/ maybe an example of when one might use the class i.e. "iTickable can be used in classes where a processtick or other time related functionality is required"? Something like that?
Trent:
Not doubting your honesty, but is
Quote:...Torque3D will be moving toward it though at a slower pacestraight from the horses mouth i.e. GG?
Quote:I find the FPS demo a little overwhelming as a learning toolYeah, and THATS only a barebones demo.
Quote:It's a programming paradigm that far more efficient than inheritanceTime-wise, it sounds like far more coding than what would be required in TGE or T3D. Aggregation sounds like the gray area between procedural and inheritance. No, you don't have to code EVERYTHING from scratch but you do have to code your specific game functionality from scratch, or most of it anyway. Initially you must create all of the required components for your specific game which, I could be wrong but, sounds very inefficient, timewise. Sure, you can reuse the components, as long as the next game has the same functionality of the last game, or you could just alter the component a bit to fit THAT game, and the next, and the next.
Quote:There also exists light, particle, spawn and trigger components as well as a sun and sky object (these are actually inherited from TorqueObject).I could be wrong but isn't every object inherited from TorqueObject (and, in some cases, a few other classes as well)?
#4
Let the computer write your code...
I used the fps sample to reverse engineer a TX3D code genrator..
static dts and material manger from .fbx ascii(even though I have the core .dts).
Player/Particle/Physics comming soon..
you sound like someone who can really help me push this to the next level..interesed??
patrick at forcevfx.com
03/01/2010 (7:37 am)
Code once, use forever..Use a Database Template system, that matches TX components...Let the computer write your code...
I used the fps sample to reverse engineer a TX3D code genrator..
static dts and material manger from .fbx ascii(even though I have the core .dts).
Player/Particle/Physics comming soon..
you sound like someone who can really help me push this to the next level..interesed??
patrick at forcevfx.com
#5
I think I posted some links on component vs inheritance architectures somewhere for you. You should read them. If you're not convinced, that's ok, there is no law that says you have to do it that way, and everyone has different opinions and requirements.
03/01/2010 (1:57 pm)
Yeah that comment was straight for the horses mouth. Redesigning an app from inheritance to component aggregation is no small task.I think I posted some links on component vs inheritance architectures somewhere for you. You should read them. If you're not convinced, that's ok, there is no law that says you have to do it that way, and everyone has different opinions and requirements.
#6
Quite a few of us have stuff actually published on the Xbox, its not impossible, I actually found it pretty easy after coding flash for years. If you have any questions post them, If I can I or someone who can will do their best to answer.
03/01/2010 (8:23 pm)
I have made a number of them You have the source, open it up and read the comments. Yea the docs suck. You do not need to even know what many of the classes are to use them. Eventually you will get the hang and learn more. Like I said, I did the tutorials, bought Johns book and haunted the forums. Quite a few of us have stuff actually published on the Xbox, its not impossible, I actually found it pretty easy after coding flash for years. If you have any questions post them, If I can I or someone who can will do their best to answer.
#7
03/02/2010 (9:32 am)
Thanks Henry. I appreciate any help I can get.
Torque 3D Owner Henry Shilling
Smokin Skull
The second thing I would suggest is download the TX2D demo and go through a few of the tutorials, they explain how the engines work. TX was originally 2D/3D together in one package and were only recently split. All the concepts in the 2D engine apply to the 3D engine.
You can also get the book The Complete Guide to Torque X. www.amazon.com/Complete-Guide-Torque-X/dp/1568814216/ref=sr_1_1?ie=UTF8&s=bo...
You can get the examples from Johns Site: www.envygames.com/content/?page_id=219
Read the forums, ask questions and you will be building stuff in no time.