2018年3月19日 星期一

Week04_阿天筆記

一:
下載[data],[win32], glut32.dll 跟第一周一樣先解壓縮win32,把glut32.dll與data放到解完壓縮的win32裡




二:
開啟windows裡的Transformation.exe就可以移動,旋轉,縮放裡面的模型了


三:
老師說旋轉是按照安培右手定則,像一根竹籤插進模型內,能很容易理解模型旋轉的方向是怎麼轉的


四:
把紅框框裡的程式碼藏起來後,圖形就不會轉了~~

(老師的圖)

五:
讓茶壺轉,並把轉的角度印出來 =>

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();  //備份矩陣
        glRotated(angle,0,0,1);  //轉的角度
        glutSolidTeapot(0.3);  //印茶壺
    glPopMatrix();        //還原矩陣
    glutSwapBuffers();
    printf("%.1f\n", angle);  //把所轉的角度印出來
 angle++;  //每次角度加1度

六:
可以用滑鼠按著左右移動轉動茶壺~~超酷的 =>


void mouse(int button, int state, int x, int y)
{        ///Now: 當mouse在drag motion時,

}
void motion(int x, int y)
{         ///Now: 當mouse在drag motion時,
    angle=x;        /// Now: 去改變angle值
    glutPostRedisplay();        ///Now: 請畫面重畫



    glutMouseFunc(mouse);   ///Now: mouse
    glutMotionFunc(motion);   ///Now: motion
       ///Now: glutIdleFunc(display):///很閒/Idle,去重畫


七:
右鍵移動滑,左鍵旋轉茶壺,跟maya的旋轉移動很像~


沒有留言:

張貼留言