2016年5月9日 星期一

[討論] 有沒有遇過坐上去搖兩下就喊累的女生

HW-1 複習

Step 1: 去小葉老師的網站下載這三個檔
Step 2:
把windows & data 解壓縮然後把data文件夾跟 glut32.dll 丟進windows 資料夾裡

Step 3:點transform.exe
就可以得到一台車車

                                    Step 4: 點右上角視窗右鍵,可以得到其他的3D圖形


                                                                             HW-2
下載Source
這三個檔很重要
編譯器跟linker 要選freeglut資料夾裡的Include 跟 lib
把source 裡的這三個檔案拖曳專案資料夾裡
你就可以得到車車
HW-3
#include <GL/glut.h>
#include "glm.h"
GLMmodel * pmodel=NULL;

void display()
{
    glClearColor(1,0,0,0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if(!pmodel) {

        pmodel = glmReadOBJ("data/porsche.obj");                   //別人寫好的程式  偷來用
    if(!pmodel) exit(0);
    glmUnitize(pmodel);
    glmFacetNormals(pmodel);
    glmVertexNormals(pmodel, 90.0);
    }
glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);

    glutSwapBuffers();
}
nt main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
    glutCreateWindow("My GLM!");
    glutDisplayFunc(display);
}
你可以得到一台 2D的車車
HW-4


#include <GL/glut.h>
#include "glm.h"
GLMmodel * pmodel=NULL;

void display()
{
    glClearColor(1,0,0,0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if(!pmodel) {

        pmodel = glmReadOBJ("data/porsche.obj");                   //別人寫好的程式  偷來用
    if(!pmodel) exit(0);
    glmUnitize(pmodel);
    glmFacetNormals(pmodel);
    glmVertexNormals(pmodel, 90.0);
    }
    glRotatef(90, 0,1,0);//旋轉
    glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);

    glutSwapBuffers();
}
GLfloat pos[]={0.0,0.0,-1.0,0.0};
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE |GLUT_DEPTH);
    glutCreateWindow("My GLM!");
    glutDisplayFunc(display);

    glLightfv(GL_LIGHT0,GL_POSITION,pos);//加燈光
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);//深度偵測
    glutMainLoop();

}
然後可以得到一台D的車車
備註...可以用滑鼠改變他的方向



沒有留言:

張貼留言