Node selection

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
dutt
Posts: 8
Joined: Tue Sep 21, 2010 10:10 am

Node selection

Post by dutt »

I'm trying to select a scene node using mouse. In theory it's fairly simple, a line from where the mouse pointer going into the screen, see what node it hits and get that. The problem is that I always get the camera node regardless of where I click.

I thought about moving the starting point a short distance into the screen, but that didn't work very well.

Code: Select all

scene::ISceneNode* node = mgr->getSceneCollisionManager()->getSceneNodeFromRayBB(mgr->getSceneCollisionManager()->getRayFromScreenCoordinates(core::position2di(state.Position.X, state.Position.Y)), -1, false);
Is the problem with that line or my camera class? I've based it on the FPS camera that comes build in with irrlicht, just switched some controls around.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

the camera is a node, therefor it is in your selection code. you need to set the id of the camera to something that the selct flags wont detect.

Code: Select all


#define ID_PICKABLE 0x00000001
#define ID_NOPICK 0x00000010

camera->setID(ID_NOPICK);
for x=0 to whatever, node->setID(ID_PICKABLE);

scene::ISceneNode* node = mgr->getSceneCollisionManager()->getSceneNodeFromRayBB(mgr->getSceneCollisionManager()->getRayFromScreenCoordinates(core::position2di(state.Position.X, state.Position.Y)), ID_PICKABLE, false); 


of course it wont compile, but should push you in the right direction.


or, alternatively, you could make the camera a debug object and then not select debug objects......'


http://irrlicht.sourceforge.net/phpBB2/ ... light=pick
dutt
Posts: 8
Joined: Tue Sep 21, 2010 10:10 am

Post by dutt »

Got it working now :) I went with a pickable/non-pickable enum.

Thanks alot for the help.
Post Reply