Week15-1
今天上課先去小葉老師的網站(https://jsyeh.org/3dcg10/)下載windows和data
windows要解壓縮然後把data壓縮檔中的檔案拉到windows中
然後開啟projection的檔案
然後其中的center值則會改變方向
然後其中的up值則會改變角度
然後安裝git下載前幾周的檔案
cd desktop
git clone https://github.com/dannyyu0521/2023graphicsb
cd 2023graphicsb
然後開啟glut專案
今天的第一個程式week15-1gluLookAt
在第135行加入以下程式碼
float eyeX=0,eyeY=0;
void motion(int x,int y){
eyeX=3*(x-320)/320.0;
eyeY=3*(240-y)/240.0;
glLoadIdentity();
gluLookAt(eyeX,eyeY,-3,0,0,-6,0,1,0);
glutPostRedisplay();
}
然後154行再加入一行
glutMotionFunc(motion);
Week15-2
今天的第二個程式
新開一個glut專案
然好將第36行註解然後加入一行新的程式
///glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
glOrtho(-ar*3,ar*3,-1.0*3,1.0*3,2.0,100.0);
/// glOrtho(-ar*3,ar*3,-1.0*3,1.0*3,2.0,100.0);
然後加入gluPerspective(60,ar,0.01,1000);
視野又不一樣了
Week15-3
今天的第三個程式
程式碼如下
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void motion(int x,int y)
{
glLoadIdentity();
float eyeX=(x-150)/150.0,eyeY=(150-y)/150.0;
gluLookAt(eyeX,eyeY,1,0,0,0,0,1,0);
glutPostRedisplay();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week15");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
最後在上傳到GITHUB
cd desktop
git clone https://github.com/dannyyu0521/2023graphicsb
cd 2023graphicsb
將檔案放入資料夾
git status
git add .
git status
git config --global user.email dannyyyu0521@gmail.com
git config --global user.name dannyyu0521
git commit -m "add week15"
git push
沒有留言:
張貼留言