IonicWind Software

Aurora Compiler => 3D Graphics => Topic started by: kryton9 on August 15, 2006, 07:21:14 PM

Title: mouse in 3d
Post by: kryton9 on August 15, 2006, 07:21:14 PM
I couldn't find a mouse method in the 3d classes as there are in the 2d classes. Does this mean we have to do some sort of api calls?
Thanks in advance for any info.
Title: Re: mouse in 3d
Post by: Ionic Wind Support Team on August 15, 2006, 07:25:33 PM
MouseX and MouseY from the 2DScreen class just use the API funcitons GetCursorPos and ScreenToClient if it's not a full screen window.  I'll add identical methods to the 3DScreen class.

Title: Re: mouse in 3d
Post by: kryton9 on August 15, 2006, 07:27:15 PM
Thanks, for the quick reply Paul.
Title: Re: mouse in 3d
Post by: kryton9 on August 15, 2006, 10:00:04 PM
Quoteuse the API funcitons GetCursorPos and ScreenToClient if it's not a full screen window

GetCursorPos is giving me the overall x and y for the mouse to the whole monitor.

When I use ScreenToClient, I get nothing but 0,0.

Here is snippets of the code
declare import,ScreenToClient(hWnd as int, lpPoint as point),int;
declare import,GetCursorPos(lpPoint as point),int;
C3DCamera c;
C3DLandscape m;
C3DScreen *s;
CDirectInput *di;
float fadjust,fTarget;
point *mouse;
global sub main()
{
s= new(C3DScreen,1);
C3DObject scene;
di = new(CDirectInput,1);
mouse = new(point,1);

//target 60FPS for camera movement
fTarget = 1.0f / /*FPS*/60.0f * 1000.0f;
fAdjust = 1.0f;

s->CreateWindowed(0,0,800,600,AWS_CAPTION|AWS_VISIBLE|AWS_SIZE|AWS_CENTERED,0,"FPS Controls Test - ESC exits",NULL,false);
.
.
.
do
{
startTime = timeGetTime();
fps();// <<<<<<<<<<<<<my first person control function test<<<<<<<<<<<<<<<<<<<<<<
s->Clear(RGBA(0,0,0,255));
s->BeginScene(c);
scene.Draw();
s->RenderText(0,10,"FPS:"+NumToStr(fps),RGBA(255,255,0,255));
s->RenderText(0,30,"x: "+NumToStr(mouse->x)+"ÂÃ,  y: "+NumToStr(mouse->y),rgba(255,200,0,255));
fps = s->RenderScene();
fAdjust = (timeGetTime() - startTime) / fTarget;
}until di->KeyDown(DIK_ESCAPE);
Scene.Free();
delete di;delete s;delete mouse;
}

sub fps()
{
//getCursorPos(*mouse); // This gives mouse x and y referenced for the whole monitor
ScreenToClient(s, *mouse);// This is giving 0,0 all the time.ÂÃ,  I tried s, &s, 0 and 1 and all gave 0,0

IF di->KeyDown(DIK_W)
{
c.Move(0.0f,1f * fAdjust);
}
IF di->KeyDown(DIK_S)
{
c.Move(0.0f,-1f * fAdjust);
}
}
Title: Re: mouse in 3d
Post by: Ionic Wind Support Team on August 15, 2006, 10:12:12 PM
ScreenToClient knows nothing about a C3DScreen class.  It only takes window handles.

s.m_hWnd

Title: Re: mouse in 3d
Post by: kryton9 on August 15, 2006, 10:17:46 PM
Cool, got it working. THANKS!!  In case anyone else is reading these.

You need to use getCursorPos(*mouse);ÂÃ,  This give you the x and y for the mouse referenced to the whole monitor resolution

Then you callÂÃ,  ScreenToClient(s->m_hWnd, *mouse);ÂÃ,  This takes the x and y from the getCursorPos and then replaces those values with the screen's(window's) x and y coordinates for the mouse.
Title: Re: mouse in 3d
Post by: J B Wood (Zumwalt) on August 16, 2006, 07:04:22 AM
I was wondering how I was going to handle this in 3d space, specifically, back to the old target lookat thing, we know the x,y of the mouse, obviously it has no Z, so if I want my turret to turn based on the mouse pointer position, I have to assume the x,y of the mouse is the x,z in the 3d world oui, I really need to learn 3d math.
Title: Re: mouse in 3d
Post by: J B Wood (Zumwalt) on August 17, 2006, 12:11:17 PM
Hows this coming along Kryton9?
Title: Re: mouse in 3d
Post by: kryton9 on August 17, 2006, 04:39:40 PM
Very frustrating, I set it aside as the camera rotates and won't stay up. I tried everything I could think of. Couldn't get it to work the way I want.
I tried using the upvector and to adjust, but that is too goofy and is not smooth.

I was reading directx sites and other vector tutorial sites and couldn't find anything to help. So just figured enough time was wasted on it for now.
Sorry, I will need to wait till more documentation comes out or find better tutorials on vectors and matrices.

That is why I am so amazed at all you figured out so far. It is not easy so you are doing a great job!!
Title: Re: mouse in 3d
Post by: J B Wood (Zumwalt) on August 17, 2006, 08:13:08 PM
Thanks, but most of my work is guesswork, I haven't tried to tackle the mouse yet since I had the exact same problem with the camera you are, with it twisting around on its axis uncontrollably.
I don' t know how to stablise it.