⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 ertyuiopuygfvc bnm,kjhbgyuisdcs
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdio.h>

static int geleng=0,angguk=0;
static int tanganKiriAtas1 = -30,tanganKiriAtas2=-15, tanganKiriBawah=-30;
static int tanganKananAtas1 = -30,tanganKananAtas2=0, tanganKananBawah=-45;
static int kakiKiriAtas=-30,kakiKiriBawah=-20;
static int kakiKananAtas=0, kakiKananBawah=0;

static int putarSemua1=0,putarSemua2=0,putarSemua3=0;
static float maju =0;
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);

}


void display(void)

{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glPushMatrix();
    {
        //putar 3 dimensi darirobot
        glRotatef(putarSemua1,0,1,0);
        glRotatef(putarSemua2,1,0,0);
        glRotatef(putarSemua3,0,0,1);

        //kepala

        glPushMatrix();
        {
            glRotatef((GLfloat) geleng,0,1,0);
            glTranslatef (0, 1.55, 0);
            glColor3f(1,0.176,0.165);
            glScalef(1,1,1);
            glutSolidCube(1.0);

            // mata1
            glTranslatef (-0.1, 0, 0.30);
            glColor3f(0,0,1);
            glTranslatef (-0.1, 0.0, 0.30);
            glPushMatrix();
            {
                glScalef (0.1, 0.2, 0.2);
                glutSolidCube (1.0);     //
             }
             glPopMatrix();

            //mata 2
            glTranslatef (0.2, 0.0, 0.30);
            glColor3f(0,0,1);
            glTranslatef (0.2, 0.0, -0.30);
            glPushMatrix();
            {
                glScalef (0.1, 0.2, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();
        }
        glPopMatrix();

        // badan

        glPushMatrix();
        {
            glTranslatef (0, 0.0, 0);
            glColor3f(1,0.5,0);
            glScalef(2,2,1);
            glutSolidCube(1.0);
        }
        glPopMatrix();

         //tangan kiri
        glPushMatrix();
        {
            // tangan Kiri Atas
            glTranslatef (-0.6, 1, 0.0);
            glRotatef (-15, 0.0, 0.0, 1.0);
            glRotatef ((GLfloat) tanganKiriAtas1, 1.0, 0.0, 0.0);
            glColor3f(0,1,0);
            glTranslatef (-0.6, -0.5, 0.0);
            glPushMatrix();
            {
                glScalef (0.4, 1.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

            // tangan kiri bawah
            glTranslatef (0, -0.5, 0.0);
            glColor3f(1,0.176,0.165);
            glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0, -0.5, 0.0);
            glPushMatrix();
            {
                glScalef (0.4, 1.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

            // jari1
            glTranslatef (-0.05, -0.35, 0.0);
            glTranslatef (-0.05, -0.35, 0.0);
            glPushMatrix();
            glColor3f(0,0,1);
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();

            // jari2
            glTranslatef (0, 0.0, 0.15);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0, 0.0, 0.15);
            glColor3f(0,0,1);
            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //

            }
            glPopMatrix();

            // jari3
            glTranslatef (0, 0, -0.30);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0.0, 0.0, -0.30);
            glColor3f(0,0,1);
            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();

            // jari4

            glTranslatef (0.1, 0.0, 0.30);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0.1, 0.0, -0.30);
            glColor3f(0,0,1);
            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();
        }
        glPopMatrix();


        // tangan kanan
        glPushMatrix();
        {
            //tangan kanan atas
            glTranslatef (0.6, 1.0, 0.0);
            glRotatef (15, 0.0, 0.0, 1.0);
            glRotatef ((GLfloat) tanganKananAtas1, 1.0, 0.0, 0.0);
            glColor3f(0,1,0);
            glTranslatef (0.6, -0.5, 0.0);
            glPushMatrix();
            {
                glScalef (0.4, 1.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

             // tangan bawah
            glTranslatef (0, -0.5, 0.0);
            glColor3f(1,0.176,0.165);
            glRotatef ((GLfloat) tanganKananBawah, 1.0, 0.0, 0.0);
            glTranslatef (0, -0.5, 0.0);
            glPushMatrix();
            {
                glScalef (0.4, 1.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

               // jari1
            glTranslatef (0.05, -0.35, 0.0);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0.05, -0.35, 0.0);
            glColor3f(0,0,1);
            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();

            // jari2
            glTranslatef (0, 0.0, 0.15);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0, 0.0, 0.15);
            glColor3f(0,0,1);

            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //

            }
            glPopMatrix();

            // jari3
            glTranslatef (0, 0, -0.30);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0.0, 0.0, -0.30);
            glColor3f(0,0,1);
            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();

            // jari4

            glTranslatef (-0.1, 0.0, 0.30);
            //glRotatef ((GLfloat) tanganKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (-0.1, 0.0, -0.30);

            glPushMatrix();
            {
                glScalef (0.1, 0.4, 0.2);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();



        }
        glPopMatrix();
        glTranslatef(0,-1,0);
        // kaki kiri
        glPushMatrix();
        {
            //kaki kiri atas
            glTranslatef (-0.3, 0, 0.0);
            glColor3f(0.204,0.239,0.235);
            glRotatef ((GLfloat) kakiKiriAtas, 1.0, 0.0, 0.0);
            glTranslatef (-0.3, -1, 0.0);
            glPushMatrix();
            glColor3f(0,1,1);
            {
                glScalef (0.4, 2.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

             // kaki kiri bawah
            glTranslatef (0, -1, 0.0);
            glRotatef ((GLfloat) kakiKiriBawah, 1.0, 0.0, 0.0);
            glTranslatef (0, -1, 0.0);
            glColor3f(0.204,0.239,0.235);
            glPushMatrix();
            {
                glScalef (0.4, 2.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

            // sepatu
            glTranslatef (0, -0.35, 0.0);
            glColor3f(1,0,0);
            glTranslatef (0, -0.35, 0.0);
            glPushMatrix();
            {
                glScalef (0.5, 0.4, 1.5);
                glutSolidCube (1.0);     //
            }
            glPopMatrix();


        }
        glPopMatrix();




        // kaki kanan
        glPushMatrix();
        {
            //kaki kanan atas
            glTranslatef (0.3,0.0, 0.0);
            glRotatef ((GLfloat) kakiKananAtas, 1.0, 0.0, 0.0);
            glTranslatef (0.3, -1, 0.0);
            glColor3f(0,1,1);
            glPushMatrix();
            {
                glScalef (0.4, 2.0, 1.0);
                glutSolidCube (1.0);
            }
            glPopMatrix();

             // kaki kanan bawah
            glTranslatef (0, -1, 0.0);
            glRotatef ((GLfloat) kakiKananBawah, 1.0, 0.0, 0.0);
            glColor3f(0.204,0.239,0.235);
            glTranslatef (0, -1, 0.0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -