ICS 186A Winter 2003: Assignment 4 (Due 01/31/03)

What is to be done?

Verify if openGL is doing the right computation for the following Model View Transformations:

Details

Write my_glTranslate, my_glRotate, and my_glScale according to the following specifications:

Syntax:

·        void my_glTranslated(GLdouble* newmatrix, GLdouble x, GLdouble y, GLdouble z)

·        void my_glRotated( GLdouble* newmatrix, GLdouble angle, GLdouble x, GLdouble y, GLdouble z )

·        void my_glScaled(GLdouble* newmatrix, GLdouble angle, GLdouble x, GLdouble y, GLdouble z)

·        void my_gluLookAt(GLdouble* newmatrix, GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz)

Semantics:

Ok but how do you verify the openGL functions?

my_glTranslated(newmatrix, tx,ty,tz);

printMat(newmatrix) ;

glTranslated(tx,ty,tz);

glGetMatrix(tempmatrix);

printMat(tempmatrix);

if( compareMat(newmatrix, tempmatrix) ) printf("Matrix is wrong");

// compareMat raises the flag if the matrices don't match.

 

The above change is going to print a lot of matrices. Once you have verified your comparMat function correctly compares two matrices, you can remove the printMat statements. It need not be part of your submission.

Once you have verified that there is no statement displayed that “Matrix is wrong” (in other words, your matrix in newmatrix and OpenGl’s matrix in tempmatrix are the same all the time), then you should replace OpenGl’s computation of transformation with your computation of transformation as follows. For example, a glTranslated(tx,ty,tz) should be substituted by,

my_glTranslated(newmatrix, tx,ty,tz);

glLoadMatrix(newmatrix);

 

Once the above change works properly, you should use glLoadMatrix only when it is required. For example, if you are using a sequence of my_gl transformations, you should use glLoadMatrix only once, after all the my_gl transformations.

 

·         Check if your output is the same as before (your previous assignment submission). If so, then you have successfully emulated OpenGl transformation calls using your own my_gl transformation calls.

 

WHAT TO SUBMIT: Your final code after you have done all the above changes. In other words you code (a) does not have any of the following OpenGL’s transformation matrices: glTranslate, glRotate, glScale, and gluLookAt,  (b) runs with your implementation of these functions, and (c) uses minimum number of glLoadMatrix function call.

NOTE

·        OpenGL deals with matrices in COLUMN MAJOR order. This means for a matrix A represented by tempmatrix as: