[Urgent] API for mouse coordinate to world coordinate

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
williamlai3a
Posts: 13
Joined: Wed Sep 19, 2007 11:57 am

[Urgent] API for mouse coordinate to world coordinate

Post by williamlai3a »

Is there any API in the game engine can convert the mouse coordinate to world space coordinate??
I mean like glUnProject in OpenGL.
This is because I am develop a game which need the player to click on screen to build things on the map.

Thxs a lot for the one who can answer.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Check out the ISceneCollisionManager in the API, it's got functions that allow you to cast a line from the mouses position and see which nodes in the scene it collides with, if you check the line against all nodes in the scene then you'll get the 3D position.
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

What's so [Urgent] about this? :P

Use ISceneCollisionManager::getRayFromScreenCoordinates() to create a ray.

Then either use ISceneNodeCollisionManager::getSceneNodeFromRayBB() to find the nearest scene node that the ray intersects.

And/or ISceneNodeCollisionManager::getCollisionPoint() to find the intersection of the ray and a triangle selector (or a collection of triangle selectors held in a meta triangle selector).

See example 07. Collision for usage of these.

Alternatively, you may need to collide the ray with a plane. Create a suitable core::plane3df() and then use plane3d::getIntersectionWithLine() or plane3d::getIntersectionWithLimitedLine() to find the intersection point.

If you need [Urgent] help, then Irrlicht's IRC channel is a good place to ask.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply