2022年3月8日 星期二

豪哥的圖學筆記week03

1.開啟blogger寫今天的課堂作業

2.範例 jsyeh.org/3dcg10

3.下載 data,win32

windows.zip >  下載\windows\Transformation.exe

data.zip > 下載\windows\data\模型.obj

4.執行 Transformation.exe

(右上角)右鍵換模型




4.

    glPushMatrix();///備份矩陣
        glTranslated(x,y,0);
        glColor3f(1,1,0);
        glutSolidTeapot(0.3);
    glPopMatrix();///還原矩陣



茶壺程式碼

#include <GL/glut.h>
#include <stdio.h>
float mouseX=0,mouseY=0;
void myteatop(float x,float y){
        glPushMatrix();///備份矩陣
    ///移動會累積,因為它會修改矩陣
        glTranslatef(x, y , 0);//x,y,z方向
        glColor3f(1,1,0);
        glutSolidTeapot(0.3);
        glPopMatrix();///還原矩陣(還原舊的位置)
}
void display(){
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glBegin(GL_POLYGON);

glEnd();
    glutSwapBuffers();
}
void mouse(int button,int state,int x,int y){
    printf("glVertex2f((%d-150)/150.0,-(%d-150)/150.0);\n",x,y);
    mouseX=x;mouseY=y;
}
int main(int argc,char**argv){
    glutInit(&argc,argv);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("week03_mouse");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);

    glutMainLoop();
}



沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...