isometric map mouseovers

Hi,

I’m currently in the process of writing an isometric engine for a personal project. Currently, I have a set of map tiles that is combined into a map and drawn using jogl.
The dilemma i’m facing is finding a way to create mouseovers so that when a user moves his/her mouse over a specific tile, an overlay would appear over that tile.
I thought about creating some sort of mask overtop of the tile map which has mouse event handlers, but am at a loss as to how to implement this.
Any ideas?

thanks in advance
-rey

hi, as I see it, there are two ways of doing this, one simple and crude, one complex and elegant.

simlpe methond:
If you map is flat, you can convert the screen coordinate to a map coordinate.
This will give you the map-pixel. Now you divide by the size of each tile, and you’ve got the tile under the mouse.
This only works if you map is flat (or else you would need a rather more complex convertion algorythm).

The complex method:
Have each tile stored as a sprite in a huge array containing all the sprites that are drawn into your isometric world.
Sort the array isometrically and make an exception so that tiles are allways beneth other sprites.
Now you must rig your sprites to store where they were drawn to each time their drawn.
When you want to know which tile the cursor is over, you need to do som Z-order stuff. like this:
Reverse through the sprite list (start at the end). This way you check the object drawn the last (ei is closest to the camera) first.
for each object in the sprite list check if the mouse is within it’s clipping box.
If the mouse is within the spritebox, you need to check if the mouse is over a oppaque part of the sprite.
If it is, this is your sprite/tile!
If it is not, reverse further down the list.

This method can be a pain to write. But once it’s completed it works like a charm!
Any Questions? =)

The gleem package in the jogl-demos workspace contains one version of the kind of math you would need. Check out the Manipulator and ManipPart classes. Basically if you express your tiles in terms of triangles then gleem can do the ray casting for you and give you a callback upon selection of a particular part. This is how the highlighting of the faces in the HandleBoxManipulator is done. You might also consider using a scene graph like Xith3D to draw your scene and using the built-in picking code there.