Merging scene graphs?
by Ray Graham · in Technical Issues · 12/16/2008 (2:47 pm) · 2 replies
Hello,
I'm a fairly new user of TGB (specifically iTGB). I am looking for some advice on how to best partition my game's graphical interface design to (a) avoid duplicating work and (b) ensure that when I make a change that *all* levels are changed.
Essentially, there are some user interface elements in the game that are always going to be on the screen. They will look and function identically for every level in the entire game. What I want to do is avoid having to do a ton of duplicate work for each level to get those things out there and to make sure they function like they intend to.
I see that the *.t2d files (the levels) are really just creating a new t2dSceneGraph. So I was thinking that maybe I could make a scene graph that only contains my user interface stuff. And then somehow make sure that all other levels use the data contained in that scene graph. However, I cannot seem to find any information on how I can merge two scene graph objects. I'm also a bit nervous that perhaps the game builder won't behave properly for me.
Is my thinking on the right track, based on your experience? Is there a way to merge scenes? Or is there some other way that I should be doing it?
Thanks for any help and advice.
-Ray
I'm a fairly new user of TGB (specifically iTGB). I am looking for some advice on how to best partition my game's graphical interface design to (a) avoid duplicating work and (b) ensure that when I make a change that *all* levels are changed.
Essentially, there are some user interface elements in the game that are always going to be on the screen. They will look and function identically for every level in the entire game. What I want to do is avoid having to do a ton of duplicate work for each level to get those things out there and to make sure they function like they intend to.
I see that the *.t2d files (the levels) are really just creating a new t2dSceneGraph. So I was thinking that maybe I could make a scene graph that only contains my user interface stuff. And then somehow make sure that all other levels use the data contained in that scene graph. However, I cannot seem to find any information on how I can merge two scene graph objects. I'm also a bit nervous that perhaps the game builder won't behave properly for me.
Is my thinking on the right track, based on your experience? Is there a way to merge scenes? Or is there some other way that I should be doing it?
Thanks for any help and advice.
-Ray
#2
Thanks a lot for this information. I'll investigate both suggestions that you've made in more detail.
Above, when you said "add a second t2dSceneWindow to your GUI" do you mean the Game Builder GUI? If so, I'm not quite able to picture yet how to do that.
I'll study levelManagement.cs more and see if I can picture what you mean.
Thanks.
12/16/2008 (5:35 pm)
Hello Gary,Thanks a lot for this information. I'll investigate both suggestions that you've made in more detail.
Above, when you said "add a second t2dSceneWindow to your GUI" do you mean the Game Builder GUI? If so, I'm not quite able to picture yet how to do that.
I'll study levelManagement.cs more and see if I can picture what you mean.
Thanks.
Torque Owner Gary Preston
There is one caveat with doing this though, the 2nd level's objects will not receive an onLevelLoaded callback, you'll need to simulate that yourself after the addToLevel call has finished. Which is easy enough to do, just iterate trough all the objects in the $LevelManagement::newObjects group (recursively to account for any group objects) and do the onLevelLoaded callback.
Another alternative, which I prefer, is to add a second t2dSceneWindow to your GUI. Then you can load the interface level into this scene window via the standard loadLevel call.
Have a look in levelManagement.cs if you want to know more about how TGB handles loading levels vs adding a level to an existing scene.