TimmyPrograming
TimmyPrograming

Reputation: 31

old JOGL, order of transformation

I have to solve a problem and I realize it is a bit oldschool code..

I need to write down the order of transformations from 1 to 4 and the result for pruple vertex. Would someone help me check whether it is correct and if not - why?

JOGL code

It is a bit tough for me to find answers to this and be 100% sure it is correct.

What I think is correct: 1. Start from bottom, take MODELVIEW first, then PROJECTION - Yet I am not sure I did it right...

EDIT, code rewritten to text:

gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glTranslatef(-1, -1, -0);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glScalef(2, 1, 3);
gl.glRotatef(-90, 0, 0, 1);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glScalef(2, 3, 1);


gl.glBegin(GL.GL_QUADS);
gl.glColor3f(0, 0, 1);
gl.glVertex3f(-2, -2, -2);
gl.glColor3f(1, 1, 0);
gl.glVertex3f(2, 1, 3);
gl.glColor3f(1, 0, 1);
gl.glVertex3f(1, 1, -2);
gl.glColor3f(0, 1, 0);
gl.glVertex3f(-1, 1, 2);
gl.glEnd();

Write the transformations as they go in order and write the coordinate changes of purple vertex for each transformation.

Transform 1:________________ Coordinates x:_______ y:_______ z: _______

Transform 2:________________ Coordinates x:_______ y:_______ z: _______

Transform 3:________________ Coordinates x:_______ y:_______ z: _______

Transform 4:________________ Coordinates x:_______ y:_______ z: _______

Upvotes: 1

Views: 136

Answers (1)

TimmyPrograming
TimmyPrograming

Reputation: 31

Problem solved

  • supposed to start with model transforms and then projection, always from the bottom
  • apply transforms from bottom

Also, I was accidentally using wrong coordinates..

~thanks for help though!

Upvotes: 1

Related Questions