Mouse Picking

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
sevans
Posts: 6
Joined: Thu Mar 01, 2007 6:00 am

Mouse Picking

Post by sevans »

Hi,

I am new to Irrlicht. I have been working through the Irrlicht tutorials. There is information in tutorial 7 for picking based on the camera. How can I do picking based on mouse clicks? Is there a tutorial or reference for this? I have done it using OpenGL before so I figure it must be possible. :)

Thanks,

-sevans
raven_coda
Posts: 89
Joined: Thu Aug 17, 2006 8:11 pm
Location: Salt Lake City, UT, USA
Contact:

Post by raven_coda »

Here's an example,

Code: Select all

core::position2d<s32> mouse_pos=Device->getCursorControl()->getPosition(); 
core::line3df line=Device->getSceneManager()->getSceneCollisionManager()->getRayFromScreenCoordinates(mouse_pos, Device->getSceneManager()->getActiveCamera()); 
 
IsceneNode* object=smgr->getSceneCollisionManager()->getSceneNodeFromRayBB(line);
	
Definition of an Upgrade: Take old bugs out, put new ones in.
sevans
Posts: 6
Joined: Thu Mar 01, 2007 6:00 am

Post by sevans »

Ah that makes perfect sense.

Get the mouse coord on screen, use a ray and the col. detection system to find out what is the first object at those coords on the screen.

Thanks a bunch raven_coda
Post Reply