View Full Version : A program to generate scenes

08-13-2003, 08:39 AM
What is the best way to plot a pixel in a three dimensional graph based on the mouse position on the screen? When the user presses the mouse button the pixel should appear

where the mouse cursor is (which can be an infinite number of points going away from
the cursor position). I am guessing I should start by calculating a vector that
represents all posible values where the point could be plotted. Then I would need to
decide how far from the viewer to plot the point. I just have no idea how to go about
this mathematically.

This is for a simple project I am working on as part of my opengl education. I decided
to create a program that I can use to generate vertex arrays of scenes more quickly than coding glVertex3f() a million times and figuring out all the vertices by hand.

Rob The Bloke
08-14-2003, 01:33 AM

08-14-2003, 10:15 AM
Thank you for the reply. I had thought about trying to use gluUnProject but I came across a slight problem.

The gluUnProject function maps window coordinates to object coordinates.

int gluUnProject(
GLdouble winx,
GLdouble winy,
GLdouble winz,
const GLdouble modelMatrix[16],
const GLdouble projMatrix[16],
const GLint viewport[4],
GLdouble * objx,
GLdouble * objy,
GLdouble * objz

I believe that this function is used when you are trying to get the coordinates of an object that already exists. I am trying to figure out where to plot the object (in this case a point). I am going to look around some more on this function to see if I can actually use it. I will check back latter.

08-14-2003, 11:02 AM
sorry to have questioned you. I tried gluUnProject and so far it works perfectly. I just needed to set the winz variable to zero. Thanks a lot ya bloke.