What are Canvas, scenegraph, views, windows really?
by Simon Jensen · in Torque Game Builder · 08/16/2006 (11:43 am) · 7 replies
I'm having a hard time figuring out what Canvas, scenegraph, views, windows, t2dscenegraph, gui and levels actually are and how they relate to each other.
Is there a general framework overview doc hidden somewhere that will explain a 1000 foot overview of how the major components tie together?
Is there a general framework overview doc hidden somewhere that will explain a 1000 foot overview of how the major components tie together?
#2
I know these seems like the absolute basic most concepts but finding a clear definiton of these things in the documentation has proven frustrating, and getting a clean mental picture of how the basic bits tie together just didn't gel for me. And the working through the tutorials
My confusion on views and windows comes from the 3rd post in this thread. http://www.garagegames.com/mg/forums/result.thread.php?qt=49188
I guess I meant t2dSceneWindow which look to be tied to individual t2dscenegraphs.
08/16/2006 (1:11 pm)
Thanks.I know these seems like the absolute basic most concepts but finding a clear definiton of these things in the documentation has proven frustrating, and getting a clean mental picture of how the basic bits tie together just didn't gel for me. And the working through the tutorials
My confusion on views and windows comes from the 3rd post in this thread. http://www.garagegames.com/mg/forums/result.thread.php?qt=49188
I guess I meant t2dSceneWindow which look to be tied to individual t2dscenegraphs.
#3
Your canvas is derived from GuiControl (class GuiCanvas) and can be thought of as your GUI manager. The function that creates the canvas object is in the file: 'games/common/gameScripts/canvas.cs'. By default you can only have one canvas (and I can't think of a reason why you would want more than one) and it has the global name 'Canvas'.
Scenegraph is derived from SimSet (class t2dSceneGraph). A scenegraph is a collection of objects that belong to a common scene. If you open up any proper level file you can see how the scenegraph for that level is created. Scenegraphs have lots of useful functions ('pick' for example), but their main purpose is to keep track of objects.
Scenewindow is derived from GuiControl (class t2dSceneWindow). A scenewindow is responsible for rendering the objects in a scenegraph. You can think of a scenewindow as a viewport and a camera. It's a GUI control that's placed in the window (origin and extent in the window frame), but it also has a 'position' in the world. The scenewindow by default handles all mouse events and also holds all camera functionality.
When you run your game several things happen. By default you have one scenewindow named 'SceneWindow2D' which is created in '[projectFolder]/gui/mainscreen.gui'. MainScreenGui is then set as the content ('background', basically) of your Canvas. Then in '[projectFolder]/gameScriptsi/game.cs' in the startGame function, SceneWindow2D.loadLevel() is called and the scenegraph for the level file is created and loaded into the scenewindow.
Thats the basic flow of it. If you wanted to do split-screen you would just add another scenewindow to the canvas and set it's scenegraph.
I hope this was helpful. If you need any clarification on anything let me know.
Edit: Fixed a filename...
08/29/2006 (2:48 pm)
The basic breakdown as I understand it is the following:Your canvas is derived from GuiControl (class GuiCanvas) and can be thought of as your GUI manager. The function that creates the canvas object is in the file: 'games/common/gameScripts/canvas.cs'. By default you can only have one canvas (and I can't think of a reason why you would want more than one) and it has the global name 'Canvas'.
Scenegraph is derived from SimSet (class t2dSceneGraph). A scenegraph is a collection of objects that belong to a common scene. If you open up any proper level file you can see how the scenegraph for that level is created. Scenegraphs have lots of useful functions ('pick' for example), but their main purpose is to keep track of objects.
Scenewindow is derived from GuiControl (class t2dSceneWindow). A scenewindow is responsible for rendering the objects in a scenegraph. You can think of a scenewindow as a viewport and a camera. It's a GUI control that's placed in the window (origin and extent in the window frame), but it also has a 'position' in the world. The scenewindow by default handles all mouse events and also holds all camera functionality.
When you run your game several things happen. By default you have one scenewindow named 'SceneWindow2D' which is created in '[projectFolder]/gui/mainscreen.gui'. MainScreenGui is then set as the content ('background', basically) of your Canvas. Then in '[projectFolder]/gameScriptsi/game.cs' in the startGame function, SceneWindow2D.loadLevel() is called and the scenegraph for the level file is created and loaded into the scenewindow.
Thats the basic flow of it. If you wanted to do split-screen you would just add another scenewindow to the canvas and set it's scenegraph.
I hope this was helpful. If you need any clarification on anything let me know.
Edit: Fixed a filename...
#4
08/29/2006 (8:06 pm)
Is there a way in the GUI editor to set up multiple scenewindows within a single canvas, or does this have to be manually coded?
#5
//--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(mainScreenGui) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 0";
Extent = "800 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "~/data/images/mainScreen";
useVariable = "0";
tile = "0";
new t2dSceneWindow(sceneWindowLeft) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "0 0";
Extent = "400 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};
new t2dSceneWindow(sceneWindowRight) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "400 0";
Extent = "400 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};
};
//--- OBJECT WRITE END ---
And in your script you can assign the same sceneGraph to each to have 2 views on the same graph (possibly with different zoom settings), or, assign different scenegraphs to each and have 2 views of separate graphs.
Anyone please correct me if I'm off here.
08/29/2006 (8:13 pm)
You can do://--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(mainScreenGui) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
position = "0 0";
Extent = "800 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "~/data/images/mainScreen";
useVariable = "0";
tile = "0";
new t2dSceneWindow(sceneWindowLeft) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "0 0";
Extent = "400 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};
new t2dSceneWindow(sceneWindowRight) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "400 0";
Extent = "400 600";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};
};
//--- OBJECT WRITE END ---
And in your script you can assign the same sceneGraph to each to have 2 views on the same graph (possibly with different zoom settings), or, assign different scenegraphs to each and have 2 views of separate graphs.
Anyone please correct me if I'm off here.
#6
Find this:
...and replace it with this:
...and viola, it should work.
08/29/2006 (9:55 pm)
Youre exactly right. I would suggest keeping one window named sceneWindow2D, but that's just a personal preference. Then you would just have to change the following in game.cs...Find this:
if( isFile( %levelToCheck ) )
sceneWindow2D.loadLevel( %level );...and replace it with this:
if( isFile( %levelToCheck ) )
{
sceneWindow2D.loadLevel( %level );
sceneWindowRight.setSceneGraph( sceneWindow2D.getSceneGraph() );
}...and viola, it should work.
#7
Cheers!
08/30/2006 (4:42 am)
Also, just to clarify: the code that Scott posted above would replace your mainScreen.gui file.Cheers!
Associate Anthony Rosenbaum
scenegraphs are responcable for organizing all the object on the scene, it answers such questions as where an object is? should it be rendered?
views well I guess you mean a viewport that is our window into the world
window well that is a window like your browser is a window or the game is a window, it is what made win95 so much different than windows3.1
t2dscenegraph is tgb's scenegraph system , objects that are to show up in a level must use the scenegraph of a gui ( see documentation with TGB for further details)
GUI = Graphic User Interface, it is all the buttons, type, menus, sliders you use each has a function althought they are all GUIcontrols of one way shape or form
levels are the combination of all art assets associated with a scenegraph combined into a level, you make a level save it , play it
I know theses are rough approximations, I would encourage you to do seach on each of these subject so you might have a better concept of what the game development process involves.