 # Rotation and Translation in openGL

I’m rally new in openGL and already have some problems 
I’m loading meshes, extracted from 3D images, and the meshes have always different orientations. My task at the university is to transform the meshes in two defined orientations. Here is the orientations axis:

1. x = (1,0,0), y=(0,1,0) and z=(0,0,1) //axial view
2. x = (1,0,0), y=(0,0,1) and z=(0,-1,0) // sagital view

For the loaded mesh I can compute the orientation and the origin. So I defined a transformation matrix which is build from the inverse orientation of the mesh and the negative origin. In other words I transform first the mesh into its origin:

transMat(0,0) = ax; transMat (0,1) = ax; transMat (0,2) = ax; transMat (0,3) = -org;
transMat (1,0) = ay; transMat (1,1) = ay; transMat (1,2) = ay; transMat (0,3) = -org ;
transMat (2,0) = az; transMat (2,1) = az; transMat (2,2) = az; transMat (0,3) = -org ;
transMat (2,0) = 0; transMat (2,1) =0 ; transMat (2,2) =0; transMat (0,3) = 1;

mesh->ApplyTransformation(transMat) ;

and then I apply the new orientation, e.g for case number 1:

ax = (1,0,0);
ay =(0,1,0);
az=(0,0,1) ;

transMat(0,0) = ax; transMat (0,1) = ax; transMat (0,2) = ax; transMat (0,3) = org;
transMat (1,0) = ay; transMat (1,1) = ay; transMat (1,2) = ay; transMat (0,3) = org ;
transMat (2,0) = az; transMat (2,1) = az; transMat (2,2) = az; transMat (0,3) = org ;
transMat (2,0) = 0; transMat (2,1) =0 ; transMat (2,2) =0; transMat (0,3) = 1;

mesh->ApplyTransformation(transMat) ;

with this two operation I have the mesh in the required orientation. However, my supervisor at the university said I should not transform the mesh itself, but to use the MODEL_VIEW matrin in openGL in order to get the same required orientation. And here start my problem 

Here is how the openGL is initialized:

VVector3Dd eyeVector = VVector3Dd(0.0, 0.0, 150.0);
upVector = VVector3Dd(0.0, 1.0, 0.0);

void init()
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
}

void display()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

``````glPushMatrix();
gluLookAt(eyeVector, eyeVector, eyeVector, 0.0, 0.0, 0.0, upVector, upVector, upVector);

renderMesh();
glPopMatrix();
glutSwapBuffers();
``````

}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
``````glOrtho(-0.1 * w/2, 0.1 * w/2, -0.1 * h/2, 0.1 * h/2, 0.0, 1000.0);