Game Development Community

T2dSceneObjectDatablock edit: (not a bug)

by Alex Rice · in Torque Game Builder · 10/06/2006 (1:51 am) · 3 replies

The TGB reference says that among the allowed fields for a t2dSceneDatablock are class and superclass
However calling setConfigDatablock() does not link the class and superclass namespace member functions to be used by the object.

example %tNewEgg will not respond to member functions that are defined in namespaces MyClass and MyOtherClass!

datablock t2dSceneObjectDatablock(My_ConfigDB) 
{
      superclass = "MyClass";
      class = "MyOtherClass";
      // etc... other fields
   };
%tNewEgg = new t2dAnimatedSprite() 
   {
      sceneGraph = SCENEGRAPH;
      animationName = ANIM:
   };
   %tNewEgg.setConfigDatablock( My_ConfigDB );

the workaround is to specify the class and superclass in the t2dSceneObject's constructor instead of the config datablock:

%tNewEgg = new t2dAnimatedSprite() 
   {
      superclass = "MyClass";
      class = "MyOtherClass";
      sceneGraph = SCENE;
      animationName = ANIM;
   };
   %tNewEgg.setConfigDatablock( MLEggsSolidEgg_ConfigDB );

The docs leads me to think it should have worked because class and superclass are listed on p.178 and 179 of TGB Reference.pdf.

#1
10/06/2006 (8:06 am)
You have to set the config datablock at object creation if you want to have class and superclass be part of it. Namespaces are linked at creation and can't be changed at any later time. The "workaround" is to just set the config datablock at object creation, not after. I put "workaround" in quotes because I don't consider this a workaround so much as I consider it the "right" way. I put "right" in quotes because with anything involving an artists touch (including programming) there often is not a single right way.

datablock t2dSceneObjectDatablock(My_ConfigDB) 
{
      superclass = "MyClass";
      class = "MyOtherClass";
      // etc... other fields
   };
%tNewEgg = new t2dAnimatedSprite() 
   {
      config = "My_ConfigDB";
      sceneGraph = SCENEGRAPH;
      animationName = ANIM:
   };
#2
10/06/2006 (8:23 am)
Ben is correct--namespace linking is done on object creation (specifically, the t2dSceneObject::onAdd() c++ method, which is a chained call from the new operation), and cannot be changed afterwards.
#3
10/06/2006 (10:36 am)
Thanks Ben and Stephen, I didnt realize you could set the config datalock in the new() like that.