View Full Version : 2D mouse input and 3D detection
01-14-2007, 09:24 AM
In my program, I am going to implement a first person 3D shooter. However, it is not possible to convert 2D mouse into 3D coordinates. So, I am planning to consider the 2D coordinates which is converted from 3D. However, that also has to consider about occulsion before project the model's coordinates.
So, does opengl/glut has the occulsion library?
Is my decision correct to consider the 2D in a first person shooter?
01-15-2007, 02:03 AM
You can simply use the selection buffer to pick the objects in 3D coordinates.
01-15-2007, 04:40 AM
You shouldn't use the selection mode because it is usually not accelerated (= slow). OpenGL has no occlusion library, you will have to implement it yourself. There are many possibilities to do picking, just search in in the board. You can do it in software, either by casting a mouse pointer ray into the scene (see gluUnProject) or projectiong the scene onto the mouse pointer what you suggested (see gluProject). I also have a hardware-accelerated algorithm (that I never used myself :-) - I hope it works) using GL_ARB_occlusion_query
1. render the scene
2. set glScissor to accept only a small rectangle around your pointer
3. run an occlusion query for each object that could be selected (the occlusion query spec has examples of doing this)
4. select the object with most samples passed
01-15-2007, 04:56 AM
You can read this article if you want to use picking:
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.