Any reason not to subclass ShapeBase?
by Stefan Lundmark · in Torque Game Engine · 08/31/2006 (1:09 pm) · 3 replies
Hello,
Is there any reason not to subclass ShapeBase?
To me, ShapeBase is not really a base in that it has alot of functionallity not all subclasses need; for example cloaking, damage, mounting, etc.
I took the PlayerClass out of ShapeBase and subclassed it from GameBase instead. Same with StaticShape. However, it was alot of work and I got thinking of object types and how many functions assume you are using ShapeBase. Which brings me to my question:
Am I looking at this in the wrong way?
Perhaps there is something very useful with having ShapeBase in the back? I figured my approach would be better performance-wise but on the other hand there are some really skilled programmers maintaining this stuff so there probably is a reason for the design in place.
Any insight would be appreciated!
/Stefan
Is there any reason not to subclass ShapeBase?
To me, ShapeBase is not really a base in that it has alot of functionallity not all subclasses need; for example cloaking, damage, mounting, etc.
I took the PlayerClass out of ShapeBase and subclassed it from GameBase instead. Same with StaticShape. However, it was alot of work and I got thinking of object types and how many functions assume you are using ShapeBase. Which brings me to my question:
Am I looking at this in the wrong way?
Perhaps there is something very useful with having ShapeBase in the back? I figured my approach would be better performance-wise but on the other hand there are some really skilled programmers maintaining this stuff so there probably is a reason for the design in place.
Any insight would be appreciated!
/Stefan
About the author
#2
08/31/2006 (7:26 pm)
Wow, is there a book or something we can purchase that covers this kind of stuff! I have bought all the ones that deal with using the engine as far as scripting, but it would be nice to get some info like this condensed into a guide. It is one thing to have the code, it is quite another to know how to use it. No, it would not be practical for me to attend a training class. I wish it were.
#3
09/03/2006 (4:45 pm)
I am confused. I am working on a Mecha/FPS game and am now wondering if I should not be using the player/shapebase to base my vehicles and players from. Should I just mock it up and decide later?
Torque 3D Owner Stephen Zepp
As you noted, ShapeBase is an extremely "fat" class, and very fps (and specifically, Tribes) focused. In some cases you may want functionality that ShapeBase (or even Player/Vehicle) provides, but in many cases it's best to re-implement in your class derived from GameBase.
GameBase provides all of the functionality that Torque as a simulation expects, and is a good place to inherit from for many object classes.