2019年5月17日 星期五

導編演也的電腦圖學不亂學_week13

每次想要做什麼是的時候,每次就會忘了做

1.複習C++(之類的吧)

















DLC1:找回失去的記憶



2.複習湖之貴人+讀檔


















附錄:今天的程式

#include <GL/glut.h>
#include <stdio.h>
float angle[9];
int JID=1;
FILE*forin =NULL;
FILE*forout =NULL;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();

///左手
        glPushMatrix();
            glTranslated(0.3,0,0);
            glRotatef(angle[1],0,0,1);
            glTranslated(0.15,0,0);
            glColor3d(0.1,0.1,0.1);
            glutSolidTeapot(0.2);
            glPushMatrix();
                glTranslated(0.3,0,0);
                glRotatef(angle[2],0,0,1);
                glTranslated(0.15,0,0);
                glColor3d(0.1,0.1,0.1);
                glutSolidTeapot(0.2);
            glPopMatrix();
        glPopMatrix();
///左手
///左腳
    glPushMatrix();
            glTranslatef(-0.18, -0.1, 0);
            glRotatef(-angle[5]+90, 0,0,1);
            glTranslatef(-0.3, 0, 0);
            glColor3f(1,1,1);
            glutSolidTeapot( 0.2 );

            glPushMatrix();
                glTranslatef(-0.18, 0, 0);
                glRotatef(-angle[6], 0,0,1);
                glTranslatef(-0.3, 0, 0);
                glColor3f(1,1,1);
                glutSolidTeapot( 0.2 );
            glPopMatrix();
        glPopMatrix();
///左腳
///右腳
    glPushMatrix();
            glTranslatef(0.18, -0.1, 0);
            glRotatef(-angle[7]+90, 0,0,1);
            glTranslatef(-0.3, 0, 0);
            glColor3f(1,1,1);
            glutSolidTeapot( 0.2 );

            glPushMatrix();
                glTranslatef(-0.18,0, 0);
                glRotatef(-angle[8], 0,0,1);
                glTranslatef(-0.3, 0, 0);
                glColor3f(1,1,1);
                glutSolidTeapot( 0.2 );
            glPopMatrix();
        glPopMatrix();
///右腳
///右手
    glPushMatrix();
            glTranslated(-0.3,0,0);
            glRotatef(angle[3],0,0,-1);
            glTranslated(-0.15,0,0);
            glColor3d(0.1,0.1,0.1);
            glutSolidTeapot(0.2);
            glPushMatrix();
                glTranslated(-0.3,0,0);
                glRotatef(angle[4],0,0,-1);
                glTranslated(-0.15,0,0);
                glColor3d(0.1,0.1,0.1);
                glutSolidTeapot(0.2);
            glPopMatrix();
        glPopMatrix();
///右手

    glColor3d(1,1,0);
    glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
int oldx,oldy;
void motion(int x,int y)
{
    /*if(jID==1) angle1+=(x-oldx);
    if(jID==2) angle2+=(x-oldx);
    if(jID==3) angle3+=(x-oldx);
    if(jID==4) angle4+=(x-oldx);
    if(jID==5) angle5+=(x-oldx);
    if(jID==6) angle6+=(x-oldx);
    if(jID==7) angle7+=(x-oldx);
    if(jID==8) angle8+=(x-oldx);*/
    angle[JID]+=(x-oldx);
    oldx=x;
    if(forin==NULL){
        forin=fopen("idontknow.txt","w+");
    }
    for(int i=1;i<=8;i++){
        printf(" %.1f ",angle[i]);
        fprintf( forin," %.1f ",angle[i]);
    }
    printf("\n");
    fprintf( forin,"\n");
    display();
}
void mouse(int butten,int state,int x,int y)
{
    oldx=x;
    oldy=y;
}
void keyboard(unsigned char key,int x,int y)
{
    if(key=='1') JID=1;
    if(key=='2') JID=2;
    if(key=='3') JID=3;
    if(key=='4') JID=4;
    if(key=='5') JID=5;
    if(key=='6') JID=6;
    if(key=='7') JID=7;
    if(key=='8') JID=8;
    if(key=='w'){
        if(forin==NULL){
            forin=fopen("idontknow.txt","w+");
        }
        for(int i=1;i<=8;i++){
            printf(" %.1f ",angle[i]);
            fprintf( forin," %.1f ",angle[i]);
        }
        printf("\n");
        fprintf( forin,"\n");
    }
    if(key=='r'){
        if(forout==NULL){
            forout=fopen("idontknow.txt","r");
        }
        for(int i=1;i<=8;i++){
            fscanf( forout," %f ",&angle[i]);
        }
    }
    glutPostRedisplay();
}
int main(int argc,char ** argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(600,600);
    glutCreateWindow("week13");

    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    glutMainLoop();
}

然後


沒有留言:

張貼留言