Discussion: suitable mouse system design
Hello everyone
For the past little while I have been working on a turn based strategy game idea with a friend, and it''s about time we got some coding done to start things off. The problem is as follows...
This is a picture of the engine in its current state, a hexagon board using a height map, rendered in OpenGL.
See that red square? right now that is my cursor, and this is the problem. I would like to implement some menus and a border, kinda like warcraft 3 I guess, so you can see unit information on whatever you''ve clicked on. But the cursor as it is now is actually a 3D object floating over the world. This cursor will probably not do, as there are a few problems with the way it scrolls off into the distance and can be a pain to track in my view. This cursor is similar right now to the one in Black & White.
I would like to implement a more traditional 2D cursor so that I can place it over 2D menus and the 3D terrain as well without having to switch it, but i''m not sure how easy it will be to select hex spaces. I''m guessing I''ll have to draw some kind of invisible ray from the cursor to the hex and do a collision detection, but i''m not sure exactly how that will work yet.
Any suggestions, help, or examples on how I should implement a mouse for this kind of view (knowing that there will be 2D menus to click on as well) would be greatly appreciated.
Thank you
Nexpert
ICBW but there is a tutorial at gametutorial about gl picking..
dunno if this can help you.
But it looks like it might can help you
dunno if this can help you.
But it looks like it might can help you
To do the 2D overlay (including the mouse) look up using glOrtho.
This places any new 3d objects flat against the screen (e.g like a menu, or mouse pointer) You can use the Pick mode to see if the mouse has clicked on any of the 3d surfaces including the flat ones. If it has clicked on your menu, you can use the original event to find what the screen co-ords of the mouse click was (i.e where on the surface it clicked).
//here is my own crappy codebool EndDrawOverlays(){ glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glFlush(); return true;}bool BeginDrawOverlays(){ glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0,Width,0,Height,-1,1); glMatrixMode(GL_MODELVIEW); return 0;}
This places any new 3d objects flat against the screen (e.g like a menu, or mouse pointer) You can use the Pick mode to see if the mouse has clicked on any of the 3d surfaces including the flat ones. If it has clicked on your menu, you can use the original event to find what the screen co-ords of the mouse click was (i.e where on the surface it clicked).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement