Saving Custom Objects
by Jendrik Posche · in Torque Game Engine · 05/05/2008 (6:00 am) · 4 replies
Hi All,
I derived my own object from sceneobject. I also created a datablock in torquescript. When I load the world editor , i can add my object to the world. I see my object and I can set some properties.
However when I look into the object/scene tree, my derived object doesn't show up in that list. Also when i save the mission, the object isn't saved.
Any ideas what I should do in order to make my own derived object saveable and show up in the scene tree in world editor?
Regards
I derived my own object from sceneobject. I also created a datablock in torquescript. When I load the world editor , i can add my object to the world. I see my object and I can set some properties.
However when I look into the object/scene tree, my derived object doesn't show up in that list. Also when i save the mission, the object isn't saved.
Any ideas what I should do in order to make my own derived object saveable and show up in the scene tree in world editor?
Regards
#2
05/06/2008 (1:53 am)
I'm using tge 1.5.2 and my gamebase doesn't have a save() function, nor a consolemethod save
#3
You need "typedef SimObject Parent" somewhere inside your class.
You need to override / define onAdd, onRemove, and probably initPersistFields for your class. ( Make sure you are properly calling the Parent's overriden function inside each as well ).
You need "DECLARE_CONOBJECT(MyClassName);" somewhere in the .h ( I put it right below the constructor ).
You need "IMPLEMENT_CO_NETOBJECT_V1(MyClassName);" somewhere in the .cpp ( I put it right at the top - under the includes )
These steps ( and more info ) are documented in the source file simObject.h
05/06/2008 (9:08 am)
Its from SimObject::Save() - but you shouldn't need to directly call that for it to save/load from the editor. You might be missing one of the important steps when making a "console object".You need "typedef SimObject Parent" somewhere inside your class.
You need to override / define onAdd, onRemove, and probably initPersistFields for your class. ( Make sure you are properly calling the Parent's overriden function inside each as well ).
You need "DECLARE_CONOBJECT(MyClassName);" somewhere in the .h ( I put it right below the constructor ).
You need "IMPLEMENT_CO_NETOBJECT_V1(MyClassName);" somewhere in the .cpp ( I put it right at the top - under the includes )
These steps ( and more info ) are documented in the source file simObject.h
#4
05/07/2008 (1:36 am)
Thanks, I'll look into this.
Torque Owner Nathan Kent