Advertisement

How to do picking with mouse click on nodes in Irrlicht

Started by February 02, 2014 08:27 AM
0 comments, last by flammable 10 years, 9 months ago

I am not sure what function in ISceneCollisionManager I can use to do picking of objects.

I want to click on mesh nodes or whatever is on screen and get that object which was clicked on by the mouse pointer?

Thanks!

Hey,

The simplest method is using: ISceneCollisionManager::getSceneNodeFromScreenCoordinatesBB

This method only takes bounding boxes into consideration though, if you need more precision you should probably use


 line3d<f32> ray = colmgr->getRayFromScreenCoordinates(device->getCursorControl()->getPosition(), camera);

This returns a ray which goes though the camera and points to where the cursor is pointing, then use:

ISceneCollisionManager::getSceneNodeAndCollisionPointFromRay

to find the first scene node intersecting this ray

links:

http://irrlicht.sourceforge.net/forum/viewtopic.php?t=38725

http://irrlicht.sourceforge.net/docu/classirr_1_1scene_1_1_i_scene_collision_manager.html

This topic is closed to new replies.

Advertisement