今日課程內容:
1.使用老師提供的網站(http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/)
1.先下載win32, data, glut32.dll2.將win32, data解壓縮後將所有資料放入windows資料夾
3.打開Light Material.exe
需要調整的是上方字型大的部分
GLfloat light_pos
GLfloat light_Ka --- a代表Ambient
GLfloat light_Kd --- d代表Diffuse
GLfloat light_Ks --- s代表Specular
環境光Ambient
漫射光Diffuse
止まるんじゃねぇぞ...
|
ₘₙⁿ
▏n
█▏ 、⺍
█▏ ⺰ʷʷィ
█◣▄██◣
◥██████▋
◥████ █▎
███▉ █▎
◢████◣⌠ₘ℩
██◥█◣≫
██ ◥█◣
█▉ █▊
█▊ █▊
█▊ █▋
█▏ █▙
█
GLfloat light_Ka --- a代表Ambient
GLfloat light_Kd --- d代表Diffuse
GLfloat light_Ks --- s代表Specular
環境光Ambient
漫射光Diffuse
鏡面光Specular
2.按照老方法開啟glut
1.讀入每周慣例的茶壺
2.更改程式碼使茶壺可以自行轉動
#include <GL/glut.h>
float x=0,y=0;
float angle=0;//開始角度
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//滑鼠移動
glPushMatrix();
glRotatef(angle,0,1,0);//以角度決定旋轉
glColor3f(0.8,0.6,0);
glutSolidTeapot(0.3);
glPopMatrix();
angle++;//角度++,可調整角度以增加速度
glutSwapBuffers();
}
void motion(int nowx,int nowy)
{
x=nowx; y=nowy;//滑鼠移動
display();
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week05 translate 06160095");
glutDisplayFunc(display);
glutIdleFunc(display);//需要,否則不會自動旋轉
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
glutMotionFunc(motion);//執行
glutMainLoop();
}
|
ₘₙⁿ
▏n
█▏ 、⺍
█▏ ⺰ʷʷィ
█◣▄██◣
◥██████▋
◥████ █▎
███▉ █▎
◢████◣⌠ₘ℩
██◥█◣≫
██ ◥█◣
█▉ █▊
█▊ █▊
█▊ █▋
█▏ █▙
█
沒有留言:
張貼留言