Game Development Community

How to define new scenegraph

by Playware · in Torque Game Builder · 03/14/2007 (8:40 pm) · 3 replies

Hi,

How I can define new scenegraph for either level or Gui otherthan default t2dSceneGraph.


If any help is for me, it is appreciated.


thnx.

#1
03/14/2007 (10:00 pm)
You can add scenegraph's through the scenewindow object -- check the TGB Reference for methods
#2
03/15/2007 (7:01 pm)
I'm not really sure what the question is here. Are you asking how to create a derived type of scenegraph or how to create a new t2dSceneGraph instance?

GUI Controls don't need a scenegraph to be rendered, they are rendered on the Canvas. t2dSceneWindow is a special GUI Control that renders a scene to the Canvas. The scene it renders is defined by a scenegraph object. When you call LoadLevel on a scene window it loads the specified level file, which itself contains the scenegraph definition for that level.

You can create a new scenegraph the same way you would create a new ScriptObject or SimSet:

// create an empty scene graph
%myNewSceneGraph = new t2dSceneGraph();

// add an object to it
%someObject = new t2dSceneObject();
%myNewSceneGraph.add( %someObject );

You can then render the new scenegraph by either assigning it to the default scene window that's already on the Canvas, or creating a new scene window and pushing it to the Canvas.

// replace the scenegraph on the default scene window (named SceneWindow2d)
SceneWindow2D.setSceneGraph(%myNewSceneGraph);

-or-

// create a new scene window
%myNewWindow = new t2dSceneWindow();

// assign the new scenegraph to the new scenewindow
%myNewWindow.setSceneGraph(%myNewSceneGraph);

// push the new window onto the GUI Canvas
Canvas.pushDialog(%myNewSceneWindow);
#3
03/15/2007 (11:40 pm)
Thnx. a lot Thomas. It really helped me a lot. I wanted to define a nw scnegraph instance.