I've just started a new project, and was only a little bit in when I ran into a strange little problem when using the getSceneNodeFromCameraBB to select the scene node that you're looking at. It simply doesnt work unless you're really close to the scenenode (about 1.0f away or so, pretty much has to fill the screen before it works)
The code that I currently have is real simple, just a turn off the lighting on the selected node with a mouse click:
The node I've created is like this:
Code: Select all
scene::ISceneNode * node = smgr->addSphereSceneNode();
node->setPosition(core::vector3df(0,0,30));
node->setMaterialTexture(0, driver->getTexture("Data/Graphics/rockwall.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setDebugDataVisible(true);
node->setID(333);
Code: Select all
bool OnEvent(const SEvent & event)
{
if (event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN)
{
//get the selected node
scene::ISceneNode* selected = 0;
selected = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(smgr->getActiveCamera(),0,true);
if (selected) {
char s[64];
sprintf(s, "ID: %i", selected->getID());
device->getLogger()->log(s);
selected->setMaterialFlag(video::EMF_LIGHTING, true);
}
return true;
}
When clicking on the node, if you're close, you get the ID displayed to the output, otherwise you always get -1.
I can't see anything out of the ordinary so far, it just doesnt seem to work if you're further than 1f away.
I have searched through the forums already to seem if anyone else had a similar problem, and I get the same effect even with the following:
* if I set the camera to be a debugobject, and then set ignore debug to true on the getSceneNodeFromCameraBB
* use bit masking
* use getSceneNodeFromRayBB instead
* use a different type of scenenode
Any ideas as to what this might be, or am I just missing something obvious?