顯示具有 Week04 標籤的文章。 顯示所有文章
顯示具有 Week04 標籤的文章。 顯示所有文章

2018年6月24日 星期日

Week 04 潘家智的筆記

從老師的網站http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載data、win32、glut32.dll 這三個檔案
將win32解壓縮然後把glut32.dll 放入window資料夾
執行Transfromation


安培右手定則
glRotatef( 角度, X軸, Y軸, Z軸);
X軸:正值>右手大拇指向右   轉動向內
        負值>右手大拇指向左   轉動向外
Y軸:正值>右手大拇指向上   轉動向內
        負值>右手大拇指向下   轉動向外
Z軸:正值>右手大拇指向內   逆時針轉動
        負值>右手大拇指向外   順時針轉動



期中考考題


可以轉動的茶壺

#include <stdio.h>
#include <GL/glut.h>
float angle=0,teapotX=0,teapotY=0;
int oldX=0,oldY=0,nowRotate=0;///

void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);///
        glRotatef(angle,0,0,1);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    ///printf("%.1f\n",angle);
    ///angle++;
}
void mouse(int button,int state,int x,int y)
{
    if(button==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)nowRotate=1;
    if(button==GLUT_RIGHT_BUTTON&&state==GLUT_DOWN)nowRotate=0;
    oldX=x;oldY=y;///

}

void motion(int x,int y)
{
    if(nowRotate==1)angle+=(x-oldX);
    else
    {
        teapotX += (x-oldX)/150.0;///
        teapotY += (oldY-y)/150.0;///
    }
    oldX=x; oldY=y;
    glutPostRedisplay();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("05160133_week04 transformation");
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    ///glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}


2018年6月4日 星期一

WEEK04 QAQ筆記

WEEK04:移動、旋轉、縮放
                     複習上週:move 移動


任務一:Transformation.exe

datawin32glut32.dll 
解壓縮win32
glut32.dlldata放進wnidow資料夾

1.開啟Transformation.exe

2.按右鍵選取AI Capone,並拉動綠色的值,就可以調整模型的角度
(可參考"安培右手法則")


任務二:期中考

glPushMatrix();   //備份矩陣
   glTranslatef(x,y,z);   //移動
   glRotatef(angle,x,y,z);   //轉動
   glScalef(x,y,z);   //放大縮小
   glBegin(GL_POLYGON);   //開始畫
      glColor3f(r,g,b);   //顏色
      glVertex3f(x,y,z);   //頂點
   glEnd();   //結束畫 glBegin()對應
glPopMatrix();   //還原矩陣


任務三:畫出可自動旋轉的茶壺

1.自動旋轉茶壺












#include <stdio.h>
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle,0,0,1); ///旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    printf("%.1f\n",angle);
    angle++; ///每次角度加1度
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("05160806_teapot_rotating");

    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}


2.手動旋轉茶壺(用滑鼠)











#include <stdio.h>
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();   
        glRotatef(angle,0,0,1);   ///旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix(); 
    glutSwapBuffers();
    angle++;   ///每次角度加一度
}
void mouse(int button, int state, int x,int y)
{

}
void motion(int x, int y)
{///Now:當mouse在drag motion時
    angle=x;   ///改變angle值
    glutPostRedisplay();
}
int main(int argc,char *argv[])
{
    glutInit(&argc, argv); 
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week04");
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    glutDisplayFunc(display);
    glutMainLoop();  
}


3.最終版 (用滑鼠轉起來比較順了)











#include <stdio.h>
#include <GL/glut.h>
float angle=0,teapotX=0,teapotY=0;
int nowRotate=0,oldY=0,oldX=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);///2種模式
    glPushMatrix();
        glTranslatef(teapotX,teapotY,0);
        glRotatef(angle,0,0,1);///旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();///交換畫面buffer便會顯示
    ///Now:printf("%.1f\n",angle);
}
void mouse(int button,int state,int x,int y)
{
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=1;
    if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) nowRotate=0; 
    oldX=x;oldY=y;///Now2:按下去的時候,把oldX,oldY記起來!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
void motion(int x,int y)
{
    if(nowRotate==1) angle+=(x-oldX);///Now:取改變angle值 ///Now2:加上改變量
    else{
                 teapotX+=(x-oldX)/150.0;///Now2:加上改變量!!!!!!!!!!!!!!
                teapotY+=(oldY-y)/150.0;///Now2:加上改變量!!!!!!!!!!!!!!

    }
    oldX=x;oldY=y;///Now2:做完計算時把oldX,oldY記起來!!!!!!!!!!
    glutPostRedisplay();///Now:請畫面重畫
}
int main(int argc, char**argv)///進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week04");
    glutMouseFunc(mouse);//Now:mouse
    glutMotionFunc(motion);//Now:motion
    ///Now:glutIdleFunc(disolay);///很閒/Idle,去重畫
    glutDisplayFunc(display);///等一下樓上要準備 void display()
    glutMainLoop();
}

Week15_馬明

2018-06-04
Week15
(1)下週期末作品展示
(2)主題:學期內容回顧
(3)問題Q&A

TODO:

Week1:
1.WebGL
2.跑OpenGL

Week2:
1.GLUT專案

Week3:

移動旋轉縮放
跑Transformation.exe
glutSolidTeapot(半徑)
glutSolidSpagere(半徑,切,切)
gltuSolidCone(半徑,切,切)

Week4:Rotate,矩陣
Week5:T-R-T,特定軸
Week6:glm 3D模型
#include "glm.h"
GLM *pmodel = NULL
畫圖:
(
if(pmodel==NULL)
///讀入模型
{
glmReadOBJ("...");
縮放,glmUnitize(),法向量.
}
glmDran()
小心舊的 Strdup()會不相容

Week7:
小心 CodeBlocks專案 & Setting-Compiler
要設對glm.cpp 才行compile

Working_dir要設成"."

libfreeglut.dll  COPE>>專案目錄

Week8:打光.陣列
Week10:
貼圖
OpenCV
設目錄link
秀圖
Week11:
keyboard配PlaySound()變成鍵盤鋼琴
mouse配PlaySound()變成射擊遊戲

CMP3_MCI.h可撥MP3

2018年3月25日 星期日

Week04 來福的汪汪圖學週記

開模型觀察旋轉方向
(滑鼠要按照他的軸向拉才能調整)
轉旋轉軸
 
 
glRotatef(轉幾度, X軸,Y軸,Z軸)
旋轉方向看右手定則 ( 拇指是軸向  四指轉向 )

 
 


旋轉茶壺的程式
 
 
 
#include <stdio.h>
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();///備份矩陣
        glRotatef(angle,0,0,1);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    printf("%.1f\n",angle);
    angle++;///角度增加
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week04 旋轉");

    glutIdleFunc(display);///重新畫
    glutDisplayFunc(display);
    glutMainLoop();///重複反覆
} 
 
 
手拉旋轉茶壺>>4-1
 
 
新增mouse跟motion函式
(轉更順)
 
void mouse(int but,int state,int x,int y)
{
    if(but==GLUT_LEFT_BUTTON&&state==GLUT_DOWN)
        nowRotate=1;
    if(but==GLUT_RIGHT_BUTTON&&state==GLUT_DOWN)n
        oldRotate=0;
    oldX=x;
  oldY=y;
}



void motion(int x,int y)

{
    if(nowRotate==1)
    angle+=(x-oldX);
    else
    {
        teapotX += (x-oldX)/150.0;
        teapotY += (oldY-y)/150.0;
    }
    oldX=x;
  oldY=y;
    glutPostRedisplay();
}
 

2018年3月19日 星期一

Week04_+0筆記

下載: http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
 1.data  2.win32  3.glut32.dll
調整旋轉角度 glRotatef
自動旋轉

#include <GL/glut.h>//使用GLUT外掛
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    angle++;//每次角度加1度
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutIdleFunc(display);//很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}

手動旋轉
老師的

我的

#include <GL/glut.h>//使用GLUT外掛
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    angle++;//每次角度加1度
    //Now:printf("%.1f\n",angle);///Now:angle++;//每次角度加1度
}
void mouse(int button,int state,int x,int y)
{
}
void motion(int x,int y)
{///Now:當mouse在drag motion時
    angle=x;//Now:去改變angle值
    glutPostRedisplay();//Now:請畫面重畫
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutMouseFunc(mouse);//Now:mouse
    glutMotionFunc(motion);//Now:motion
    ///Now:glutIdleFunc(disolay);///很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}

移動旋轉

#include <stdio.h>
#include <GL/glut.h>//使用GLUT外掛
float angle=0,teapotX=0,teapotY=0;
int nowRotate=0,oldY=0,oldX=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glTranslatef(teapotX,teapotY,0);
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    //Now:printf("%.1f\n",angle);///Now:angle++;//每次角度加1度
}
void mouse(int button,int state,int x,int y)
{
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=1;
    if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) nowRotate=0;
    oldX=x;oldY=y;
}
void motion(int x,int y)
{///Now:當mouse在drag motion時
    if(nowRotate==1) angle+=(x-oldX);
    else{
                 teapotX+=(x-oldX)/150.0;
                teapotY+=(oldY-y)/150.0;

    }
    oldX=x;oldY=y;
    glutPostRedisplay();//Now:請畫面重畫
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutMouseFunc(mouse);//Now:mouse
    glutMotionFunc(motion);//Now:motion
    ///Now:glutIdleFunc(disolay);///很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}

Week04史蒂芬的課堂筆記

一.下載

http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
從網站中下載3個檔案
1.data
2.win32
3.glut32.dll
將windows.zip解壓縮glut32.dll放入資料夾
data也解壓縮(注意data資料夾只能有一層)
開啟Transformation
去調整旋轉角度
glRotatef(旋轉角度,x軸,y軸,z軸)
加入自動旋轉
#include <GL/glut.h>//使用GLUT外掛
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    angle++;//每次角度加1度
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutIdleFunc(display);//很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}
加入手動旋轉
#include <GL/glut.h>//使用GLUT外掛
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    angle++;//每次角度加1度
    //Now:printf("%.1f\n",angle);///Now:angle++;//每次角度加1度
}
void mouse(int button,int state,int x,int y)
{
}
void motion(int x,int y)
{///Now:當mouse在drag motion時
    angle=x;//Now:去改變angle值
    glutPostRedisplay();//Now:請畫面重畫
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutMouseFunc(mouse);//Now:mouse
    glutMotionFunc(motion);//Now:motion
    ///Now:glutIdleFunc(disolay);///很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}
移動旋轉
#include <stdio.h>
#include <GL/glut.h>//使用GLUT外掛
float angle=0,teapotX=0,teapotY=0;
int nowRotate=0,oldY=0,oldX=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//2種模式
    glPushMatrix();//備份矩陣
        glTranslatef(teapotX,teapotY,0);
        glRotatef(angle,0,0,1);//旋轉angle度
        glutSolidTeapot(0.3);
    glPopMatrix();//還原矩陣
    glutSwapBuffers();//交換畫面buffer便會顯示
    //Now:printf("%.1f\n",angle);///Now:angle++;//每次角度加1度
}
void mouse(int button,int state,int x,int y)
{
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=1;
    if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) nowRotate=0;
    oldX=x;oldY=y;
}
void motion(int x,int y)
{///Now:當mouse在drag motion時
    if(nowRotate==1) angle+=(x-oldX);
    else{
                 teapotX+=(x-oldX)/150.0;
                teapotY+=(oldY-y)/150.0;

    }
    oldX=x;oldY=y;
    glutPostRedisplay();//Now:請畫面重畫
}
int main(int argc, char**argv)//進階的main()參數(個數,字串)
{
    glutInit(&argc,argv);//進階參數,初始GLUT
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);//開始2種模式
    glutCreateWindow("Week04");//盡量不要用中文
    glutMouseFunc(mouse);//Now:mouse
    glutMotionFunc(motion);//Now:motion
    ///Now:glutIdleFunc(disolay);///很閒/Idle,去重畫
    glutDisplayFunc(display);//等一下樓上要準備 void display()
    glutMainLoop();//主要迴圈
}

Week 04 安淇的課堂筆記

1.下載檔案
http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載
windows.zip
data.zip
glut32.dll

2.期中考題:
glPushMatrix();   //備份矩陣
   glTranslatef(x,y,z);   //移動
   glRotatef(angle,x,y,z);   //轉動
   glScalef(x,y,z);   //放大縮小
   glBegin(GL_POLYGON);   //開始畫
      glColor3f(r,g,b);   //顏色
      glVertex3f(x,y,z);   //頂點
   glEnd();   //結束畫  與glBegin()對應
glPopMatrix();   //還原矩陣

3.自動旋轉
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle,0,0,1);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    angle++;
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("Week04");
    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}

Week04 ㄩㄐ的流浪日常

Week03教學內容

(1)到jsyeh.org/3dcg10

下載

①windows.zip ➤ Transformation.exe
②data.zip ➤ 很多模型
③glut32.dll



噹啷~~~~~~~~~






(2)開啟隨意檔案,試 glRotatef (angle, x, y, z);


嘗試各種旋轉軸


以及各種模型


(3)轉轉茶壺




#include <stdio.h>
#include <GL/glut.h>

float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix(); /*備份矩陣*/
        glRotatef(angle, 0, 0, 1); /*旋轉角度*/
        glutSolidTeapot(0.3);
    glPopMatrix(); /*還原矩陣*/
    glutSwapBuffers();
    printf("%.1f\n", angle);
    angle++; /*每次角度+1*/
}

int main(int argc, char*argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week04_Transformation");

    glutIdleFunc(display); /*重畫*/
    glutDisplayFunc(display);
    glutMainLoop();
}

↑程式碼長這樣 

(4)加入拖曳茶壺的程式
int nowRotate=0/*0=translate, 1=rotate*/

void motion(int button, int state, int x, int y)
{
   /*當滑鼠在操作時*/
   angle=x;
   glutPostRedisplay();
}

這時會發現茶壺移動的方式很奇怪
於是更改motion並加入mouse程式碼及移動座標

float angle=0, teapotX=0, teapotY=0;
int oldX=0oldY=0, nowRotate=0;

void mouse(int button, int state, int x, int y)
{
   if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWNnowRotate=1/*左鍵則旋轉*/
   if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWNnowRotate=0/*右鍵則移動*/
   oldX=x; oldY=y;
}

void motion(int button, int state, int x, int y)
{
   if(nowRotate == 1) angle=x;
   else
   {
      teapotX += (x-150) / 150.0;
      teapotY += (150-y) / 150.0;;
   }
   oldX=xoldY=y;
   glutPostRedisplay();
}

Week 04 ------ 想狩獵

1.將data.rar解壓縮成資料夾,放到windows資料夾裡,注意只能有一個data目錄,點開範例Transformation.exe

2.程式碼
glRotatef(角度, x軸, y軸, z軸);///旋轉
glScalef(x軸, y軸, z軸);///放大縮小

3.整段程式碼
#include <stdio.h>
#include <GL/glut.h>
float angle=0, teapotX=0, teapotY=0;///要轉的角度、移動的座標
int oldX=0, oldY=0, nowRotate=0;///0:移動 1:旋轉
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glTranslatef(teapotX, teapotY, 0);///轉完再移動
    glRotatef(angle,0,0,1);///旋轉
    glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    ///printf("%.1f\n",angle);///印出目前度數
    ///angle++;///增加一度
}
void mouse(int button, int state, int x, int y)
{
    if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN) nowRotate=1;
    ///如果是左鍵就旋轉
    if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN) nowRotate=0;
    ///如果是右鍵就移動
    oldX=x;///按下去時把oldX、oldY紀錄
    oldY=y;
}
void motion(int x,int y)
{
    ///當滑鼠在drag motion時
    if(nowRotate==1) angle+=(x-oldX);///改變angle值,加上改變量
    else
    {
        teapotX+=(x-oldX)/150.0;///加上改變量
        teapotY+=(oldY-y)/150.0;
    }
    oldX=x;///做完計算時把oldX、oldY紀錄
    oldY=y;
    glutPostRedisplay();///讓畫面重畫
}
int main(int argc ,char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GL_DEPTH);
    glutCreateWindow("05161252_Week04");
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    ///glutIdleFunc(display);///Idle重畫
    glutDisplayFunc(display);
    glutMainLoop();
}