• Advertisement


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

Mouse in 3D

This topic is 5715 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 I''m currently working on a simple game that should be something like command and conquer except i''m trying to do it in 3D. Now my problem is "THE MOUSE". I have to map the mouse to my 3D scene. Are there any functions which could do the mapping ? Any suggestions ? Thanx

Share this post

Link to post
Share on other sites
one way is to use mouse wheel as 3rd dimension of movemenet.

you grab 3 vectors form camera : right, up and forward. Then mouse cursor is translated by those vectors.

mousePos += right*mosue.x + up*mouse.y + forward*mouse.wheel

the other idea is to just use 2D mouse & picking.

hope this helps.

You should never let your fears become the boundaries of your dreams.

Share this post

Link to post
Share on other sites
Here''s how I do it in my Raid3D engine.
My terrain is made up from a rectangular grid of terrain patches.

1) start selection mode (see NeHe''s tut)
2) Render all visible models.
3) Have we got a hit? if not, mabe we clicked on the terrain.
4) Render all patches the fast way (no textures, lightning or anything).
5) get the patch that had the best ''hit'' (again see NeHe''s tut on picking). If none, we clicked on the void (sky, unselectables, etc.)
6) Divide the patch in small squares and render them
7) Get the square with the ''hit''
8) derive the coordinates from the square

this way I know what the user clicked, being eighter a model or terrain coordinates. The smaller you make the squares in the last selection pass, the more accurate the coordinates will get.

- An eye for an eye will make the world go blind -

Share this post

Link to post
Share on other sites

  • Advertisement