Just wondering if anybody here can hook me up with how to detect the mouse on geometry that has been rotated.
In other words, before I call glRotatef(), most of the geometry is offscreen and I need to detect if the mouse is over that geometry when it is drawn to the screen in its rotated state.
Do I need to rotate it myself using the rotational matrix (which I don't have or know anymore), or is there a function that will return coordinates that have been rotated.
I know about glProject() and glUnproject() but, they only tell me of the current unrotated state of everything.
I'm trying to get hotspots to work with a cubic panorama if that helps at all.
Thanks for any help,
Nathan Warden
You’re probably supplying the modelviewmatrix to the gluUnproject function after you have popped the modelviewmatrix. You have to supply the modelviewmatrix with the rotation.
If you only want to now if the object covers the mouse position, I suggest using a stencil test and reading out the stencil value at the mouse position.
Does this mean use glLoadIdentity() after I do a mouse test instead of before? If so… that sounds easy enough.
What do you mean by stencil test? If this is the same thing I used in REALbasic in the 3D environment, I would rather use that!!! Can you tell me more (or give an example) of this?
Basically, render the rotated cubic panorama hot spots as filled polys, each as a unique flat color, into the back buffer. Do not swap at the end of the render unless you are debugging what is drawn. Then read the single pixel of the mouse location from the back buffer. Not only can the pixel color tell you if a hot spot was hit, but if you rendered each with a unique color you can tell which hotspot the mouse is over.
That sounds like it’s exactly what I’m looking for. Plus, it sounds very efficient seeing that I won’t have to see if the point lies within a specific square.