Game Development Community

T2dSceneGraph

by Matt Huston · in Torque Game Builder · 07/06/2006 (7:20 pm) · 5 replies

I'm a little confused about t2dsceneGraph. I would like to turn on Debug mode. However, I get...

gameSpecific/gameScripts/game.cs (20): Unable to find object: 't2dSceneGraph' attempting to call function 'setDebugOn'

I've looked at a lot of code on TDN and on boards here. The style of coding seems quite a bit different (maybe because it is old code) than what is in the tutorials. The code style I am using is similar to that of FishGames, I don't see any reference to t2dSceneGraph their either. Only the Level (as mine also has) first line is %levelContent = new t2dSceneGraph() {.

It seems to me from the code I've seen, that people are coding in the creation of their objects whereas I and in the tutorials (again the FishDemo) am using the GUI to create levels so the objects are all loaded via the level file and not through CS code.

Anyway, as you can see, I am kinda confused on this particular bit.

#1
07/06/2006 (7:46 pm)
Try

sceneWindow2D.getSceneGraph().setDebugOn();
#2
07/06/2006 (8:51 pm)
Here is a little utility function I wrote. Hope you find it useful

function MLtoggleDebugInfo( %pLevel )
{
   if ($runWithEditors)
      %tSceneGraph =  ToolManager.getLastWindow().getSceneGraph();
   if( ! isObject( %tSceneGraph ))
      %tSceneGraph = sceneWindow2D.getSceneGraph();
   
   if( ! isObject( %tSceneGraph ))
    {
      MessagePopup("SceneGraph Debug", "unable to get scenegraph" );
      schedule(800, 0, CloseMessagePopup);    
      return;   
    }

   // toggle the scenegraph setting
   if( %tSceneGraph.getDebugOn( %pLevel ))
      %tSceneGraph.setDebugOff( %pLevel );
   else
      %tSceneGraph.setDebugOn( %pLevel );
   
   // provide some feedback
   switch(%pLevel) 
   {
      case 0:
         %tDescr = "Statistics Debug Banner";
      case 1:
         %tDescr = "Bounding, Collision, and Clipping Boxes";
      case 2: 
         %tDescr = "Mount Nodes";
      case 3: 
         %tDescr = "Mount Force Lines";
      case 4: 
         %tDescr = "World Limit";
      case 5: 
         %tDescr = "Collision Bounds";
   }
   if (%tSceneGraph.getDebugOn( %pLevel ))
      %tDescr = %tDescr NL "ON";
   else
      %tDescr = %tDescr NL "OFF";
      
   MessagePopup("SceneGraph Debug", %tDescr );
   schedule(800, 0, CloseMessagePopup);
}
if ($runWithEditors)
{
      GlobalActionMap.bindCmd(keyboard, "shift escape", "", "quit();"); // doesn't work in DebugActionMap?
      
      new ActionMap(DebugActionMap);
      DebugActionMap.bindCmd(keyboard, "f5", "", "runGame();");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad0", "", "MLtoggleDebugInfo(0);");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad1", "", "MLtoggleDebugInfo(1);");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad2", "", "MLtoggleDebugInfo(2);");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad3", "", "MLtoggleDebugInfo(3);");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad4", "", "MLtoggleDebugInfo(4);");
      DebugActionMap.bindCmd(keyboard, "ctrl numpad5", "", "MLtoggleDebugInfo(5);");
      DebugActionMap.push();
}
#3
07/07/2006 (5:15 am)
Alex, yup that worked. Cool little utility function. I appreciate the help.
#4
07/14/2006 (2:55 am)
Okay, I must be a bit slow as well. I'm trying to turn on debug mode (debug banner) and I can't find anything that seems to work. I tried the above code and didn't get anything either. Where specifically do you need to place these routines (if looking at the shooter demo). Is there a toggle button for the debug banner already? Sure would be nice if there was.
#5
07/14/2006 (3:23 am)
Using the above code, the Ctrl Numpad 1-5 keys will turn on the debug window. Alternatively you could do:

function setupKeybinds()
{
   new ActionMap(debugMap);
   moveMap.bind("keyboard", "1", debug_on);
   moveMap.bind("keyboard", "2", debug_off);
}

function debug_on(%val)
{
   t2dscene.setDebugOn(0);
}

function debug_off(%val)
{
   t2dscene.setDebugOff(0);
}

This sets key "1" to turn on debug banner and key "2" to turn it off. Just call this action map in your game.

This should work so long as your scenegraph is called t2dscene.