Ray From mouse pos

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
devil20
Posts: 14
Joined: Wed Jan 19, 2005 2:28 pm
Location: UK

Ray From mouse pos

Post by devil20 »

Hi

How can i get 3d Ray from 2d mouse position ? engine has any function ?

I just want to pick some objects but i need intersection points at mouse cursor position if any .
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post by lantis »

irr::core::position2d<int> cursorPos;
cursorPos = cursor->getPosition();

smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(cursorPos);


Unfortunately here bug in engine and sometimes this code can't pickup node
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

// answering the original question:
line3d<f32> raytrace = colmgr->getRayFromScreenCoordinates(device->getCursorControl()->getPosition(), camera);
pr3t3nd3r_guest

Post by pr3t3nd3r_guest »

lantis wrote:irr::core::position2d<int> cursorPos;
cursorPos = cursor->getPosition();

smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(cursorPos);


Unfortunately here bug in engine and sometimes this code can't pickup node
When create nodes what you don't want to be selected use id 0 and the same for mouse cursor, light ... etc ...
Sometimes the desired node doesn't get selected because there are other nodes in front with id -1.
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post by lantis »

pr3t3nd3r_guest you are wrong - this bug happens and if all id >=0
Post Reply