how to use gluproject to get the center coordinate of any object?

MGS 2 Member since: 11/30/2003 From: Egypt
Posted - 3 December 2003 2:32:55 PM
Here is the gluproject function :

GL.gluProject (xposition ,yposition,positionz,modelview,projection,viewport,out x,out y,out zdepth); // c# using csgl

now the question is how to use this function to determine the x , y and zdepth positions ; what is xposition , yposition and position z refers to ; is it referes to any verix on my drawn object that consist of many vertices and it is automatically gets the center coordinate x,y,z of my created object or What !!! please help me

Hi,

gluProject is similar to gluUnProject. Those command is use to read the mouse position when you click on screen and determining the 3 dimension point at near and far clipping planes.

The gluUnproject is not refer to any vertex on you object. It is refer to the near and far clipping plane. How to get the coordinates x,y,z of the object by gluUnproject? The steps will be show as below:

  1. You draw a long line at z axis by using the gluUnProject command.
  2. Then you need to do the interpolation between the line that you draw with your object.
  3. The initerpolation point is the coordinates that you need…

You can refer the gluUnproject in red book(page 152). or at http://myopendemo.hypermart.net/opengl2.htm
The demo will shown you how to use the gluUnproject command.

Hope it can help.