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!
I want to code a program where I can select a rendered node by mouse. Is there a way to do this fast and easy?
I suggested to code my own class inherited from IEventReceiver and ISceneNode. But this doesn't work for me because the IEventReceiver isn't able to find this node.
The ISceneCollisionManager has some methods to help you with this. You can get the collision manager through smgr->getCollisionManager(); The getSceneNodeFromScreenCoordinatesBB method will give you the scene node based on node's bounding box. The getRayFromScreenCoordinates method will give you a ray which you can then use for more accurate detection (you can then use getCollisionPoint on various scene nodes with your ray to determine if the ray from the screen position hit any of the node's triangles).
Everything works good but now there ist the problem that the given node isn't able to give me triangles.
the getCollisionPoint-method also needs an selector. I tried to use the given irr::scene::CTriangleSelector. But after implementing no triangles appeared in this selector. Why?
I would use smgr->createTriangleSelector(mesh,node) to get your selector, then attach it to the node using node->setTriangleSelector(). The documentation has more info on the createTriangleSelector method.
Yes.. however if you use CreateFromBoundingBox, this will have the same effect as the getSceneNodeFromScreenCoordinatesBB call, and the getSceneNodeFromScreenCoordinatesBB call does not require you to create a selector.
Boogle wrote:Yes.. however if you use CreateFromBoundingBox, this will have the same effect as the getSceneNodeFromScreenCoordinatesBB call, and the getSceneNodeFromScreenCoordinatesBB call does not require you to create a selector.
true, but with the selector you can retrive the intersection point between the mesh and ray, instead of just the node. this can be helpful if you want to 'drag' the node around on a plane using the mouse.
No problem to implement this code but now the click is only registered if I'm using fullscreen. In windowed mode the click is also recognized but I have to click outside the object.
Why? To test the implementation I used the original code of the CustomSceneNode and modified it with my own event receiver. In this receiver I tried to cut the ray of the active camera and the current mouse screen position with the bounding of the node. But it doesn't work in windowed mode.
Can anybody help me?
Now my second problem. How do I get a Mesh out of a single Node? Have I to fill it myself with triangle and node information like a loader?