2020年3月24日 星期二

week4.汪

week4上課內容
1.Transformation移動旋轉
 老師還為了讓我們更加理解竟然還站在椅子上示範+上安培右手定則的示範

                                                             使用滑鼠控制 
glutMotionFunc(motion); //加入了mouce的函式 可提mouce的動態
void motion(int x,int y)//mouce motion現在動到哪裡
 myAngle=x; //我的角度x值
 float myAngle=0; //變數的宣告
 const double a =  myAngle; //把角度塞進去















簡易版!!
#include<GL/glut.h>
float myAngle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//清除殘影
    glPushMatrix();
        glRotatef(myAngle,0,0,1);//對z軸做旋轉
        glutSolidTeapot(0.3);
        glPopMatrix();
        glutSwapBuffers();
}
    void motion(int x,int y)
    {
        myAngle=x;我的角度
        display();每次做動作 就重劃畫面

    }
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week 04 rotate");
    glutMotionFunc(motion);//加入motion函式
    glutDisplayFunc(display);
    glutMainLoop();

}
優化版
優化後可以準確拉到目標
如何在Maya裡轉動3D模型
1.mouse按下去
                                                                     2.mouse動
                                                                     3.mouse放開



沒有留言:

張貼留言