1.
1-1. 進入老師的網站jyseh.org/3dcg10找到example的data跟win32下載下來,將它們都解壓縮,將data放進windows裡,打開transformation.exe
1-2.開啟新的GLUT專案,觀察兩種
2.
2-1 用老師openGL_TRT_demo程式打開來跑,按下ToDraw可以畫身體、頭、手...可以按住程式碼,移動它的位置,可以先只放一個旋轉(在手的前面,只影響手臂)他會對正中心轉,看起來會怪怪的。改成移動後讓手臂的關節轉移到正中心後,再來把轉動給加上去,手臂會在肚臍的位置轉動,最後把移動給加上去,讓旋轉中的手臂成功掛到肩膀上
2-2.講解下週的考試題目範例,以奇異博士的手旋轉來做講解
3.
3-1.開新GLUT專案,命名為week05-2_robot,寫出一個機械手臂旋轉的程式
#include <GL/glut.h>
float angle=0;
void mycube()///step2改函式
{
glPushMatrix();///step1
glScalef(0.5,0.2,0.2);///step調大小
glutSolidCube(1);///step1 正方體
glPopMatrix();///step1
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);///白色
glutSolidCube(1);///身體
glPushMatrix();///step2
glTranslatef(0.5,0.5,0);///右上角
glRotatef(angle,0,0,1);///轉它
glTranslatef(0.25,0,0);///往右邊移動0.25能讓關節在正中心
glColor3f(1,1,0);///黃色的
mycube();///step2改函式
glPopMatrix();///step2
glPushMatrix();
glTranslatef(-0.5,0.5,0);///左上角
glRotatef(angle,0,0,1);///轉它
glTranslatef(0.25,0,0);///往右邊移動0.25能讓關節在正中心
glColor3f(1,1,0);///黃色的
mycube();///step2改函式
glPopMatrix();///step2
glutSwapBuffers();
angle++;
}
int main(int argc,char* argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week05");
glutDisplayFunc(display);
glutIdleFunc(display);
glutMainLoop();
}



沒有留言:
張貼留言