Week04
(1)
1-1. 在 https://jsyeh.org/3dcg10,下載data , win32
1-2. 解壓縮,把data放到windows裡
1-3.開Transformation.exe
1-4.選AI Capone
1-5.轉動方向
1-5-1.y軸
(2)glut-rotate
2-1 File-New-Project , 開GLUT
2-2. 設定freeglut
2-3. 程式碼全刪
2-4.茶壺
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(90,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMainLoop();
}
2-5.旋轉後會回原位
#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();
}
void motion(int x,int y)
{
angle = x ;
display();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2-6.旋轉之後留在旋轉後的位置
#include <GL/glut.h>
float angle=0, oldX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
angle += (x-oldX) ;
oldX=x;
display();
}
void mouse(int button,int state,int x,int y)
{
oldX=x;
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
(3)改時間
3-1.開git 小黑窗
3-2.git clone https://github.com/ajie4jellyfish/2022graphics1
git status --> git add .--> git status
git config --global user.email "selinalu2002@gmail.com"
-->git config --global user.name "ajie4jellyfish"
-->git commit -m "add week04" --date "2022-03-09 12:00:00"
-->git push
沒有留言:
張貼留言