Timeline for How to tell what part of a 3D cube was touched
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 3, 2013 at 1:14 | comment | added | Sean Middleditch | Correct. There is a lot of existing documentation on this, on this very site. Just search for opengl ray casting, then look at the article I linked. Once you get those bits down you can then apply the technique I presented in this answer. | |
| Jul 3, 2013 at 1:08 | comment | added | Clayton | You are explaining very well, I am quite new to this and I understand what you are explaining to do but just don't know how to get it working. The classes that Byte56 used are in Open GL; While android only supports Open GL ES. I understand that when the user touches my screen I will need to get the x,y coordinates and then from my current angle must create a ray to see what part of the axis is hit to register if the ray runs into my inner cube. | |
| Jul 2, 2013 at 22:44 | comment | added | Sean Middleditch | I explained that. You use ray casting to find out which point on a AABB is picked. Then you can use that point to find out what area on the face is clicked. I'm unsure how to explain it any clearer. | |
| Jul 2, 2013 at 22:29 | comment | added | Clayton | That means Byte56's solution will have to be used or a similar version of Ray Picking. With ray picking I know how to figure out which face of the cube was touched along with the triangle. But what about the inner square? As well as what if the user touches the border between the two triangles? | |
| Jul 2, 2013 at 22:29 | comment | added | Sean Middleditch | Indeed. Doing that means for specifically that you'd doing an AABB test instead of a general cube test which is way easier. Axis-aligned slab test in particular. See gamedev.stackexchange.com/questions/18436/…. | |
| Jul 2, 2013 at 22:10 | comment | added | Adam | To do the test against a rotated cube, you can simply rotate the ray by the inverse of the cubes rotation and test against the unrotated cube and you'll get the same answer as rotating the cube. | |
| Jul 2, 2013 at 21:21 | comment | added | Clayton | Can this work if the cube rotating along the x, y, and z axis simultaneously? | |
| Jul 2, 2013 at 20:25 | comment | added | House | Yes, the first suggestion is much more simple to do. Good answer Sean. | |
| Jul 2, 2013 at 20:07 | history | answered | Sean Middleditch | CC BY-SA 3.0 |