[CSC 315] Small Packages

Andrew J. Pounds pounds_aj at mercer.edu
Mon Nov 21 10:16:54 EST 2022


Nobody has reached out to me about needing assistance in class 
tomorrow.  Since it was going to be a "workday", I am officially 
cancelling class tomorrow.  You can still come use the lab if you would 
like.

Now -- some gifts come in small packages... and since we are are not 
having class tomorrow, and since I have not seen any houses "moving", I 
wanted to give you a snippet of code (a small package) that is found in 
my own 3D house code.  I have replaced my "pipeline code", which built 
the translation and rotation matrices and applied them to the 
coordinates, with the following OpenGL transformations.

void pipeline(void)
{
    spinX(); spinY(); spinZ();
    glRotatef(SPIN_ANGLE_X,1.0,0.0,0.0);
    glRotatef(SPIN_ANGLE_Y,0.0,1.0,0.0);
    glRotatef(SPIN_ANGLE_Z,0.0,0.0,1.0);
    glutPostRedisplay();
}

where the SPIN_ANGLE_X,Y,Z global variables are modified by their 
representative functions...

voidspinX(void)
{
SPIN_ANGLE_X = SPIN_ANGLE_X + DELTA_SPIN_X;
if(SPIN_ANGLE_X > 360.0)SPIN_ANGLE_X = SPIN_ANGLE_X - 360.0;
}

and the  DELTA_SPIN_X,Y,Z global variables are set in the mouse function.

You are welcome to use this coding paradigm in your own code. Remember 
to call glutPostRedisplay after you change the state of your graphics 
window ( you will also need to make sure that you have double buffering 
set up correctly).

I hope this helps you - and please let me know if you have questions.  I 
may not have internet access on Wednesday - but if I do I will be 
answering questions.


-- 
*Andrew J. Pounds, Ph.D.*
/Professor of Chemistry and Computer Science/
/Director of the Computational Science Program/
/Mercer University, Macon, GA, 31207 (478) 301-5627 /
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc315/attachments/20221121/1910308f/attachment.html>


More information about the csc315 mailing list