2024年4月18日 星期四

week09 電腦圖學

 主題: T-R-T 關節的階層性轉動


week09-0_sample
1.安裝freeglut 再把 lib\libfreeglut.a 複製成libglut32.a
2.建立GLUT專案


複習上週的week08-3專案
1.設環境=>OpenCV=>小心:Add PATH=>小心:目錄不要改
2.重開CodeBlocks
3.Setting-Compiler加入三個設定
   =>C:\OpenCV2.1\include
   =>C:\OpenCV2.1ib
   =>cv210、cxcore210、highgui210
4.把上週的GitHub倉庫複製下來
   =>安裝Git,開啟Git Bash 小黑
   =>cd desktop
   =>git clone https://github.com/帳號/2024graphicsa
   =>cd 2024graphicsa
   =>start .
5.開啟上週的week08-3_glm_gundam_opencv_texture_lighting
   =>File-Open-到那個目錄=點開 .cbp(CodeBlocks Project檔案)
   =>Build&Run



week09-1_glm_gundam_opencv_texture_lighting
1.把剛剛的專案,先關起來Close Project (這樣才不會被鎖)
2.目錄:把整個week08-3_glm_gundam_opencv_texture_lighting複製到桌面的week09-         1_glm_gundam_opencv_texture_lighting
3.檔案:把新目錄裡的專案檔week08-3_glm_gundam_opencv_texture_lighting.cbp改檔名變成week09-1_glm_gundam_opencv_texture_lighting.cbp
4.CodeBlocks File-Open 開啟week09-1_glm_gundam_opencv_texture_lighting.cbp
5.再把專案的Title改成week09-1_glm_gundam_opencv_texture_lighting
   =>用Notepad++開啟week09-1_glm_gundam_opencv_texture_lighting.cbp,把裡面的week08-3  都改成week09-1,再存檔
6.再用Codeblocks File-Open 開啟cbp檔
7.記得把main.cpp裡的week08 Gundam改成week09-1 Gundam



week09-2_glutSolidTeapot_glutSolidCube_glutSolidSphere
1.建立專案
2.貼上GLUT程式11行程式碼
3.換畫另外3個(左上、上、右上)
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///備份矩陣
        glTranslatef(-0.5, +0.3, 0);
        glutSolidTeapot(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.0, +0.3, 0);
        glutSolidCube(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.5, +0.3, 0);
        glutSolidSphere(0.3, 30, 30);
    glPopMatrix();///還原矩陣

glutSwapBuffers();
}
int main(int argc, char*argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week09 Microsoft Visual Studio");
glutDisplayFunc(display);
glutMainLoop();
}




week09-3
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///備份矩陣
        glTranslatef(-0.5, +0.3, 0);
        glutSolidTeapot(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.0, +0.3, 0);
        glutSolidCube(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.5, +0.3, 0);
        glutSolidSphere(0.3, 30, 30);
    glPopMatrix();///還原矩陣

    glPushMatrix();///備份矩陣
        glTranslatef(-0.5, -0.3, 0);
        glutWireTeapot(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.0, -0.3, 0);
        glutWireCube(0.3);
    glPopMatrix();///還原矩陣
    glPushMatrix();///備份矩陣
        glTranslatef(+0.5, -0.3, 0);
        glutWireSphere(0.3, 30, 30);
    glPopMatrix();///還原矩陣


glutSwapBuffers();
}
int main(int argc, char*argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week09 Microsoft Visual Studio");
glutDisplayFunc(display);
glutMainLoop();
}














沒有留言:

張貼留言