PDA

View Full Version : move object on screen



lenna
12-26-2004, 06:02 AM
Hi, I'm probably the newest openGL programer!

I have a working application in which the user can control a cursor shaped as 'L', so it will perfectly match a target shaped as 'L' as well.

the application is 3D, so the match should be sensitive to orientation of 'L' cursor and target in space.

as I mentioned the application is already programmed (by someone else).

my job is to implement an automatic procedure that performs the process described above - something like a demo.

I know how to get the absolute location of the three vertices of the 'L' shape (both for cusrsor and target). my general plan is to calculate the distances between x/y/z axis of cursor and target, and then to give the cursor new coordinates closer and closer to the target until they perfectly match.

I'll just mention that the way I retrieve the cursor and target absolute coordinates while drawing them is by using the code:


GLdouble Cursor_modelview[16];
GLdouble Target_modelview[16];
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);and calculate the distances between cursor's and target's coresponding vertices (x/y/z) as follows:


x_Distance = Cur_modelview[12]-Cur_modelview[12]
y_Distance = Cur_modelview[13]-Cur_modelview[13]
z_Distance = Cur_modelview[14]-Cur_modelview[14] ooof..it's long!

Q1) how do I set the cursor's new location (so it will get closer to the target)?
Q2) is there a function like glSETDoublev (so, I'll be ablt to set in the array new values and it will be draw later accordingly).

THANKS FOR YOUR HELP. AS YOU CAN SEE I KNOW NOTHING IN OPENGL.

zukko
12-26-2004, 03:36 PM
have you tried with glTranslatef(); ?