Page 1 of 1

Camera Pick?

Posted: Sun Jul 27, 2008 5:25 pm
by sanctus2099
I'm moving from BlitzMax and MiniB3d...
There was a function called CameraPick that returned the 3D pos of the collision between the mouse and a object.
I'm not sure I'm explaining this good.
So imagine you have a plane and you go with the mouse on it. I need to get the 3d coords of the mouse on the plane. or you could thing of selecting a 3D soldier in a 3d RTS. (that's what I'm trying to do).

How can I do that in Irrlicht? (I searched but didn't find anything good)

Posted: Sun Jul 27, 2008 5:59 pm
by christianclavet
Perhaps you need to do a RAY collision test with a mesh.

Here some code extracted for theIRRai editor from JP:

Code: Select all

scene::ISceneCollisionManager* colmgr = smgr->getSceneCollisionManager();
            core::line3df ray = colmgr->getRayFromScreenCoordinates(mousePos, smgr->getActiveCamera());
// Grab the node clicked on
                scene::ISceneNode* clicked_node = colmgr->getSceneNodeFromRayBB(ray);
Hope that help...

Posted: Sun Jul 27, 2008 9:12 pm
by rogerborg
Look in your Irrlicht SDK, in example/07.Collision/main.cpp