Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nexpert

Discussion: suitable mouse system design

This topic is 5196 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
To do the 2D overlay (including the mouse) look up using glOrtho.


//here is my own crappy code

bool 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).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!