2021年3月29日 星期一

階層轉動

 #include <GL/glut.h>

#include <stdio.h>

float angle=0;

int N=0,vx[3000],vy[3000];

void display()

{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

        glRotatef(angle,0,0,1);

        glScalef(0.5,0.1,0.1);

        glColor3f(0.3,0.3,1.0);

        glutSolidCube(1);

    glPopMatrix();

    glutSwapBuffers();

}

void keyboard(unsigned char key,int x,int y)

{

}

void mouse(int botton,int state,int x,int y)

{

}

void motion(int x,int y)

{

   angle++;

   display();

}

int main(int argc, char **argv)

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("08160465 大宇 Week06 轉動");


    glutDisplayFunc(display);

    glutMouseFunc( mouse );

    glutMotionFunc( motion );

    glutMainLoop();

}




#include <GL/glut.h>
#include <stdio.h>
float angle=0;
int N=0,vx[3000],vy[3000];
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(angle++,0,0,1);
        glScalef(0.5,0.1,0.1);
        glColor3f(0.3,0.3,1.0);
        glutSolidCube(1);
    glPopMatrix();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
}
void mouse(int botton,int state,int x,int y)
{
}
void motion(int x,int y)
{
   angle++;
   display();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160465 大宇 Week05 宣告陣列");

    glutIdleFunc(display);
    glutDisplayFunc(display);
    //glutMouseFunc( mouse );
    //glutMotionFunc( motion );
    glutMainLoop();
}

#include <GL/glut.h>
#include <stdio.h>
float angle=0;
int N=0,vx[3000],vy[3000];
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        ///glRotatef(angle++,0,0,1);
        glTranslatef(-0.25,0,0);
        glScalef(0.5,0.1,0.1);
        glColor3f(0.3,0.3,1.0);
        glutSolidCube(1);
    glPopMatrix();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
}
void mouse(int botton,int state,int x,int y)
{
}
void motion(int x,int y)
{
   angle++;
   display();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160465 大宇 Week05 宣告陣列");

    glutIdleFunc(display);
    glutDisplayFunc(display);
    //glutMouseFunc( mouse );
    //glutMotionFunc( motion );
    glutMainLoop();
}

#include <GL/glut.h>
#include <stdio.h>
float angle=0;
int N=0,vx[3000],vy[3000];
void hand()
{
    glPushMatrix();
        glScaled(0.5,0.1,0.1);
        glutSolidCube(1);
    glPopMatrix();
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(-0.25,0,0);
        glRotatef(angle++,0,0,1);
        glTranslatef(-0.25,0,0);
        glScalef(0.5,0.1,0.1);
        glColor3f(0.3,0.3,1.0);
        glutSolidCube(1);
        hand();
    glPopMatrix();
    hand();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
}
void mouse(int botton,int state,int x,int y)
{
}
void motion(int x,int y)
{
   angle++;
   display();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160465 大宇 Week05 宣告陣列");

    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}
#include <GL/glut.h>
#include <stdio.h>
float angle=0;
int N=0,vx[3000],vy[3000];
void hand()
{
    glPushMatrix();
        glScaled(0.5,0.1,0.1);
        glutSolidCube(1);
    glPopMatrix();
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(-0.25,0,0);
        glRotatef(angle++,0,0,1);
        glTranslatef(-0.25,0,0);
        hand();
        glPushMatrix();
            glTranslatef(-0.25,0,0);
            glRotatef(angle,0,0,1);
            glTranslatef(-0.25,0,0);
            hand();
    glPopMatrix();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
}
void mouse(int botton,int state,int x,int y)
{
}
void motion(int x,int y)
{
  
   angle++;
   display();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160465 大宇 Week05 宣告陣列");

    glutIdleFunc(display);
    glutDisplayFunc(display);
       glutMainLoop();
}


#include <GL/glut.h>
#include <stdio.h>
//float vx[2000],vy[2000];
float angle=0;
int N=0,vx[3000],vy[3000];
void hand()
{
    glPushMatrix();
        glScaled(0.5,0.1,0.1);
        glutSolidCube(1);
    glPopMatrix();
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();///LEFT
        glTranslatef(-0.25,0,0);
        glRotatef(angle++,0,0,1);
        glTranslatef(-0.25,0,0);
        hand();
        glPushMatrix();
            glTranslatef(-0.25,0,0);
            glRotatef(angle,0,0,1);
            glTranslatef(-0.25,0,0);
            hand();
        glPopMatrix();
    glPopMatrix();
    glPushMatrix();///RIGHT
        glTranslatef(+0.25,0,0);
        glRotatef(-angle,0,0,1);
        glTranslatef(+0.25,0,0);
        hand();
        glPushMatrix();
            glTranslatef(+0.25,0,0);
            glRotatef(-angle,0,0,1);
            glTranslatef(+0.25,0,0);
            hand();
        glPopMatrix();
    glPopMatrix();
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
}
void mouse(int botton,int state,int x,int y)
{
}
void motion(int x,int y)
{
   angle++;
   display();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("08160465 大宇 Week05 宣告陣列");

    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}


沒有留言:

張貼留言

Week18期末作業(橘貓的跳舞熊熊)

 期末作業(橘貓的跳舞熊熊) 影片: https://youtu.be/R89tptMaQZw 程式碼: #include <opencv/highgui.h> #include <opencv/cv.h> #include <GL/glut.h...