   Pivot point rotation
  Hi,    I am using OpenGL for visualization purpose. Here I am using quaternion for Eye  matrix computation. I am planning to extend the rotation for selected pivot point.    I used the existing logic, move the model to origin and then apply the rotation matrix and finaly move back to the original position.    I am not getting the proper result.    The following are code that I used   { /* Clear the buffer */glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );  /* Set draw mode Orthographic */  float lhsToRhsMirror[16] = {  1.0 ,  0.0 ,  0.0 ,  0.0 , 0.0 ,  1.0 ,  0.0 ,  0.0 , 0.0 ,  0.0 , -1.0 ,  0.0 , 0.0 ,  0.0 ,  0.0 ,  1.0 };glMatrixMode   ( GL_MODELVIEW );glLoadIdentity ();glMatrixMode   ( GL_PROJECTION );glLoadIdentity ();glOrtho   ( -xdist , xdist , -refDist, refDist, nearP , farP );glMultMatrixf ( lhsToRhsMirror );    /* Translate the model to origin */    double darrTrgCrds[3]; /* Model original center */    double darrSelPivotPt[3]; /* Selected pivot point */    /* Translate the model in negative direction from original center to selected point */ glTranslated(-(darrTrgCrds[0] - darrSelPivotPt[0]),  -(darrTrgCrds[1] - darrSelPivotPt[1]),  -(darrTrgCrds[2] - darrSelPivotPt[2])); /* apply model view matrix, prepared using Right direction,  up direction, sight direction and eye position */   double darrEye[3]; /* Eye position, usually half of the bounding box    diagonal distance along sight direction */    E[ 0] = T[0];E[ 1] = T[4]; Right direction from quatrenion E[ 2] = T[8];E[ 3] = 0.0;E[ 4] = T[1];E[ 5] = T[5]; Up direction from quatrenion E[ 6] = T[9];E[ 7] = 0.0;E[ 8] = T[2];E[ 9] = T[6]; sight direction from quatrenion E[10] = T[10];E[11] = 0.0;E[12] = -T[0]* darrEye[0] - T[1]* darrEye[1] - T[ 2]* darrEye[2];E[13] = -T[4]* darrEye[0] - T[5]* darrEye[1] - T[ 6]* darrEye[2];E[14] = -T[8]* darrEye[0] - T[9]* darrEye[1] - T[10]* darrEye[2];E[15] = 1.0;    /* Multiply the prepared model view matirx */    glMatrixMode ( GL_MODELVIEW );glLoadIdentity (); glMultMatrixd ( E );    /* Move back to the original origin, model center */    glTranslated((darrTrgCrds[0] - darrSelPivotPt[0]),  (darrTrgCrds[1] - darrSelPivotPt[1]),  (darrTrgCrds[2] - darrSelPivotPt[2])); /* Draw actual content */    Could any one help me to locate the proplem Thanks    
  There is a lot of code here that is funky to read.  Try using the code tag which is   paste stuff  to give us more readable code.Generally, to rotate around a point, all you need to do is glTranslatef to the pivot point, do your glRotatef(angle,x, y, z), then undo your glTranslatef back to your drawing position, draw the item, then translate back to the pivot point, do a glRotatef(-angle,x,y,z), and then finally translate back to drawing point.Ya dig?   ;Quote:Original post by zer0sumTry using the code tag which is   paste stuff  to give us more readable code[source][/source] would probably be better ('source' gives you a nice scrollable code box with syntax highlighting, while 'code', I believe, only preserves whitespace and gives you a monospace font).   ;  Sorry for posted code.  Basically I am preparing modelview matrix to view the model. To prepare a matrix, I am using eye position, right, sight and up direction. When I use this matrix, it is always rotating about the screen center, but I palnning to rotate about specific center. To do that, In my code, before applying the matrix, I have translated the model using "glTranslated" to specific point, then apply the matrix and then bring it back to the original position. firts time, It is rotating about the center, but model is moving form its original position. Second time onwards, it is not working based on given specific point. Is the way am I following is correct?.   