Advertisement

2d mouse,3d object, how do I tell mouse is over it

Started by June 18, 2000 04:22 PM
4 comments, last by VECTOR 24 years, 5 months ago
is there and offscreen selection buffer I can use? Is it that easy to use or is there easier ways of doing this? What I want is the type of thing in Homeworld, where you can select ships in 3d using 2d mouse pointer.
The object of war is not to die for your country, but to make the other bastard die for his . . -General MacArthur
one way to do this is to draw a frame of colored untextured objects(dont display it to the screen) and use glReadPixels(?) to check what the color is under the mouse pointer and select that object.


Theres probably an easier way by using a matrix to find where the mouse is in 3d space, but i dont know how to do that, sorry.
Advertisement
hi
you can take a look at the "OpenGl Super Bible" chapter 19 :

http://www.itknowledge.com/reference/archive/1571690735/ch19/591-593.html#Heading2

lunasol
hi
you can take a look at the "OpenGl Super Bible" chapter 19 :

http://www.itknowledge.com/reference/archive/1571690735/ch19/591-593.html#Heading2

lunasol
Another way you can do it is to cast a ray from the tip of your cursor a specified distance out (taking into account for perspective) and collision detect that ray with the objects in your scene. This works best if you render models from specific data structures and have ray/object, ray/sphere, or ray/polygon collision detection implemented. I know you may not want to go this route, but it is another method for people to keep in mind.

Morgan
www.mr-gamemaker.com has a tutorial on just that

Im Always Bored--Bordem ICQ: 76947930

This topic is closed to new replies.

Advertisement