3d picking

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
ckob
Posts: 7
Joined: Tue Jan 03, 2006 3:56 am

3d picking

Post by ckob »

Hi im currently trying to make an editor for my game and have come to the point where I would like to place models at a specific spot on my map, however I cannot seem to figure out how to get the entity picked and also is there a way to get the x,y,z of where the mouse clicked?
HazardEffect
Posts: 9
Joined: Fri Feb 03, 2006 2:06 pm
Location: Wales

Post by HazardEffect »

In my editor, I pick the scene nodes using code like this:

Code: Select all

ISceneManager* smgr = device->getSceneManager();

		ISceneNode* node=smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(cursorpos, 0);
where you set cursorpos to the cursor position (duh) and get back the nearest node to the active camera, under these coords.
This does a collision test with the bounding box of each scene node, unfortunately there's a tiny bug in 0.14 so you may need to patch the engine to get the collision test to work properly -
in aabbox3d.h, line 136 should read :

Code: Select all

const vector3d<T> e = getExtent() * (T)0.5;
I just use the node position for xyz, although I suppose you could do a more accurate hit test using ISceneCollisionManager::getCollisionPoint(...) like in the Collision sample.
I made a camera scene node that works a bit like the editor in the Torque game engine, with node selection, dragging etc. You can get the code here (CCameraEditorSceneNode.zip) if it's any help
Guest

Post by Guest »

thanks a Ton ill check it out
ckob
Posts: 7
Joined: Tue Jan 03, 2006 3:56 am

Post by ckob »

oops thought I was looged in, anyway thanks
HazardEffect
Posts: 9
Joined: Fri Feb 03, 2006 2:06 pm
Location: Wales

Post by HazardEffect »

Don't you just hate it when that happens :wink:
Let me know if you need any help with the CCameraEditorSceneNode stuff.
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

Really thanks!
It's what I need to solve the same problem as irr's picking really not accurate!

But I wonder if irr's forum can let me bookmark a topic when it solved my problem, and then I don't have to reply it, which make me able to find it again through "View your posts"???
Post Reply