April 25, 2024, 02:23:53 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


mouse in 3d

Started by kryton9, August 15, 2006, 07:21:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kryton9

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.

Ionic Wind Support Team

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.

Ionic Wind Support Team

kryton9

Thanks, for the quick reply Paul.

kryton9

August 15, 2006, 10:00:04 PM #3 Last Edit: August 15, 2006, 10:03:16 PM by kryton9
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);
}
}

Ionic Wind Support Team

ScreenToClient knows nothing about a C3DScreen class.  It only takes window handles.

s.m_hWnd

Ionic Wind Support Team

kryton9

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.

J B Wood (Zumwalt)

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.

J B Wood (Zumwalt)

Hows this coming along Kryton9?

kryton9

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!!

J B Wood (Zumwalt)

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.