View Full Version : translate?
04-03-2000, 11:27 AM
If I have a cube, and I want it to disappear if I click it with the mouse? How do I do? Is there any way to convert x, y cordinates to the float system that opengl uses?
04-03-2000, 11:57 AM
Well, you will find this topic covered under the title "picking" in the red book.
(or search this forum for it http://www.opengl.org/discussion_boards/ubb/biggrin.gif)
Hope that helped you!
(and may the vector be with you)
For translating the x,y coordinates into the "world" coordinates of OpenGL, use the gluProject and gluUnproject functions. The gluProject will take a world point and give you back the projection of it into the window coordinates. Note that the coordinate you get back will be 3D, not 2D as you might expect. The z component is the depth component and can be quite useful.
The gluUnproject may be what your looking for. It takes a window point (again, this is a 3D point where the z component specifies the depth in window coordinates and the x and y are what you normally think of for window points) and transforms the window point into the corresponding world point.
Selection is described fully in the OpenGL Redbook. If you are doing simple selection, look in the "Now that you know" section of the Redbook. It describes a very simple way to implement selection by drawing pointers (or some other identifiers to the back-buffer).
04-04-2000, 11:17 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.