2022年7月2日 星期六

09360503 陳品睿 week16

 

1.內插

1-1.用excel計算看內插運作

    1-2.加到上上禮拜程式裡



2.鏡頭

    2-1.









09360503_陳品睿_week15

 1.音樂

    1-1.先測試程式

    1-2.Setting ->compiler->linker seeting->add->輸入winmm
    1-3.放音樂進資料夾,放音樂同時執行程式,直到輸入數字

2.為了最後作業

    2-1.把存檔改成按一次存一次





2022年6月26日 星期日

7ru week17

 


week16-許皓翔

 


OldAngle[i]=NewAngle[i];
        fscanf(fin,"%f",&NewAngle[i]);


void myInterpolate(float alpha)
{
    for(int i=0;i<20;i++)
    {
    angle[i]=alpha*NewAngle[i]+(1-alpha)*OldAngle[i];
    printf("%.2f",angle[i]);
    }
    printf("\n");
    glutPostRedisplay();
}





void timer(int t)
{
    float alpha =(t%50)/50.0;
    if(t%50==0)myRead();
    myInterpolate(alpha);
    glutTimerFunc(33,timer,t+1);
}


eye是看出去的
center是看的中心
up是攝影機的旋轉



aspect ratio=寬度/高度




#include<GL/glut.h>

void motion(int x,int y)
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt((x-150)/15.0,(y-150)/15.0,3,
              0,0,0,
              0,1,0);
    glutPostRedisplay();
}
 void reshape(int w, int h)
{///aspect ratio
    const float ar = (float) w / (float) h;

    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);///投影,把3D投影到2D
    glLoadIdentity();
    gluPerspective(60,ar,0.1,100);
    //glFrustum(, ar, -1.0, 1.0, 2.0, 100.0);
    ///3D經過轉換到你最後的攝影機

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
    gluLookAt(0,0,3,0,0,0,0,1,0);
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //glColor3f(1,1,0);
    glutSolidTeapot(1);
    glutSwapBuffers();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week16 camera lookat");



glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMotionFunc(motion);



glutMainLoop();
}









week15-許皓翔

 

新的碼


案Setting ->compiler->linker seeting->add->輸入winmm-

SND_ASYNC練習

mp3撥放
改成每案一下"S"存檔一次
白色鋼彈













week14-讀寫

 

練習開檔關檔





加上以下程式碼
FILE *fout=NULL;
void myWrite()
{
    if(fout==NULL)
        fout=fopen("file.txt","w+");
    for(int i=0;i<20;i++)
    {
        fprintf(fout,"%.2f",angle[i]);
    }
}

 myWrite();




按著R會自己移動(有吃檔案)


用notpad++改workin dir=""




時間軸
會發更新率不一樣



可以有聲音

2022年6月24日 星期五

week13-手臂

 先做出一個正方形


做出小手臂



放到中心




轉角度


移動放置位置







多加一個小手臂

複製一個完整手臂在另一邊

可依讓手臂被控制