Game Development Community

T2DSceneGraph

by David Everhart · in Torque X 2D · 12/10/2007 (9:13 am) · 2 replies

In Torque 1.0 it was a singleton you could always get. This has changed in 1.5, does anyone know how to get the current scenegraph? I know you can define it in your xml,and also know that there can be multiple scenegraphs on the screen at any given time.

#1
12/10/2007 (11:22 am)
I haven't tried this yet, but it seems that you should be able to query the TorqueObjectDatabase for this as long as its a named object. For example...

Define the two scene graphs in your levelData.txscene
<SceneGraph type="GarageGames.Torque.T3D.T3DSceneGraph" name="FirstSceneGraph"/>
<SceneGraph type="GarageGames.Torque.T3D.T3DSceneGraph" name="SecondSceneGraph"/>

Add code to query the TorqueObjectDatabase and return each scene graph
T3DSceneGraph SceneGraph1 = TorqueObjectDatabase.Instance.FindObject<T3DSceneGraph>("FirstSceneGraph");
T3DSceneGraph SceneGraph2 = TorqueObjectDatabase.Instance.FindObject<T3DSceneGraph>("SecondSceneGraph");

John K.
#2
12/10/2007 (5:45 pm)
Hmm, while looking at your code I came upon a realization that there will always be a scenegraph around, otherwise an assert gets thrown. I kinda liked the T2DScenegraph singleton, ahh well, thanks for the heads up.