Picking a SceneNode

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
JFT
Posts: 11
Joined: Mon Feb 02, 2009 5:32 pm

Picking a SceneNode

Post by JFT »

Hi,

i am really frustrated because i am not able to pick a SceneNode...

I tried getSceneNodeFromScreenCoordinatesBB(); and getSceneNodefromRayBB(); and the other ray function with the Point.

It didn't give me any success.

Code: Select all

ray= game->getActivesmgr()->getSceneCollisionManager()->getRayFromScreenCoordinates(game->getDevice()->getCursorControl()->getPosition(),game->getActivesmgr()->getActiveCamera());

    selectednode =game->getActivesmgr()->getSceneCollisionManager()->getSceneNodeFromRayBB(ray,1); //<--tried different methods here...

    if (selectednode == game->getActivesmgr()->getActiveCamera())selectednode=NULL;
    if (selectednode)
    {
        printf("selected\n");
            std::cout<<selectednode->getPosition().X<<std::endl;


        }
I have an own camera.Maybe there is a problem with that so i post the code of it on pastebin:
Camera.h: http://pastebin.com/9rmtDnc4
Camera.cpp:http://pastebin.com/tTPQMsAC
And the code of the Runningstate in which the selectnode method is located.
http://pastebin.com/hzAQy03z

Thank you all for you help!

JFT

(Sorry for bad english)
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Picking a SceneNode

Post by randomMesh »

You need to use proper bit masks. Please have a look at example 7 again.
"Whoops..."
JFT
Posts: 11
Joined: Mon Feb 02, 2009 5:32 pm

Post by JFT »

Thanks for the quick answer! I forgot the triangleselector for the node... But is there a way to select nodes without this selector??
Because in my .irr files i can't set the triangleselector.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

JFT
Posts: 11
Joined: Mon Feb 02, 2009 5:32 pm

Post by JFT »

i tried the getSceneNodeFromScreenCoordinatesBB() again but it seems like this method always selects the camerasceneNode.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Post by Seven »

the code i provided is a full program that lets you select and manipulate nodes. paste it into a new console program and see what it does. it will answer a lot of your questions.

also,you will want to read up on the flags that you can set with picking. In addition, the select functions allow you to ignore debug objects.

you can either give your camera an ID that doesnt match your selection flags or you can set the camera to a debug object and then tell the select function to ignore it (true);


camera->setIsDebugObject(true);
Post Reply