In my app, I have nodes drawn randomly throughout the 3D space and I have setup a FPS camera to let the user move around the space. I've recently added code that detects a double click. If the user double clicks on a node I wanted the camera to jump forward in that direction.
Here is my code for this behaviour:
Code: Select all
core::position2d < irr::s32 > mpos = device->getCursorControl()->getPosition();
scene::ISceneNode *selectedSceneNode = device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(mpos, NODE_MASK);
if (selectedSceneNode > 0)
{
core::vector3df campos = device->getSceneManager()->getActiveCamera()->getAbsolutePosition();
core::vector3df nodepos = selectedSceneNode->getAbsolutePosition();
core::vector3df newpos = core::vector3df((campos.X+nodepos.X)/2, (campos.Y+nodepos.Y)/2, (campos.Z+nodepos.Z)/2);
scene::ISceneNodeAnimator *sa = device->getSceneManager()->createFlyStraightAnimator(Camera->getPosition(), newpos, 200, 0);
Camera->addAnimator(sa);
sa->drop();
}
Can anyone suggest why this is?