T2dSceneWindow Best Practices
by Mark Mesich · in Torque Game Builder · 06/05/2006 (11:29 am) · 5 replies
Hey Guys,
I am looking for some suggestions on how to best manage t2dSceneWindow objects....
So, I know every scene object that gets created needs to be part of a scene graph. And scenegraphs are associated with scene windows. However, I am running into problems when setting up the navigation between a number of GUI screens.
It seems that the t2dSceneWindow object can be created as part of the GUI (as in the mainScreenGui of the tutorial's and samples). If I am trying to create a number of GUI's that are navigated between like a menu system, should each GUI have its own t2dSceneWindow object? Or should I try to share a single instance?
I seem to be running into problems with GUI screens when I do not specify a scene window, yet each GUI having its own scenewindow is not quite what I want either. I also tried creating one in script, but that didnt work. What is the best way to handle these instances?
Should I be using a different strategy for menus? As an aside, I cannot seem to find docs on the Canvas class. Can someone point me in the right direction as well?
Thanks a lot for your help,
Mark
I am looking for some suggestions on how to best manage t2dSceneWindow objects....
So, I know every scene object that gets created needs to be part of a scene graph. And scenegraphs are associated with scene windows. However, I am running into problems when setting up the navigation between a number of GUI screens.
It seems that the t2dSceneWindow object can be created as part of the GUI (as in the mainScreenGui of the tutorial's and samples). If I am trying to create a number of GUI's that are navigated between like a menu system, should each GUI have its own t2dSceneWindow object? Or should I try to share a single instance?
I seem to be running into problems with GUI screens when I do not specify a scene window, yet each GUI having its own scenewindow is not quite what I want either. I also tried creating one in script, but that didnt work. What is the best way to handle these instances?
Should I be using a different strategy for menus? As an aside, I cannot seem to find docs on the Canvas class. Can someone point me in the right direction as well?
Thanks a lot for your help,
Mark
About the author
#2
So, do you have one GUI that defines a single instance of a t2dSceneWindow then, or do you create it outside of a GUI definition?
Also, if I understand what you are saying - you push and pop controls separately rather than a Canvas.setContent? Is this correct?
Perhaps my confusion is due to having a t2dSceneWindow objects defined in a GUI at all. It seems misplaced because I think of a GUI being overlayed on top of a scenewindow. I cant seem to figure out where Canvas comes in - is it a top-level object that owns the scene?
06/06/2006 (12:43 pm)
Thanks for your reply Rodney.So, do you have one GUI that defines a single instance of a t2dSceneWindow then, or do you create it outside of a GUI definition?
Also, if I understand what you are saying - you push and pop controls separately rather than a Canvas.setContent? Is this correct?
Perhaps my confusion is due to having a t2dSceneWindow objects defined in a GUI at all. It seems misplaced because I think of a GUI being overlayed on top of a scenewindow. I cant seem to figure out where Canvas comes in - is it a top-level object that owns the scene?
#3
I lay it out depending upon the need. For instance, I have a GUI setup almost like MainScreenGUI from most of the examples, but when I pause my game I use this..

see how you can push a dialog on top of the other.. Notice this is a GUI control without a SceneWindow, I didn't need one. Because it pops on top of the canvas, covering whatever other GUI, if one exists underneath. Like in the case of the image above, the standard mainSreenGUI is its own GUI control.
The Canvas is the main drawing interface, t2dSceneWindows sit on top of Canvas, thus enabling to have multiple t2dSceneWindows on a single canvas. along with other GUI controls.
I use a combination of setContent with push , pops and visible nonvisible toggles..
Hope this helps clarify some..
Rodney
06/06/2006 (4:39 pm)
Canvas is really the main drawing layer, t2dSceneWindow is really just another GUI control.I lay it out depending upon the need. For instance, I have a GUI setup almost like MainScreenGUI from most of the examples, but when I pause my game I use this..

//define some game junk..
$gameName = "Placid";
//Define our Pause Window
new GuiWindowCtrl(pauseFullWindow) {
canSaveDynamicFields = "0";
Profile = "EditorWindowProfile";
HorizSizing = "center";
VertSizing = "center";
position = "0 0";
Extent = "640 480";
MinExtent = "8 2";
canSave = "1";
Visible = "0";
hovertime = "1000";
text = "Alert";
maxLength = "1024";
resizeWidth = "0";
resizeHeight = "0";
canMove = "0";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
new GuiWindowCtrl(pauseWindow) {
canSaveDynamicFields = "0";
Profile = "EditorWindowProfile";
HorizSizing = "center";
VertSizing = "center";
position = "220 190";
Extent = "200 100";
MinExtent = "8 2";
canSave = "1";
Visible = "0";
hovertime = "1000";
text = $gameName;
maxLength = "1024";
resizeWidth = "0";
resizeHeight = "0";
canMove = "0";
canClose = "0";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
new GuiButtonCtrl(pauseGameBtn) {
canSaveDynamicFields = "0";
Profile = "GuiButtonProfile";
HorizSizing = "center";
VertSizing = "center";
position = "24 41";
Extent = "140 30";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "pauseGame(t2dScene);";
hovertime = "1000";
text = "Game is Paused";
groupNum = "-1";
buttonType = "PushButton";
};
};
};
//****************************************************//
// getGamePaused
//
// returns the state of the pausing
//****************************************************//
function getGamePaused()
{
return $gamePaused;
}
//****************************************************//
// setGamePaused
//
// sets the state of the pausing
//****************************************************//
function setGamePaused(%val)
{
$gamePaused = %val;
echo("gamePaused set to" SPC %val);
return getGamePaused();
}
//****************************************************//
// pauseGame
//
// Given a SceneGraph it will pause scene.
//****************************************************//
function pauseGame(%obj)
{
if(isObject(%obj))
{
if (getGamePaused())
{
echo("Resuming Game");
canvas.popDialog(pauseFullWindow);
setGamePaused(0);
pauseWindow.setVisible(false);
%obj.setScenePause(false);
SetCanvasTitle($gameName);
} else {
echo("Pausing Game");
setGamePaused(1);
canvas.pushDialog(pauseFullWindow);
pauseWindow.setVisible(true);
%obj.setScenePause(true);
SetCanvasTitle($gameName SPC "- Paused");
}
} else {
echo("Non Object Reference Passed to pauseGame");
return;
}
}
moveMap.bindCmd(keyboard, "alt p" , "" , "pauseGame(t2dScene);" );see how you can push a dialog on top of the other.. Notice this is a GUI control without a SceneWindow, I didn't need one. Because it pops on top of the canvas, covering whatever other GUI, if one exists underneath. Like in the case of the image above, the standard mainSreenGUI is its own GUI control.
The Canvas is the main drawing interface, t2dSceneWindows sit on top of Canvas, thus enabling to have multiple t2dSceneWindows on a single canvas. along with other GUI controls.
I use a combination of setContent with push , pops and visible nonvisible toggles..
Hope this helps clarify some..
Rodney
#4
This is very helpful and the kind of guidance I was looking for - thanks a lot!!
Mark.
06/06/2006 (7:22 pm)
Hey Rodney, This is very helpful and the kind of guidance I was looking for - thanks a lot!!
Mark.
#5
06/06/2006 (8:06 pm)
No problem, I was in your position a few weeks ago, Good thing TGB has a short learning curve :-)
Torque 3D Owner Rodney Rindels - Torqued
Divide By Zero
Not much help, but thats my approach. ;-)