Mouse WorldPosition
by rennie moffat · in Torque Game Builder · 11/25/2009 (12:33 pm) · 6 replies
The %worldPos of any mouse event is a vector returned in WorldSpace? The documentation simply says it returns a vector, but not specific to world, canvas or window space. I would assume World, I just want to be sure.
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
I have been coding my sceneWindow2D as sceneWindow2D.camera, with set size, position, but I call my sceneWiindow2D.camera (what i use to call my camera throughout my behavior) .
so i would say something like this..
But am unsure if this sets to, must, should be placed as a scenegraph or what the benefit would be.
12/01/2009 (8:12 pm)
Hmmm sceneWindow as a sceneGraph, I never though of that. What is the benefit of that?I have been coding my sceneWindow2D as sceneWindow2D.camera, with set size, position, but I call my sceneWiindow2D.camera (what i use to call my camera throughout my behavior) .
so i would say something like this..
function CameraMovement::onLevelLoaded(%this, %scenegraph)
{
sceneWindow2D.setCurrentCameraPosition(%this.x, %this.y, %width, %height);
}But am unsure if this sets to, must, should be placed as a scenegraph or what the benefit would be.
#3
So for example if just to create
new t2dSceneWindow(TestWindow)
{
Position = "0 0";
Extent = "1024 768";
};
in gui-structure and set mouse events enabled, so in
function TestWindow::OnMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
%worldPosition will show coords, where mouse' pointer is "on"(overlap) this sceneWindow - in our case it is 1024x768 - so our scenewindow filling all our screen: if to move cursor to left top corner - we will have x=0,y=0.
and
if you're assigning scenegraph like you wrote, or like I do: sceneWindow2D_HelpDlg.setSceneGraph( $HelpDlgSceneGraphShow );
sceneWindow2D_HelpDlg.setCurrentCameraPosition( "0 0 1024 768" );
so now "function TestWindow::OnMouseDown" will return another coords based on new settings. Now x=0,y=0 - it is center of the sceen,
btw we can setCurrentCameraPosition( "512 384 1024 768" ); - so we will have as well x=0,y=0 at left top corner.
12/02/2009 (5:49 am)
There are few spaces in TGB (like world/local/window/canvas).So for example if just to create
new t2dSceneWindow(TestWindow)
{
Position = "0 0";
Extent = "1024 768";
};
in gui-structure and set mouse events enabled, so in
function TestWindow::OnMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
%worldPosition will show coords, where mouse' pointer is "on"(overlap) this sceneWindow - in our case it is 1024x768 - so our scenewindow filling all our screen: if to move cursor to left top corner - we will have x=0,y=0.
and
if you're assigning scenegraph like you wrote, or like I do: sceneWindow2D_HelpDlg.setSceneGraph( $HelpDlgSceneGraphShow );
sceneWindow2D_HelpDlg.setCurrentCameraPosition( "0 0 1024 768" );
so now "function TestWindow::OnMouseDown" will return another coords based on new settings. Now x=0,y=0 - it is center of the sceen,
btw we can setCurrentCameraPosition( "512 384 1024 768" ); - so we will have as well x=0,y=0 at left top corner.
#4
I am a little perplexed by this...
A. sceneWindow2D_HelpDlg is this "extension" (_HelpDlg), or any other for that matter, safe to tag on to the sceneWindow2D, and TGB will still see it as a sceneWindow2D?
B. setSceneGraph attaches a scenegraph to this window (sceneWindow2D_HelpDlg). So in this case the window is the sceneWindow2D, the scenegraph is the $HelpDlgSceneGraphShow, my question is and I think I may answer it here, but beyond coordinates, Window in world space, scenegraph in window space, what are the benefits of doing this? And how will it help me to better get my mouse event to move an object?
12/02/2009 (1:04 pm)
So what you have done is set up the TestWindow class as a new t2dsceneWindow, in this case lets just say it is our game screen. I am a little perplexed by this...
Quote:
sceneWindow2D_HelpDlg.setSceneGraph( $HelpDlgSceneGraphShow );
sceneWindow2D_HelpDlg.setCurrentCameraPosition( "0 0 1024 768" );
A. sceneWindow2D_HelpDlg is this "extension" (_HelpDlg), or any other for that matter, safe to tag on to the sceneWindow2D, and TGB will still see it as a sceneWindow2D?
B. setSceneGraph attaches a scenegraph to this window (sceneWindow2D_HelpDlg). So in this case the window is the sceneWindow2D, the scenegraph is the $HelpDlgSceneGraphShow, my question is and I think I may answer it here, but beyond coordinates, Window in world space, scenegraph in window space, what are the benefits of doing this? And how will it help me to better get my mouse event to move an object?
#5
a. if I have a sceneWindow2D as I do, the one thing I have not done is create as you did...
I did not assign a child of the parent sceneWindow. I have been just roughly without declaring "sceneWindow2D.camera" ... this, I am thinking is pointless. I must link/declare a scenegraph, a child of the sceneWindow in order for the mouse to recognize and pass on it's event info?
12/02/2009 (1:44 pm)
Oh Just a quick other thing while I am here. I am still a little sketchy on equating/linking/assigning certain objects to others and how thats done, how they are called etc, so just a quick question.a. if I have a sceneWindow2D as I do, the one thing I have not done is create as you did...
new t2dSceneWindow(TestWindow)
{
};I did not assign a child of the parent sceneWindow. I have been just roughly without declaring "sceneWindow2D.camera" ... this, I am thinking is pointless. I must link/declare a scenegraph, a child of the sceneWindow in order for the mouse to recognize and pass on it's event info?
#6
I have written this in declaring my new sceneWindow as levelA1 as such...
but since it is in onLevelLoaded, would this be better/correct/incorrect?
12/02/2009 (1:49 pm)
also just one more very quickly...I have written this in declaring my new sceneWindow as levelA1 as such...
///this exists in onLevelLoaded %this.levelA1 = new t2dsceneWindow(levelA1)
but since it is in onLevelLoaded, would this be better/correct/incorrect?
%scenegraph = new t2dsceneWindow(levelA1) ///OR!!!!>>>... %scenegraph.levelA1 = new t2dSceneWindow(levelA1)
Vyacheslav Klymenko
sceneWindow2D_HelpDlg.setCurrentCameraPosition( "0 0 480 320" );
will define another coords - e.g. in this case "mouseX=0 mouseY=0" - it is center of the screen and "-480 -320" - left up corner, so "480 320" - right down corner.