Archived

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

VECTOR

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

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites