顯示具有 02160083_廖峻賢 標籤的文章。 顯示所有文章
顯示具有 02160083_廖峻賢 標籤的文章。 顯示所有文章

2015年6月18日 星期四

02160083廖峻賢

資傳二乙 廖峻賢
我的想法是讓一個積木人活過來 並且雀躍的跳舞
影片呈現的看了就知道

https://youtu.be/4op9zmI3Ysc


#include <GL/glut.h>
#include <stdio.h>
#include "glm.h"
#include <math.h>
#include <mmsystem.h>

float a=0; float x=0;

FILE *fout=NULL; ///­n¦sÀɥΪº°Õ!
FILE * fin  =NULL;

GLMmodel *pmodel1=NULL;
GLMmodel *pmodel2=NULL;
GLMmodel *pmodel3=NULL;
GLMmodel *pmodel4=NULL;
GLMmodel *pmodel5=NULL;

float angle[10]={0};
    float angleOld[10]={0};
    float angleNew[10]={0};
float oldX=0, oldY=0;
int n;


void readNew()
{
    if(fin==NULL) fin=fopen("a.txt", "r");
    for(int i=0;i<10;i++)
    {   angleOld[i]=angleNew[i];
        fscanf(fin, "%f",&angleNew[i]);
        printf("%.1f ",angleNew[i]);
    }
    printf("\n");
}

void timerPlay(int t)
{
    glutTimerFunc(20, timerPlay, t+1);

    if(t%2==0) readNew();
    a=(t%2)/2.0;
    for(int i=0;i<10;i++)
    {
        angle[i]=(1-a)*angleOld[i]+(a)*angleNew[i];
    }
    glutPostRedisplay();
}


void keyboard(unsigned char key,int x,int y)
{
    if(key=='1')n=1;
    if(key=='2')n=2;
    if(key=='3')n=3;
    if(key=='4')n=4;
    if(key=='a')x-=0.1;
    if(key=='d')x+=0.1;
    if(key=='p')glutTimerFunc(10, timerPlay,0);
    if(key=='s')
    {
        if(fout==NULL) fout=fopen("a.txt", "w+");
    for(int i=0;i<10;i++)
    {
            printf(      "%.1f ",angle[i]);
            fprintf(fout, "%.1f",angle[i]);
    }
    printf("\n");
    fprintf(fout,"\n");
}



    glutPostRedisplay();


}
void drawBody(){
    glPushMatrix();
    glmDraw(pmodel1,GLM_SMOOTH|GLM_MATERIAL);
    glPopMatrix();
}

void display()
{
    { ///Lighting
    //glColor3ub(166,132,100);
    glClearColor(0.3,0.5,0,0);
    GLfloat pos[]={1, 0, -1, 0};
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
    glPushMatrix();
        glRotatef(x,0,1,0);
        glScalef(0.5,0.5,0.5);
        //glTranslatef(cos(x/20)*0.5,y,0);
        drawBody();
//////////////B
        glPushMatrix();
            glTranslatef(-0.3,0,-0.02);
            glRotatef(angle[1],90,100,-180);
            glTranslatef(0,-0.1,-0.3);
            glScalef(0.4,0.4,0.4);


///////////////A
            glmDraw(pmodel2,GLM_SMOOTH|GLM_MATERIAL);
        glPopMatrix();
        glPushMatrix();
            glTranslatef(0.4,0.3,-0.2);
            glRotatef(-angle[2],-90,0,-90);
            glTranslatef(-0.2,-0.4,0.05);
            glScalef(0.5,0.5,0.5);
//////////////AA
            glmDraw(pmodel3,GLM_SMOOTH|GLM_MATERIAL);
        glPopMatrix();
        glPushMatrix();
            glTranslatef(0.2,-0.65,0.5);
            glRotatef(angle[3],-0.5,0,0.5);
            glTranslatef(0,-0.5,-0.5);
            glScalef(0.3,0.3,0.3);
/////////////////BB
            glmDraw(pmodel4,GLM_SMOOTH|GLM_MATERIAL);
        glPopMatrix();
        glPushMatrix();
            glTranslatef(-0.035,-0.85,0);
            glRotatef(-angle[4],0.5,-0.2,0.8);
            glTranslatef(-0.1,-0.3,-0.2);
            glScalef(0.3,0.3,0.3);

            glmDraw(pmodel5,GLM_SMOOTH|GLM_MATERIAL);
         glPopMatrix();
    glPopMatrix();


    glFlush();
    x++;
}
void motion(int x, int y)
{
    angle[n] -= y - oldY;
    if(angle[n]>60)angle[n]=60;
    if(angle[n]<0)angle[n]=0;
    oldY=y; oldX=x;
    if(fout==NULL)fout=fopen("a.txt","w+");
    for(int i=0;i<8;i++)
    {
        fprintf(fout,"%.1f\t",angle[i]);
    }
    fprintf(fout,"\n");
}

void mouse(int button, int state, int x, int y){
    if(state==GLUT_DOWN) {
        oldX=x;
        oldY=y;
    }
}





void timer(int t)
{
    glutTimerFunc(20, timer, t+1);
    //angle++;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
  PlaySound("QQQQ.wav",NULL,SND_ASYNC);
    glutInit(&argc, argv);

    pmodel1=glmReadOBJ("body.obj");
    glmUnitize(pmodel1);
    glmFacetNormals(pmodel1);
    glmVertexNormals(pmodel1,90.0);

    pmodel2=glmReadOBJ("A.obj");
    glmUnitize(pmodel2);
    glmFacetNormals(pmodel2);
    glmVertexNormals(pmodel2,90.0);

    pmodel3=glmReadOBJ("B.obj");
    glmUnitize(pmodel3);
    glmFacetNormals(pmodel3);
    glmVertexNormals(pmodel3,90.0);

    pmodel4=glmReadOBJ("AA.obj");
    glmUnitize(pmodel4);
    glmFacetNormals(pmodel4);
    glmVertexNormals(pmodel4,90.0);

    pmodel5=glmReadOBJ("BB.obj");
    glmUnitize(pmodel5);
    glmFacetNormals(pmodel5);
    glmVertexNormals(pmodel5,90.0);

    glutCreateWindow("02160083");
    glutDisplayFunc(display);
    glutTimerFunc(20, timer, 0);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}

2015年6月11日 星期四

02160083廖峻賢

  1. 移動,旋轉,縮放
  2. T-R-T關節結構
  3. 存檔,讀檔,播放
  4. 內插動作Interpolate
  5. 期末作品






#include <GL/glut.h>
#include <stdio.h>
#include <math.h>
FILE * fout=NULL;
FILE * fin =NULL;
float oldX=0, oldY=0, x=0, y=0;
int angle[8] = {0}, angleOld[8], angleNew[8];
int now;

void readNew()
{
    if(fout==NULL) fout=fopen("a.txt", "w+");
    for(int i=0;i<8;i++){
        angleOld[i]=angleNew[i];
        fscanf(fin, "%f",&angleNew[i]);
        printf("%f ",angleNew[i]);
    }
    printf("\n");
}
void drawBody(){
    glPushMatrix();
    glScalef(1, 0.5, 0.5);
    glutSolidCube(1);
    glPopMatrix();
}
void drawArm(){
    glPushMatrix();
    glScalef(0.6, 0.3, 0.3);
    glutSolidCube(1);
    glPopMatrix();
}
void display()
{
    { ///Lighting
    glColor3ub(166,132,100);
    GLfloat pos[]={0, 0, -1, 0};
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glEnable(GL_LIGHT0);
    //glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
    glPushMatrix();
        glTranslatef(0.5, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
        glRotatef(angle[1], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
        glTranslatef(0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
        drawArm();///這是個Arm ver 1  Right Upper Arm
        glPushMatrix();
            glTranslatef(0.25, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
            glRotatef(angle[2], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
            glTranslatef(0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
            drawArm(); ///Right Lower Arm
        glPopMatrix();
    glPopMatrix();
    glPushMatrix();
        glTranslatef(-0.5, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
        glRotatef(-angle[3], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
        glTranslatef(-0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
        drawArm();///這是個Arm ver 1  Left Upper Arm
        glPushMatrix();
            glTranslatef(-0.25, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
            glRotatef(-angle[4], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
            glTranslatef(-0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
            drawArm(); ///Left Lower Arm
        glPopMatrix();
    glPopMatrix();
    drawBody();
    glFlush();
}
void motion(int x, int y)
{   angle[now] -= y - oldY;
    oldY=y; oldX=x;

    //if(fout==NULL) fout=fopen("a.txt", "w+");
    //for(int i=0;i<10;i++){
    //    printf("%f",angle[i]);
    //    fprintf(fout, "%f ",angle[i]);
    //}
    //printf("\n");
   // fprintf(fout,"\n");
}
void timerPlay(int t)
{

    glutTimerFunc(20, timerPlay, t+1);
    float a=(t%50)/50.0;
    if(t%50==0) readNew();
    for(int i=0;i<8;i++){
        angle[i]=(1-a)*angleOld[i]+(a)*angleNew[i];
    }
    glutPostRedisplay();
}
void keyboard(unsigned char key, int x, int y)
{
    if(key=='1')now=1;
    if(key=='2')now=2;
    if(key=='3')now=3;
    if(key=='4')now=4;
    if(key=='p')glutTimerFunc(20, timerPlay, 0);
    if(key=='s')
        if(fout==NULL) fout=fopen("a.txt", "w+");
        for(int i=0;i<8;i++)
        {
            fprintf(fout, "%.1f\t",angle[i]);
            printf("%.1f\t",angle[i]);
        }
    fprintf(fout,"\n");
    printf("\n");
}

void mouse(int button, int state, int x, int y){
    if(state==GLUT_DOWN) { oldX=x; oldY=y; }
}
void timer(int t)
{
    glutTimerFunc(20, timer, t+1);
    //angle++;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("T-R-T test");
    glutDisplayFunc(display);
    glutTimerFunc(20, timer, 0);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}



2015年6月4日 星期四

02160083 廖峻賢


  1. 複習上週 T-R-T
  2. 期中作品
  3. 建出全身關節
  4. 鍵盤滑鼠操控動作
  5. 存檔Play播放



#include <GL/glut.h>
#include <stdio.h>///寫檔案
FILE * fout=NULL;///file output
float oldX=0, oldY=0;
void drawBody(){
    glPushMatrix();
    glScalef(1, 0.5, 0.5);
    glutSolidCube(1);
    glPopMatrix();
}
void drawArm(){
    glPushMatrix();
    glScalef(0.6, 0.3, 0.3);
    glutSolidCube(1);
    glPopMatrix();
}
float angle[10];
int angleID=1;
//float angle1=0,angle2=0,angle3=0,angle4=0;
void display()
{
    { ///Lighting
    glColor3ub(166,132,100);
    GLfloat pos[]={0, 0, -1, 0};
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glEnable(GL_LIGHT0);
    //glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
    glPushMatrix();
        glTranslatef(0.5, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
        glRotatef(angle[1], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
        glTranslatef(0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
        drawArm();///這是個Arm ver 1  Right Upper Arm
        glPushMatrix();
            glTranslatef(0.25, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
            glRotatef(angle[2], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
            glTranslatef(0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
            drawArm(); ///Right Lower Arm
        glPopMatrix();
    glPopMatrix();
    glPushMatrix();
        glTranslatef(-0.5, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
        glRotatef(-angle[3], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
        glTranslatef(-0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
        drawArm();///這是個Arm ver 1  Left Upper Arm
        glPushMatrix();
            glTranslatef(-0.25, 0, 0);///最後一步, 把樓下的 "會對Arm Joint做旋轉的東西" 再移到右上 掛上去 ver 4
            glRotatef(-angle[4], 0,0,1);///把下面整團, 都對中間做旋轉 ver 3
            glTranslatef(-0.25, 0,0);///這是把它往右移, Arm Joint在中間 ver 2
            drawArm(); ///Left Lower Arm
        glPopMatrix();
    glPopMatrix();
    drawBody();
    glFlush();
}
void Keyboard(unsigned char key,int x, int y)
{
    if(key=='1') angleID=1;
    if(key=='2') angleID=2;
    if(key=='3') angleID=3;
    if(key=='4') angleID=4;
}

void motion(int x, int y)
{
    angle[angleID] -= y - oldY;
    oldY=y; oldX=x;

    if(fout==NULL) fout=fopen("a.txt", "w+");
    printf("%f",angle[1]);
    fprintf(fout, "%f \n",angle[1]);
}
void mouse(int button, int state, int x, int y){
    if(state==GLUT_DOWN) { oldX=x; oldY=y; }
}
void timer(int t)
{
    glutTimerFunc(20, timer, t+1);
    //angle++;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("T-R-T test");
    glutDisplayFunc(display);
    glutTimerFunc(20, timer, 0);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(Keyboard);
    glutMainLoop();
}

2015年5月28日 星期四

02160083_廖俊賢

  1. 期末作品
  2. 會跳舞的機器人
  3. T-R-T對關節轉
  4. 小考:T-R-T觀念
  5. 作業問題





































#include <GL/glut.h>
float angle=0, oldX=0, oldY=0;
void drawArm(){
    glPushMatrix();
        glScalef(0.5,0.25,0.25);
        glutSolidCube(1);
    glPopMatrix();
}
void drawBody(){
    glPushMatrix();
        glTranslatef(0,-0.5,0);
        glRotatef(-90,1,0,0);
        glutSolidCone(0.3,0.8,30,30);
    glPopMatrix();
    }
void display()
{

    {
        GLfloat pos[] = {0, 0, -1, 0};
        glLightfv(GL_LIGHT0,GL_POSITION, pos);
        glEnable(GL_LIGHT0);
        glEnable(GL_LIGHTING);
        }
        glEnable(GL_DEPTH_TEST);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glPushMatrix();
                glTranslatef(0.15,0,0);
                glRotatef(angle,0,0,1);
                glTranslatef(0.25 , 0, 0);
                drawArm();
            glPopMatrix();
        glPopMatrix();

        glPushMatrix();
                glTranslatef(-0.15,0,0);
                glRotatef(-angle,0,0,1);
                glTranslatef(-0.25 , 0, 0);
                drawArm();
            glPushMatrix();
        glPopMatrix();
        drawBody();
        glFlush();
}
void timer(int t)
{
    glutTimerFunc(20, timer,0);
    ///angle++;
    glutPostRedisplay();
}
void mouse (int button,int state,int x,int y)
{
    if(state==GLUT_DOWN) { oldX=x; oldY=y; }
}

void motion(int x, int y)
{
    angle += (x -oldX);
    oldX= x;
}
int main (int argc, char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hw");
    glutDisplayFunc(display);
    glutTimerFunc(20,timer,0);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutMainLoop();
}


2015年5月21日 星期四

week 13 02160083 廖峻賢



#include <iostream>
#include <GL/glut.h>
#include "CMP3_MCI.h"
CMP3_MCI myMP3;

using namespace std;

int main()
{
    myMP3.Load("RickyMartin.mp3");
    myMP3.Play();
    cout << "Hello world!" << endl;
    int a;
    cin >>a;
    return 0;
}

2015年5月14日 星期四

02160083_廖俊賢


  1. 作業回顧
  2. 作業需求(小遊戲)
  3. 3D MODEL模型. glm.c
  4. Maya轉OBJ檔
  5. 介紹 助教 影片資源


#include "glm.h"

GLMmodel* pmodel = NULL;

void display()
{
    GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
    glFlush();
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("GLUT");
    glutDisplayFunc(display);

    pmodel = glmReadOBJ("porsche.obj");
    glmUnitize(pmodel);
    glmFacetNormals(pmodel);
    glmVertexNormals(pmodel, 90.1);

    glutMainLoop();
}


2015年5月7日 星期四

電腦圖學
1.Timer計時器
2.多個貼圖
3.作業:互動小遊戲
4.總結整題觀念


一開始先做一個會轉動的茶壺


#include <GL/glut.h>
float angle=0;
void display()
{
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle, 0,1,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glFlush();
    ///angle+=0.01;
}
void timer(int t)
{
    glutTimerFunc(10 ,timer, 0);
    angle+=1;
    glutPostRedisplay();
}
int main (int argc, char**argv)
 {
    glutInit(&argc,argv);
    glutCreateWindow("3D");
    glutDisplayFunc(display);
    ///glutIdleFunc(display);
    glutTimerFunc(10, timer,0);
    glutMainLoop();
}

2015年4月16日 星期四


#include<GL/glut.h>
#include<mmsystem.h>
#include<stdio.h>
#include<math.h>
float potX=-1, potY=0;
void mouse(int button, int state, int x ,int y)
{
    if(state==GLUT_DOWN){
        PlaySound("Shot.wav",NULL,SND_ASYNC);
        printf("Shot!\n");

        float mouseX = 2*x/1280.0 -1, mouseY = 2*y/1024.0 -1;
        if( fabs(mouseX - potX) < 0.1 && fabs(mouseY-potY)<0.1) {
            PlaySound("ahhh.wav",NULL,SND_ASYNC);
        printf("You got it!\n");
        }
    }
}
void keyboard(unsigned char key,int x,int y)
{
    exit(0);
}

void display()
{
    potX+=0.01;
    if(potX>1.1)potX=-1.1;
    glClearColor(0.5,0.5,1,0);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(potX,potY,0);
        glutSolidTeapot(0.05);
    glPopMatrix();
    glFlush();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("hello");

    glutFullScreen();/////////
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMainLoop();
}


2015年4月9日 星期四

week07 廖峻賢




#include <GL/glut.h>
#include <stdio.h>
/// /////////////////
#include <mmsystem.h>

void display()
{
    glutSolidTeapot(0.3);
    glFlush();
}
void keyboard(unsigned char key, int x, int y)
{
    if(key=='a'){
     /// ///////////////////////
    PlaySound("tarzan.wav",NULL, SND_ASYNC);
    printf("嗚~~~嗚~~~嗚~~~ \n");
    }
    if(key=='b')printf("bbbbb\n");
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutCreateWindow("hello");

    glutDisplayFunc(display);
    /// /////////////////////////
    glutKeyboardFunc(keyboard);

    glutMainLoop();
}



加入音效檔(wav)
PlaySound("tarzan.wav",NULL, SND_ASYNC);






PlaySound("tarzan.wav",NULL, SND_ASYNC);
    printf("嗚~~~嗚~~~嗚~~~ \n");
    }
    if(key=='1')PlaySound("Do.wav",NULL, SND_ASYNC);
    if(key=='2')PlaySound("Re.wav",NULL, SND_ASYNC);
    if(key=='3')PlaySound("Mi.wav",NULL, SND_ASYNC);
    if(key=='4')PlaySound("Fa.wav",NULL, SND_ASYNC);
    if(key=='5')PlaySound("Sol.wav",NULL, SND_ASYNC);
    if(key=='6')PlaySound("La.wav",NULL, SND_ASYNC);
    if(key=='7')PlaySound("Si.wav",NULL, SND_ASYNC);
}

加入鋼琴音效

加入程式碼使得茶壺可以上下旋轉移動


2015年3月26日 星期四

1.自製3D模型
2.利用mouse旋轉
3.回家作業

TODO;freeglut,CodeBlocks.(小心,libglut32.a)
TODO:上週的glutWiretoru(0.3,0.7,30,30);




這是上週做的透視圓圈旋轉





描點出一個正方形旋轉




劃出2個立方體繞著Y軸做旋轉呈現出立體感



四邊形描點連起來呈現出3D圖形
至於空洞的話只要將第一航描點的再貼到後面就可以了


一個畫面,一個畫線,最後再結合起來凸顯立體感





加入一些程式碼使得立體圖形可以做上下左右旋轉
void motion(int x, int y)
{
    printf("%d %d\n",x,y);
    angle = x;
    angle2 = y;
}



加入
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutInitDisplayMode(GLUT_DEPTH);
讓顯示的window有3d的深度功能
開啟Depth Text深度測試,進的會擋到遠的,遠的不會擋到近的




2015年3月19日 星期四

hw1


1.作業表揚
2.本週重點:移動,旋轉,放大&縮小
3.3D物件


第一步加了3行程式碼
包含了Translate移動



清除背景後再加入幾行程式
glutSoildTorus(r,R,橫切,縱切)



2015年3月12日 星期四

week03



1.點,線,面,顏色
2         .5行程式
3         glut範例
   4 .電腦圖學之父



先到 jsyeh.org/3dcg10 下載

1.windows.zip->桌面\windows\範例.exe.(shapes.exe)
2.glut32.dll->桌面\windows\glut32.dll

windows   glut32   data


把window解壓縮glut32跟data丟入windows檔案中


執行shapes.exe



加入 glColor3f(1,1,0);
使茶壺變色
加入這3行
    glClearColor(0.7,0,0.6,1);///今天重點3: 用來Clear清的顏色是什麼
    glClear(GL_COLOR_BUFFER_BIT);///今天的重點2: Clear而且要說明你清哪一個 buffer
    glColor3f(1,1,0);///今天重點1: Color
                                                                   使得茶壺背景顏色改變  

                                     

加入這幾行程式碼去更改點的顏色

glBegin(GL_POLYGON);
        glColor3f(1,0,0);
        glVertex2f(0,0);

        glColor3f(0,1,0);
        glVertex2f(-1,0);

        glColor3f(0,0,1);
        glVertex2f(0,-1);
    glEnd();


2015年3月5日 星期四

week02




1.#include <GL/glut.h> 呼叫外掛
2.高手寫int main(int argc, char *argv[]))
3.glutInit(&argc, argv); 把GLUT準備好,參數照舊
4.glutCreateWindow("02160083陳雷"); 開一個GLUT的視窗
5.glutMainLoop(); GLUT的主要迴圈,卡住用的
6.void display() {} 我們用來畫東西的顯示函式
7.glutSolidTeapot(0.3); 用glut畫一個實心的茶壺(solid換成wire可以畫空心的)
8.glFlush(); 把它沖馬桶沖出去
9.glutDisplayFunc(display); 把樓上寫的display()函式在這邊掛上來
(10.return 0; 剛好十行)
F9 執行

week02









1.下載 freeglut 的Windows MinGW版本
2.解壓縮到C:\user\user\Desktop\freeglut
3.在codeblocks新增project
4.把GLUT設在C:\user\user\Desktop\freeglut
5.把libl\libfreeglut.a  複製在改名稱 libglut32.a
6.按F9跑程式
7.就會跑出六個3D圖案

week01











打開CodeBlocks接著File→New→Project
選擇openGL專案
並完成小精靈的開檔設定
接著F9就有彩虹旋轉中的三角形