week10-1_glutWireCube_myBody_myArm
安裝freeglut,把freeglut/lib/libfreeglut.a複製改名成libglut32
打開codeblock新增專案
把上週的專案程式碼貼上
glutWireCube(x)
x=中心到四周的距離
所以x=0.3 Cube的邊長就是0.6
加上 glColor3f() 跟 glScalef() 可以更改大小跟顏色
把打好的程式變成函式,就可以用呼叫的方法畫出圖
week10-2_rotate_myArm
用week10-1的程式複製貼上
要有一個 float angle=0的程式
在main()裡加上 glutIdleFunc(display);
在display裡,myArm前後要加上glutPushMatrix glPopmatrix跟 glRotatef(angle++,x,y,z)
week10-3_rotate_translate_myArm
用week10-2的程式複製貼上
加上gltranslatef()
把旋轉中心放到正中間
再加上一行 gltranslatef()
把它放到要旋轉的地方
week10-5_TRT_TRT_myArm
用week10-4的程式複製貼上
然後在myArm()後面插入
glPushMatrix();
glTranslatef(0.15,0,0);///(3)放到肩膀上
glRotatef(angle++,0,0,1);///(2)旋轉角度
glTranslatef(0.15,0,0);///(1)把旋轉中心放到正中間
myArm();
glPopMatrix();
week10-6_left_right_myArm
用week10-5的程式複製貼上
然後複製
glPushMatrix();///右邊
glTranslatef(0.3,0.3,0);///(3)放到肩膀上
glRotatef(angle++,0,0,1);///(2)旋轉角度
glTranslatef(0.15,0,0);///(1)把旋轉中心放到正中間
myArm();///右手臂
glPushMatrix();
glTranslatef(0.15,0,0);///(3)放到肩膀上
glRotatef(angle++,0,0,1);///(2)旋轉角度
glTranslatef(0.15,0,0);///(1)把旋轉中心放到正中間
myArm();///右上臂
glPopMatrix();
glPopMatrix();
再貼到glPopMatrix後面
week10-7_mouse_motion_angle_myArm
貼上week10-6的程式
想要用滑鼠控制,所以angle++改成angle
在main()加glutMotionFunc(motion);
加一個void(int x,int y)
week10-8_mouse_motion_angle_2_myArm
貼上week10-7的程式
把angle改成負的
讓左右邊的角度相反
week10-9_PlaySound
在#include的地方加入#include<mmsystem.h>
在main()的第一行加入PlaySound("C:\\Users\\Administrator\\Desktop\\2024-graphicsA\\week10\\horse.wav",NULL,SND_ASYNC);
執行程式就能發出聲音
Git 指令
cd desktop
git clone https://github.com/mickey1132/2024-graphicsA
cd 2024-graphicsA
git status
git add .
git status
git config --global user.email mickylin1132@gmail.com
git config --global user.name mickey1132
git commit -m WeekXX
git push
沒有留言:
張貼留言