I have even tried hardcoding a ray that intersects the cube and still no joy. What am i doing wrong?
Code: Select all
bbEntity* ScreenPick (s32 x,s32 y,s32 id,bool includeDebugObjects)
{
scene::ISceneCollisionManager* collMan = irrSmgr->getSceneCollisionManager();
//bbLine3d ray = collMan->getRayFromScreenCoordinates(irrDevice->getCursorControl()->getPosition());
core::line3d<f32> ray;
ray.start = bbVector3d(-100,0,-100);
ray.end = bbVector3d(0,0,0);
irrDriver->draw3DLine(ray.start,ray.end);
bbVector3d intersection;
bbTriangle hitTriangle;
scene::ISceneNode * selectedSceneNode = collMan->getSceneNodeAndCollisionPointFromRay(
ray,
intersection, // This will be the position of the collision
hitTriangle, // This will be the triangle hit in the collision
id, // This ensures that only nodes that we have
// set up to be pickable are considered
0
,includeDebugObjects); // Check the entire scene (this is actually the implicit default)
std::cout<<intersection.X;
return (bbEntity*)selectedSceneNode;
}