Virtual Classes, Multiple Inheritance, Console
by Don Harvey · in Torque Game Engine · 12/31/2005 (11:16 am) · 4 replies
I purchased TGE a couple of weeks ago and after having the chance to compile and peruse the source, I get the big picture and I'm even more excited to start my endeavor! I do, however, have a couple of very specific questions relating to how a couple of C++ language constructs impact console scripts.
I have written a large 'rules' engine (prior to my purchase of TGE). I wrote it in such a way that I could 'plug in' a graphics or game engine. Currently, most of the important classes exist in a hierarchy that I now need to tie into TGE. So, here are my questions:
1.) If I expose the classes in my hierarchy by deriving my rules base class from a SimObject class, will my derived classes behave properly via script? In other words, what does the v-table do to derived class methods when called from script?
2.) Does Torque support multiple inheritance objects from within script? Can I derive a class from both my rules-base class as well as SimObject and get an exploitable object?
3.) How does overloaded functions and methods impact scripts that access these functions and methods?
Other that these three questions, I'm completely satisfied with what I see -- there's some ingenious code in Torque. I hope to absorb more so I can contribute.
Thanks!
I have written a large 'rules' engine (prior to my purchase of TGE). I wrote it in such a way that I could 'plug in' a graphics or game engine. Currently, most of the important classes exist in a hierarchy that I now need to tie into TGE. So, here are my questions:
1.) If I expose the classes in my hierarchy by deriving my rules base class from a SimObject class, will my derived classes behave properly via script? In other words, what does the v-table do to derived class methods when called from script?
2.) Does Torque support multiple inheritance objects from within script? Can I derive a class from both my rules-base class as well as SimObject and get an exploitable object?
3.) How does overloaded functions and methods impact scripts that access these functions and methods?
Other that these three questions, I'm completely satisfied with what I see -- there's some ingenious code in Torque. I hope to absorb more so I can contribute.
Thanks!
#2
I am aware that classes are exposed to the console by providing a parent typedef and using the declare and implement macros. I guess I was just wondering if I expose the base-most class to the console, then make a call to it from script, would the appropriate derived class member be called. I think I read somewhere that pointers can't be exposed to the console so a v-table entry being what it is ... Well, you get the picture. I've been looking through some more of the engine source and it appears that the Player class contains a pointer to the player datablock. Also, to clarify my musings in 2.), I didn't mean multiple inheritance within script but rather in C++ - then accessing the multiply (multipley? multiplee?) inherited object from script. It appears some of Torques native classes use multiple inheritance (such as NetConnection deriving from both ConnectionProtocol and SimGroup) so maybe it's possible. I guess these are the kinds of things we noobees have to take our time with!
Thanks again.
12/31/2005 (1:16 pm)
Thanks, Paul.I am aware that classes are exposed to the console by providing a parent typedef and using the declare and implement macros. I guess I was just wondering if I expose the base-most class to the console, then make a call to it from script, would the appropriate derived class member be called. I think I read somewhere that pointers can't be exposed to the console so a v-table entry being what it is ... Well, you get the picture. I've been looking through some more of the engine source and it appears that the Player class contains a pointer to the player datablock. Also, to clarify my musings in 2.), I didn't mean multiple inheritance within script but rather in C++ - then accessing the multiply (multipley? multiplee?) inherited object from script. It appears some of Torques native classes use multiple inheritance (such as NetConnection deriving from both ConnectionProtocol and SimGroup) so maybe it's possible. I guess these are the kinds of things we noobees have to take our time with!
Thanks again.
#3
12/31/2005 (2:14 pm)
As long as your Parent hierarchy is reasonable, TorqueScript should work fine. It just has no conception of MI (and likely won't for the foreseeable future - we might someday put interfaces & the like in, though).
#4
I never liked MI anyway. I'm just trying to fit what I have into TGE with minimal fuss.
12/31/2005 (3:12 pm)
Thanks Ben, I never liked MI anyway. I'm just trying to fit what I have into TGE with minimal fuss.
Torque Owner Paul /*Wedge*/ DElia
2.) No I don't think so.
3.) I don't think you can overload ConsoleMethods, though I could be wrong. If not youl'd just have to make a few console methods for the variants of your function.
I'm far from any kind of expert on the engine or c++, so this is all just off my elementary understanding. I'm sure some staffer or veteran will explain it better than me.