1.練習期中考題
2017電腦圖學 Computer Graphics 授課教師: 葉正聖 銘傳大學資訊傳播工程系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
2017年6月12日 星期一
2017年6月11日 星期日
week_06 劉念慈的上課筆記
課堂作業一:
glPushMatrix( );// 備份矩陣 10%
glRotatef(angle,x,y,z);// 旋轉30%
glTranslatef(x,y,z);// 縮放40%
glBegin(GL_POLYGON);// 開始畫60%
glNormal3f(nx,ny,nz);// 打光的法向量90%
glTexCoord2f(tx,ty);//貼圖座標100%
課堂作業二 : 階層轉動
程式碼
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glutSolidTeapot(0.3);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glTranslatef(0.5, 0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業三: T-R-T
課堂作業四: 矩陣
glPushMatrix( );// 備份矩陣 10%
glRotatef(angle,x,y,z);// 旋轉30%
glTranslatef(x,y,z);// 縮放40%
glBegin(GL_POLYGON);// 開始畫60%
glNormal3f(nx,ny,nz);// 打光的法向量90%
glTexCoord2f(tx,ty);//貼圖座標100%
課堂作業二 : 階層轉動
程式碼
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glutSolidTeapot(0.3);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glTranslatef(0.5, 0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業三: T-R-T
課堂作業四: 矩陣
程式碼
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glColor3f(1,0,0); glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5,0.14,0);
glRotatef(mouseX, 0,0,1);
glTranslatef(0.41,-0.05,0);
glColor3f(1,1,1); glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2017年6月5日 星期一
Week 06 OW李寧OW
茶壺旋轉
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);///3.把整個下面的東西移到紅色茶壺嘴
glRotatef(mouseX, 0,0,1);///2.會轉動
glTranslatef(0.41, -0.05,0);///1.把手把移到轉盤的中心
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
期中考題
glPushMatrix(); //備份矩陣
glTranslatef(x,y,z); //移動
glRotatef(angle,x,y,z); //旋轉
glScalef(x,y,z); //縮放
glBegin(GL_POLYGON); //開始畫多邊形
glNormal3f(nx,ny,nz); //打光法向量
glTexCoord2f(tx,ty); //貼圖座標
glColor3f(r,g,b); //顏色
glVertex3f(x,y,z); //頂點
glEnd(); //結束畫
glPopMatrix(); // 還原矩陣
glTranslatef(x,y,z); //移動
glRotatef(angle,x,y,z); //旋轉
glScalef(x,y,z); //縮放
glBegin(GL_POLYGON); //開始畫多邊形
glNormal3f(nx,ny,nz); //打光法向量
glTexCoord2f(tx,ty); //貼圖座標
glColor3f(r,g,b); //顏色
glVertex3f(x,y,z); //頂點
glEnd(); //結束畫
glPopMatrix(); // 還原矩陣
2017年4月26日 星期三
2017年4月1日 星期六
Lars'的圖學 week06
HW一 練習期中考題:
程式碼
|
用途
|
| glPushMatrix(); |
備份矩陣
|
glTranslatef(x,y,z);
|
移動
|
| glRotatef(角度x,y,z); | 旋轉 |
| glScalef(x,y,z); | 縮放 |
| glBegin(GL_POLYGON); | 開始畫 |
| glNormal3f(nx,ny,nz); | 打光的法向量 |
| glTexCoord2f(tx,ty); | 貼圖座標 |
| glColor3f(r,g,b); | 顏色 |
| glVertex3f(x,y,z); | 頂點 |
| glEnd(); | 結束畫 |
| glPopMatrix(); | 還原矩陣 |
HW二 旋轉茶壺關節:
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX,0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);
glRotatef(mouseX,0,0,1);
glTranslatef(0.41,-0.05,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2017年3月29日 星期三
不信你去問小麥他也說要緊繃
1.練習期中考題
glPushMatrix(); //備份矩陣
glTranslatef(x,y,z); //移動
glRotatef(角度,x,y,z); //旋轉
glScalef(x,y,z); //縮放glBegin(GL_POLYGON); //開始畫
glNormal3f(nx,ny,nz); //打光法向量
glTexCoord2f(tx,ty); //貼圖座標
glColor3f(r,g,b); //顏色
glVertex3f(x,y,z); //頂點
glEnd(); //結束畫
glPopMatrix(); //還原矩陣
2.讓茶壺轉~
有點像是變成機器人的關節
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX,0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);
glRotatef(mouseX,0,0,1);
glTranslatef(0.41,-0.05,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
glPushMatrix(); //備份矩陣
glTranslatef(x,y,z); //移動
glRotatef(角度,x,y,z); //旋轉
glScalef(x,y,z); //縮放glBegin(GL_POLYGON); //開始畫
glNormal3f(nx,ny,nz); //打光法向量
glTexCoord2f(tx,ty); //貼圖座標
glColor3f(r,g,b); //顏色
glVertex3f(x,y,z); //頂點
glEnd(); //結束畫
glPopMatrix(); //還原矩陣
2.讓茶壺轉~
有點像是變成機器人的關節
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX,0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);
glRotatef(mouseX,0,0,1);
glTranslatef(0.41,-0.05,0);
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2017年3月28日 星期二
Week 06 - 【狂喜屁股】洗屁股紀錄
Week06 劉旆君的上課筆記
●練習期中考題
glPushMatrix( ); //備份矩陣
glRotatef(angle , x , y , z); //旋轉
glTranslate(x , y , z); //移動
glScalef(x , y , z); //縮放
glBegin(GL_POLYGON); //開始畫
glNormal3f(nx, ny, nz); //打光的法向量
glTexCoord2f(tx, ty); //貼圖座標
glColor3f(r, g , b); //顏色
glVertex3f(x,y,z); //頂點
glEnd( ); //結束畫
glPopMatrix( ); //還原矩陣
●理解旋轉
先將
windows.zip data.zip glut32.dll
下載後會看到此圖即可觀察理解旋轉狀況
glTranslatef( )在前 glRotatef( ) 在後
會呈現一個車子自轉的效果,不論是移動到哪個位置,車子仍舊在移動到的地方自轉著
glRotatef( ) 在前 glTanslatef( ) 在後
會呈現一個車子公轉的效果,先旋轉後跟著跟個中心點 直繞著移動的感覺
●茶壺模擬機器手臂
step1
將兩個茶壺浮貼在一起
step2
加上滑鼠mouseX可以使用滑鼠來移動使茶壺旋轉但是會發現第一個茶壺的旋轉點在於另一個茶壺的中心點,但這並不是我們想要的效果點
step3
Week 06 GO!GO!Power Ranger!
期中考試程設表
glPushMatrix();//備份矩陣
glRotatef(angle, x, y, z);//旋轉
glTranslatef( x, y, z);//移動
glScalef( x, y, z);//縮放
glBegin(GL_POLYGON);//開始畫
glNormal3f(nx, ny, nz);//打光的法向量
glTexCoord2f( tx, ty);//貼圖座標
glColor3f( r, g, b);//顏色
glVertex3f(x, y, z);//頂點
glEnd();//結束畫
glPopMatrix();//還原矩陣

茶壺旋轉連接(TRT)
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);///3.把整個下面的東西移到紅色茶壺嘴
glRotatef(mouseX, 0,0,1);///2.會轉動
glTranslatef(0.41, -0.05,0);///1.把手把移到轉盤的中心
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
glPushMatrix();//備份矩陣
glRotatef(angle, x, y, z);//旋轉
glTranslatef( x, y, z);//移動
glScalef( x, y, z);//縮放
glBegin(GL_POLYGON);//開始畫
glNormal3f(nx, ny, nz);//打光的法向量
glTexCoord2f( tx, ty);//貼圖座標
glColor3f( r, g, b);//顏色
glVertex3f(x, y, z);//頂點
glEnd();//結束畫
glPopMatrix();//還原矩陣

茶壺旋轉連接(TRT)
#include <GL/glut.h>
float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);///3.把整個下面的東西移到紅色茶壺嘴
glRotatef(mouseX, 0,0,1);///2.會轉動
glTranslatef(0.41, -0.05,0);///1.把手把移到轉盤的中心
glColor3f(1,1,1);
glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
week06 陳琇雅 筆記
1.期中考
glPushMatrix();//備份矩陣
glTranslatef(x,y,z);//移動
glRotatef(角度x,y,z);//旋轉
glScalef(x,y,z);//縮放
glBegin(GL_POLYGON);//開始畫
glNormal3f(nx,ny,nz);//打光法向量
glTexCoord2f(tx,ty);//貼圖座標
glColor3f(r,g,b);//顏色
glVertex3f(x,y,z);//頂點
glEnd();//結束畫
glPopMatrix();//還原矩陣
2.階層轉動
3.實作:T-R-T
glPushMatrix();//備份矩陣
glTranslatef(x,y,z);//移動
glRotatef(角度x,y,z);//旋轉
glScalef(x,y,z);//縮放
glBegin(GL_POLYGON);//開始畫
glNormal3f(nx,ny,nz);//打光法向量
glTexCoord2f(tx,ty);//貼圖座標
glColor3f(r,g,b);//顏色
glVertex3f(x,y,z);//頂點
glEnd();//結束畫
glPopMatrix();//還原矩陣
2.階層轉動
3.實作:T-R-T
Week 6_04160373 梁家豪_洞叁倆八_上課筆記
Week 06
HW1_練習期中考題函式
glPushMatrix();//備份矩陣glRotatef(angle,x,y,z);//(旋轉角度,x,y,z)
glTranslatef(x,y,z);//移動
glScalef(x,y,z);//縮放
glBegin(GL_POLYGON);//開始畫
glNormal3f(nx,ny,nz);//打光的法向量
glTexCoord2f(tx,ty);//貼圖座標
glColor3f(r,g,b);//顏色
glVertex3f(x,y,z);//頂點
glEnd();//結束
glPopMatrix();//還原矩陣
HW2_理解函式運作邏輯
glPushMatrix();
glRotatef(angle,x,y,z);
glTranslatef(x,y,z);
glScalef(x,y,z);
glBegin(GL_POLYGON);
glNormal3f(nx,ny,nz);
glTexCoord2f(tx,ty);
glColor3f(r,g,b);
glVertex3f(x,y,z);
glEnd();
glPopMatrix();
glut函式具有階層性的轉動,先執行Begin(開始)~End(結束)函式及其內部函式。接續到外層的縮放(Scalef)、移動(Translatef)、在旋轉(Rotatef),由內而外的運行glut函式。
理解在在Transformation.exe檔中,可以利用右手來判別物體旋轉的方向。
Rotatef(x,y,y軸的方向,z)
HW3_T-R-T
#include <GL/glut.h>float mouseX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(mouseX, 0,0,1);
glColor3f(1,0,0);glutSolidTeapot(0.3);
glPushMatrix();
glTranslatef(0.5, 0.14,0);//把白色茶壺手把移動到紅色茶壺嘴
glRotatef(mouseX, 0,0,1);//step2滑鼠轉動
glTranslatef(0.41, -0.05,0);//step1 把手把移到轉盤位置
glColor3f(1,1,1); glutSolidTeapot(0.3);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX = x;
glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("TRT robot");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
訂閱:
文章 (Atom)









