Camera Pick?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
sanctus2099
Posts: 18
Joined: Sat Nov 17, 2007 11:34 am

Camera Pick?

Post 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)
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post 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...
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Look in your Irrlicht SDK, in example/07.Collision/main.cpp
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply