顯示具有 40447021S_黃詠勝 標籤的文章。 顯示所有文章
顯示具有 40447021S_黃詠勝 標籤的文章。 顯示所有文章

2018年1月4日 星期四

Arthus week8

week8

Texture 貼圖
OPen CV的安裝,讀圖
open GL的貼圖設定
EX:轉動地球

http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載data、windows、glut32、source把date和glut32.dll放入windows資料夾裡
到moodle中下載OpenCV-2.1.0-win32-vs2008.exe
安裝過程中選第3個選項
打開codeblocks開專案檔console application複製貼上
#include <opencv/highgui.h>
int main()
{
IplImage * img=cvLoadImage("earth.jpg");
cvNamedWindow("hello");
cvShowImage("hello", img);
cvWaitKey(0);
return 0;
}
codeblocks設定中改成->Build options->Search directories
Search directories->Compiler->Add directory : c:\opencv2.1\include
Search directories->Linker->Add directory : c:\opencv2.1\lib
Linker setting->Add library : cv210 
Linker setting->Add library : cxcore210 
Linker setting->Add library : highgui210
下載圖檔並放到專案檔中

2017年11月30日 星期四

Arthus week12

week12

在moodle下載myGL_Frustum211_MultiView執行exe黨


打開glut專案黨執行程式碼並編譯


----------------------------------------------------------------------------------------------------------------
在moodle 下載processing在選單案速寫本選引用文件庫 並添加

關掉重開
選擇文件 範例程式
選contrubuted libraries
選collada 選viewer2d


執行


--------------------------------------------------------------
打開picking中的simple

執行





2017年10月26日 星期四

Arthus week07

week7

滑鼠打光

step1:打開glut專案檔
在main中加入glutMotionFunc(motion);

step2:加入新的function
void motion(int x,int y)
{
    light_position[0]= (x-150)/150.0 *3;
    light_position[1]= -(y/150)/150.0 *2;
    glLightfv(GL_LIGHT0,GL_POSITION,light_position);
    glutPostRedisplay();
}

step3:把 const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
const刪掉
step4:完成

2017年10月19日 星期四

Arthus week6

week06

step1:下載glut32.dll windows.zip data.zip source.zip 並解壓縮到桌面


step2:去moodle下載week5
week5打開cbp檔


step3:去setting compiler 把c++11的勾勾取消

 

step4:執行


step5:打開transformation.c 搜尋light


step6 :打光程式碼
GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };
glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, pos);



step7:執行


step8:加入keyboard mouse
#include<stdio.h>
.
.
.
void keyboard (unsigned char key, int x, int y){
printf("now:%c (%d %d)\n",key,x,y);}
void mouse (int button,int state ,int x, int y)
{
printf("now: %d %d (%d %d)\n",button,state,x,y);
}
在int main()
{
.
.
.
glutCreateWindow("week06");
glutDisplayFunc(display);
glutKeyboardFunc(Keyboard);
glutMouseFunc(mouse);
glutMainLoop();
}



step9:執行


keyboard讓東西轉 

step10:加 int rotateX=0,rotateY=0,rotateZ=0
在keyboard function中加入
    if(key=='1') rotateX++;
    if(key=='2') rotateY++;
    if(key=='3') rotateZ++;
glutPostRedisplay();///使得東西馬上更新
在display function中的drawmodol()前後加glPushMatrix()跟glPopMatrix()
並在前面加入
       glRotatef(rotateX,1,0,0);
        glRotatef(rotateY,0,1,0);
        glRotatef(rotateZ,0,0,1);
讓物體旋轉


step11:執行


MOUSE讓東西轉

step12:先加入int oldX=0,oldY=0;
在mouse function中加入
if(state==GLUT_DOWN)
    {
        oldX=x;
        oldY=y;
    }
並新增
void motion(int x, int y)
{
    rotateY+= -(x-oldX);
    rotateX+= -(y-oldY);
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
在main中新增glutMotionFunc(motion);


step13:執行

2017年10月12日 星期四

week05

複習week4

到jsyeh.org/3dcg10/下載data.zip windows.zip glut32.dll並全部放到桌面


執行Transformmation.exe並自己玩玩


執行Projection.exe 玩玩perspective



玩玩glOrtho跟glulookat




2017年10月5日 星期四

Arthus week4

week4

打造第一個會旋轉的茶壺(移動)

step1:打開glut專案黨到display 函式

step2:增加茶壺進入每個
glPushMatrix();備份矩陣
glPopMatrix();還原矩陣
之間
並更改顏色

step3:glTranslatef(x,y,z) 
glRotatef(旋轉角度,對x軸做,y,z)
glScalef(x放大,y放大,z放大)


step4:執行

完成拉!!!!!!!

2017年9月28日 星期四

Arthus week3

week3 
1.小小兵
step1:下載學姐的檔案
sss
step2:使用codeblocks的glut專檔開啟(先下載)
step3:使用編譯執行

完成!!!

2.3DExploration
step1:google 3DExploration並下載
step2:去jsyeh.org/3dcg10下載data
step3:打開3DExploration將data的檔案放入並存檔save as成cpp
然後選simple app
step4:打開openGL專案黨 放入程式碼
step5:編譯並執行
完成拉!!!!~~~~

2017年9月21日 星期四

Arthus Week2

親手打造的第一個茶壺圖學程式

step1:打開一個glut專案檔
step2:刪減程式碼到剩下這樣
step3:新增一個茶壺的程式碼
glutSolidTeapot(0.3)
step4:為茶壺加上顏色(打在茶壺的程式碼之前)
glColor3f(R,G,B) 
[3f代表三個顏色的浮點數]
[RGB範圍從1~0]
step5:執行
完成!!!!!!

親手打造的第一個3D圖學程式

step1:打開一個glut專案檔
step2:刪減程式碼到剩下這樣
step3:為接下來的圖形加上顏色
glColor3f(R,G,B) 
[3f代表三個顏色的浮點數]
[RGB範圍從1~0]
step4:打上一個多邊形
glBegin(GL_POLYGON);//新增一個多邊形
    glVertex3f(1,1,0);//輸入第一個點的座標
    glVertex3f(-1,1,0);//第二個
    glVertex3f(0,-1,0);//可以加很多很多個
    glEnd();//多邊形結束
step5:執行
完成!!!!