however, it's either NOT working, or the detection checks (red triangle, or models lightening up) is NOT working, so what's wrong?core::line3d<f32> line;
core::matrix4 Proj,View;
Proj=camera->getProjectionMatrix();
View=camera->getViewMatrix();
Proj.makeInverse();
View.makeInverse();
core::vector3df S(ms->pt.x,ms->pt.y,0);
core::vector3df E(ms->pt.x,ms->pt.y,100);
Proj.transformVect( S, S );
S.Z=0;
Proj.transformVect( E, E );
E.Z=12000;
View.transformVect( S, S );
View.transformVect( E, E );
trying to create a colliding ray from an on screen cursor
trying to create a colliding ray from an on screen cursor
i'm trying to use the position of an on screen cursor instead of the center of the screen for collision, the code i'm using (Based on what i understood from graphics programming is as follows) note that ms->pt.x and ms->pt.y is a custom input event handler code to point out where the mouse cursor is on screen at the moment.
//Use as : (device is the Irrlicht device)
//get the mouse position
irr::core::vector3df pos = device->getCursorControl()->getPosition();
//get the line ray from the active camera to mouse position
irr::core::line3df ray = device->getSceneManager()->getSceneCollisionManager()->getRayFromScreenCoordinates(pos,0);
//finally get the scenceNode for collision
irr::scene::ISceneNode* node = device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromRayBB(ray);
//get the mouse position
irr::core::vector3df pos = device->getCursorControl()->getPosition();
//get the line ray from the active camera to mouse position
irr::core::line3df ray = device->getSceneManager()->getSceneCollisionManager()->getRayFromScreenCoordinates(pos,0);
//finally get the scenceNode for collision
irr::scene::ISceneNode* node = device->getSceneManager()->getSceneCollisionManager()->getSceneNodeFromRayBB(ray);
There's something is fantastic, there's nothing is absolute.