Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello again, another day, another problem, but im getting into it :) I have a SceneNode representating a world. It includes multiple meshes, so every mesh is a part of the world. I tried getting the MeshTriangleSelector to work, but till now without success. What i need is best described in 2 steps: 1. when i click with the left mouse button i want to know which model i clicked. whatever is in the middle of my view, i want the mesh object. 2. when that worked i want that i can click somewhere in the view and selecting from there, and not the middle of the screen. Documentation says that a MeshTriangleSelector gets one mesh as a param... Does that mean for me i need to create one for every mesh i have(256)? or am i able to bind a selector to the whole scene node, so i can simply return the coordinates of the clicked polygon? Thanks again for help :) |
||||
|
A simple and fast test would be to test the bounding box of each model if it collides with the mouse. Use yourNode.getTransformedBoundingBox().intersectsWithLine(lineStart, lineEnd) for this. In most cases, this is all you need, but for polygon level collision detection, creating a MeshTriangleSelector is the way to go, yes. About 2: You only need a 3d line to do the collision detection, use engine.get3DPositionFrom2DPosition(pixelPosX, pixelPosY) to get a point on that line. Calculating the line from the position of the camera to an end point which is far enough away from it, going through the point you get from get3DPositionFrom2DPosition is all you need. Maybe I should create a new tutorial for this. |
||||
|
That would be awesome :) i guess i'll spend this day on figuring out how to get it to work... the problem (for me) is that i never did 3d-stuff before.. well not that kind of.. building gamescripts yes, but complete camera / collision etc stuff not. so this forum/website is atm my only resource. |
||||
|
After spending days to get it to work, i give up. i simply cant get it to work.. :( I tried using the camera position and the position i get with get3DPositionFrom2DPosition ... a tutorial on how to get collision detection by clicking somewhere in the screen in a custom scene node with maybe multiple mesh support would be helpful. Till that i have to pause my project |
||||
|
Yes, you need a bit to dive into programming for this. The tutorial will need a bit still, but there are some threads in this forum also describing this. |
|