mouse screencoordinates + resolution

Problems building or running the engine, queries about how to use features etc.
Zoldan
Gnoblar
Posts: 9
Joined: Wed Dec 22, 2004 4:14 am

mouse screencoordinates + resolution

Post by Zoldan »

hey,

i've searched the forum for several hours now and didnt find anything that helps me ...
i want to do picking ... ok found sth using rays but that needs the mouse coordinates but i cant find anything on how to get them ...

and where can i get the screen resolution?
User avatar
NoBrain2k
Gnoblar
Posts: 12
Joined: Tue Dec 21, 2004 3:31 am
Location: UK

Post by NoBrain2k »

http://www.ogre3d.org/docs/api/html/str ... State.html

theres the mouse stuff you need

don't know about the screen resolution but it should be in the API reference somewhere too.

hope that helps :)

EDIT:

found it! :)

looks like you need RenderTarget->getWidth et al. see this URL for more info
http://www.ogre3d.org/docs/api/html/cla ... arget.html
Zoldan
Gnoblar
Posts: 9
Joined: Wed Dec 22, 2004 4:14 am

Post by Zoldan »

i needed the screen coords not these "51239358" huge values ... and not relative since last frame but the 2d screen coords ...

i found a solution for the screen coords now in Real [0,1] values but i still need the resolution ...
User avatar
NoBrain2k
Gnoblar
Posts: 12
Joined: Tue Dec 21, 2004 3:31 am
Location: UK

Post by NoBrain2k »

just edited my post, you probably didnt catch it before you replied :)
ComputerPhreak
Gnoblar
Posts: 1
Joined: Fri Dec 31, 2004 6:33 am

Post by ComputerPhreak »

hey I'm having a similar problem. I checked the api reference but I can't seem to figure it out. I need to get the absolute position of the mouse cursor. This is the code i have to determine where on the terrain the mouse was clicked:

Code: Select all

if(mInputDevice->getMouseButton(1)  && robots &&  timeUntilNextToggle <= 0)
		{
		timeUntilNextToggle = 0.5;
		Ray updateRay;
		Ray r;
		r.setOrigin(mCamera->getPosition());
		RaySceneQuery& raySceneQuery = *(mSceneMgr->createRayQuery(r,0));
		updateRay.setOrigin(mCamera->getPosition());
		updateRay = mCamera->getCameraToViewportRay(mInputDevice->getMouseAbsX(), mInputDevice->getMouseAbsY());
		raySceneQuery.setRay(updateRay);
		RaySceneQueryResult& qryResult = raySceneQuery.execute();
		RaySceneQueryResult::iterator i = qryResult.begin();
		if (i != qryResult.end() && i->worldFragment)
			{
			std::cout << i->worldFragment->singleIntersection.x << "      "
					<< i->worldFragment->singleIntersection.z << "\n";
			Vector2 v;
			v.x = i->worldFragment->singleIntersection.x;
			v.y = i->worldFragment->singleIntersection.z;
			rbot->walk_to(v);
			}
		}
The cursor position returned is some very large number. I also tried this code but got the same results:

Code: Select all


		Ogre::MouseState ms;
		mInputDevice->getMouseState(ms);
		std::cout << "\n" << ms.Xrel << "  " << mInputDevice->getMouseAbsY();
edit:: also, is there any way to prevent the standard OS cursor from being disabled in ogre? Or do i have to track the cursor and display some sort of bitmap image as a custom cursor?

thanks
Zoldan
Gnoblar
Posts: 9
Joined: Wed Dec 22, 2004 4:14 am

Post by Zoldan »

Hey,

you can get the mouse position on the screen with a GuiContainer

Code: Select all

GuiContainer* cursor = OverlayManager::getSingleton().getCursorGui();
You can change the mouse cursor by creating your own overlay for it ...

happy new year
Zoldan