PDA

View Full Version : glTranslate



Andrew Waller
01-29-2006, 10:23 AM
Hi all its a simple question really,

I want to know if there is any way to translate a static object to the screen so that it doesnt move when I move.

Does anybody know how to do this or have some sample code I could look at?

Cheers in Advance

airseb
01-30-2006, 04:16 AM
Hi,
can you say a little more about your question ?

Andrew Waller
01-30-2006, 04:53 AM
sure no problem I have a scene in opengl your basic cube stored in a display list.

when I add objects to the scene using gltranslate to move them into the position on the screen that I want them, I have problems when you move around the screen the model isn't static.

I was wondering if there was another way to do it apart from using glTransferf(x,y,z);

here is some of the code I have written:

LoadIdentity();
glMatrixModel(GL_MODELVIEW);
glPushMatrix():
gltranslated(x,y,z); // move into the scene
glRotate(sceneroty ,x,y,z);
glCallList(ROOM); // this is the cube you can move around in
glPopMatrix();
glPushMatrix();
glTranslated(x,y,z); // move model into the scene
glCallList(model);
glPopMatrix();
glMatrixModel(GL_MODELVIEW);

songho
01-30-2006, 06:23 AM
Andrew Waller,
Try this;

glMatrixModel(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix():
gltranslated(x,y,z);
glRotate(sceneroty ,x,y,z);
glCallList(ROOM);
glPopMatrix();
glPushMatrix();
glTranslated(x,y,z);
glCallList(model);
glPopMatrix();

Notice that glMatrixModel(GL_MODELVIEW) is called first and glLoadIdentity() is called as second.
And the last glMatrixModel(GL_MODELVIEW) is removed.
==song==

Andrew Waller
01-30-2006, 12:42 PM
:( that didnt work either. This is head wrecking. Anybody wanna take a look at the exe and the code to see if they can fix this for me? or suggest what Im doing wrong?

let me know and I will email it to you to take a look at?