window coords to object coords
Currently i''m working on a windowed OpenGL game. It''s name is ''KMind'', a Master Mind clone. I have to get the object coords from the mouse coords.
The problem is that I know only the x and y coords of the mouse. I dont know the z coord. So gluUnproject doesnt work.
But I know the y coord of the object.
Does anyone have an idea how to use this information to get the x and z coords of the object?
Hendrik
there is and never will be a Z coord for the mouse. its a 2d input device. wat you need is selection and feedback which is in the red book a whole chapter on what ure describing
~prevail by daring to fail~
~prevail by daring to fail~
I agree, the only way to do it is with the selection buffer. Read up on it to see how it works and code examples. There''s a good explanation in the OpenGL SuperBible.
Basically you push a "name" (integer) before each object you draw. Then using the selection buffer and the mouse''s X, Y coordinates it will return the "name" of the object under the mouse. You should keep track of the X, Y, and Z of each object so this should be all the information you need.
Jason A.
---
I write code.
Basically you push a "name" (integer) before each object you draw. Then using the selection buffer and the mouse''s X, Y coordinates it will return the "name" of the object under the mouse. You should keep track of the X, Y, and Z of each object so this should be all the information you need.
Jason A.
---
I write code.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement