2024年3月14日 星期四

week04 11160933

 #week04

0.安裝freeglut, 重複之前的動作

1.week04_mouse_glScalef

2.加十行程式

3.乾淨背景  

  glClearColor(1.0, 1.0, 0.9, 1.0);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


4.貼上周的rotate motion指令

float angle = 0;


void motion(int x, int y)

{

    angle = x;

    display();

}

glutMotionFunc(motion);


glPushMatrix();

        glRotatef(angle, 0, 0, 1);

        glutSolidTeapot( 0.3 );



5.加scale指令

float s = 1;

glScaled(s, s, s);

s = 1 + (150)/150.0;


6.new project week04_keyboard_mouse_motion

7.貼上十行

8.void keyboard


9.加

    glutMouseFunc(mouse);

    glutMotionFunc(motion);

void mouse(int button, int state, int x, int y)

{

    oldX = x;

}

void motion(int x, int y)

{

    angle += (x-oldX);

    oldX = x;

    display();

}


10.加

    glPushMatrix();

        glRotatef(angle, 0, 0, 1);

        glutSolidTeapot( 0.3 );

    glPopMatrix();




11.開啟https://jsyeh.org/3dcg10/

download data win32

open transformation



12.new project week04_translate_rotate_scale

13.貼上上一個 刪一點

14.加    glutIdleFunc(display);

angle++



15.右邊

glTranslatef(0.8, 0, 0);

變小

glScalef(0.3, 0.3, 0.3);


16.顏色

glClearColor( 0.0, 1.0, 0.9, 1.0);

glColor3f(1, 0, 0);


17.new project week04_rotate_translate_scale

18.兩行交換

glRotatef(angle++, 0, 0, 1);

glTranslatef(0.8, 0, 0);
























沒有留言:

張貼留言