   loaded model won't translate to desired position
  Hi there,I am a newbie in opengl programming and now a days developing a basic 3D space racing game in which,I am able to load .obj model of a spaceship to my program but the problem is I am not able to place it in front of camera neither do I am able to move it using keyboard. Before I have sucessfuly achieved this effect using a color cube in place of spaceship I think I am doing some mistake while calculating the coordinates...Can you guyz help.... here are the piece of code concerning the spaceship and camera:float carlocx=0, carlocy=0.5, carlocz=48, graus=180; [CAR COORDINATES]int fps=0, displayList=0;GLfloat x=0.0f,y=1.75f,z=50.0f,angle=0.0; [CAMERA COORDINATES]GLfloat lx=0.0f,ly=0.0f,lz=-1.0f;GLMmodel* f16;void drawspaceship(){  glPushMatrix();glScalef(0.5,0.5,0.5);glRotatef(graus, 0.0, 1.0, 0.0);glTranslatef(carlocx,carlocy,carlocz);glCallList(displayList);glPopMatrix();}void display(){   //sOME CODE TO DRAW ENVIRONMENT NONE OF THEM INVOLVES MANIPULATION OF   //////COORDINAES PUSHMATRIX() AND POPMATRIX ARE USED WHILE DRAWING THEM  drawspaceship();}void movemeforward() // FUNCTION TO MOVE FORWARD{  x = x + i*(lx)*0.1;  z = z + i*(lz)*0.1;  glLoadIdentity();  gluLookAt(x, y, z,x + lx,y + ly,z + lz,0.0f,1.0f,0.0f);}void keyboard(){  //CODE FOR OTHER KEYS  case 'w':if(throttle<=20){  throttle+=2;  moveMeFlat(throttle);  display();break; } else  {   moveMeFlat(20);   display();break;   }//REST OF THE CODE}int main(int argc, char **argv) {int i;printf("\n Enter the name of player: ");gets(playername);glutInit(&argc, argv);glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);glutInitWindowPosition(50,50);glutInitWindowSize(640,360);glutCreateWindow("Sudh");glutKeyboardFunc(processNormalKeys);glutSpecialFunc(SpecialKeys);initboundingbox();glutReshapeFunc(myreshape);glutIdleFunc(display);glutTimerFunc(1000,mytimer,1);glutDisplayFunc(display);myinit();glLightfv(GL_LIGHT0, GL_POSITION, lightPos);glEnable(GL_DEPTH_TEST);glEnable(GL_LIGHTING);glEnable(GL_LIGHT0);glEnable(GL_COLOR_MATERIAL);f16 = (GLMmodel*)malloc(sizeof(GLMmodel));f16 = glmReadOBJ("C:/.../Desktop/glm-example/objs/f16.obj");displayList=glGenLists(1);glNewList(displayList,GL_COMPILE);glmDraw(f16, GLM_SMOOTH);glEndList();    glutMainLoop();return 0;}Code quality is not so good but emphasis was on the simplicity.....Any suggestion to make changes in the code are Welcome but they must be simple to implement...plz help and find out mistakes....   
  Can you repost your code using [source] tags?   ;  Here's the code...[SOURCE]float carlocx=0, carlocy=0.5, carlocz=48, graus=180; [CAR COORDINATES]int fps=0, displayList=0;GLfloat x=0.0f,y=1.75f,z=50.0f,angle=0.0; [CAMERA COORDINATES]GLfloat lx=0.0f,ly=0.0f,lz=-1.0f;GLMmodel* f16;void drawspaceship(){glPushMatrix();glScalef(0.5,0.5,0.5);glRotatef(graus, 0.0, 1.0, 0.0);glTranslatef(carlocx,carlocy,carlocz);glCallList(displayList);glPopMatrix();}void display(){//sOME CODE TO DRAW ENVIRONMENT NONE OF THEM INVOLVES MANIPULATION OF //////COORDINAES PUSHMATRIX() AND POPMATRIX ARE USED WHILE DRAWING THEMdrawspaceship();}void movemeforward() // FUNCTION TO MOVE FORWARD{x = x + i*(lx)*0.1;z = z + i*(lz)*0.1;glLoadIdentity();gluLookAt(x, y, z,x + lx,y + ly,z + lz,0.0f,1.0f,0.0f);}void keyboard(){//CODE FOR OTHER KEYScase 'w':if(throttle<=20){throttle+=2;moveMeFlat(throttle);display();break;}else{moveMeFlat(20);display();break;}//REST OF THE CODE}int main(int argc, char **argv) {int i;printf("\n Enter the name of player: ");gets(playername);glutInit(&argc, argv);glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);glutInitWindowPosition(50,50);glutInitWindowSize(640,360);glutCreateWindow("Sudh");glutKeyboardFunc(processNormalKeys);glutSpecialFunc(SpecialKeys);initboundingbox();glutReshapeFunc(myreshape);glutIdleFunc(display);glutTimerFunc(1000,mytimer,1);glutDisplayFunc(display);myinit();glLightfv(GL_LIGHT0, GL_POSITION, lightPos);glEnable(GL_DEPTH_TEST);glEnable(GL_LIGHTING);glEnable(GL_LIGHT0);glEnable(GL_COLOR_MATERIAL);f16 = (GLMmodel*)malloc(sizeof(GLMmodel));f16 = glmReadOBJ("C:/.../Desktop/glm-example/objs/f16.obj");displayList=glGenLists(1);glNewList(displayList,GL_COMPILE);glmDraw(f16, GLM_SMOOTH);glEndList();glutMainLoop();return 0;}[/SOURCE].....And can any one tell me the way to tilt the model lill bit...I am not able to get the transforations properly...   ;  I didn't look at all the code, but I did notice that you appear to applying the transforms for your ship in the wrong order. The elements of a model transform are usually applied in the order scale->rotation->translation, which in OpenGL terms would translate to the following code:void drawspaceship(){    glPushMatrix();    glTranslatef(carlocx,carlocy,carlocz);    glRotatef(graus, 0.0, 1.0, 0.0);    glScalef(0.5,0.5,0.5);    glCallList(displayList);    glPopMatrix();}Note the order in which the transform functions are called.It also looks like you might be handling your transforms incorrectly overall. It looks to me like you're setting the camera transform whenever the camera position changes, perhaps with the thought that OpenGL will somehow 'remember' the camera transform until the next time the camera moves. That isn't how OpenGL works though. OpenGL is a state machine: there is only one modelview matrix active at any one time, and it's up to you to make sure that it's set up in a meaningful way before you render anything.   