Anyway, as you can see I don't know very much. I've just been doing opengl tutorials lately and some redbook/bluebook stuff as well trying to pickup how to use it. I'm progressing ok, but I've been out of school for awhile so I've forgotten a lot of the maths and it's really not that easy to get back into it without examples :) I was pretty good at math back then I should be able to relearn but it's been long enough that just hearing it outright sounds confusing.
So if someone is willing i could use some help in understanding exactly how I would calculate a specific point on the line. I'm sure it's easy to those still doing math constantly but a bit confusing to someone who hasn't done it in a few years.
If you are interested in the relavent code I have so far it'd be
void PositionGLObject(int mousex, mousey){
GLfloat x, y, z; // allocate memory for the x, y, z position
GLint viewport[4]; //stores viewport information
GLdouble modmatrix[16], projmatrix[16];
glGetIntegerv(GL_VIEWPORT, viewport); //transfers viewport info into viewport array.
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
glGetDoublev(GL_MODELVIEW_MATRIX, modmatrix);
// invert mousey so that down lowers value
mousey = viewport[3] - mousey;
gluUnProject((GLdouble) mousex, (GLdouble) mousey, 1.0, projmatrix, modmatrix, &x, &y, &z);
cout<<"X: "<<x<<"Y: "<<y<<"Z: "<<z<<endl; //print out values
}
Feel free to correct me if I'm doing anything wrong there! Basically I'm just going to set a global variable during the function that will move the object around. I'm doing a simple program on my own to teach myself, tutorials only get me so far so I do my own thing to truly understand what I'm actually doing.
In this scenario the object I'm selecting is translated in glTranslate(0.0, 0.0, -4.0); like that, but obviously the math should work for any distance upon the line so it shouldn't really matter.












