Ejemplo n.º 1
0
def display():
    twDisplayInit();
    twCamera();
    fog(FogOption)

    # draw ground and sky, using default colors
    twSky();
    twGround();

    # draw a picket lying on the ground in the middle of the field.  With
    # the exception of using CallList instead of something like
    # drawPicket(), this is the same as any drawing code.
    glPushMatrix();
    glTranslatef(0,0,-40);
    glRotatef(30,0,1,0);
    glRotatef(-90,1,0,0);
    glTranslatef(0,0,2);
    glCallList(PICKET);
    glPopMatrix();

    # draw front fence
    glPushMatrix();
    glTranslatef(-40,0,0);
    for i in range(20):
        glCallList(PICKET);
        glTranslatef(5,0,0);
    glPopMatrix();
  
    # draw right side fence
    glPushMatrix();
    glTranslatef(60,0,0);
    glRotatef(90,0,1,0); 
    for i in range(25):
        glCallList(PICKET);
        glTranslatef(5,0,0);
    glPopMatrix();
  
    # draw left side fence
    glPushMatrix();
    glTranslatef(-40,0,0);
    glRotatef(90,0,1,0);
    for i in range(17):
        glCallList(PICKET);
        glTranslatef(5,0,0);
    glPopMatrix();

    # draw barn
    glPushMatrix();
    glTranslatef(-40,0,-125);
    glRotatef(-90,0,1,0);
    glScalef(40,35,50);
    teal      = (0,0.5,0.5)
    dark_blue = (0,0,0.5)
    cyan      = (0,1,1)
    twSolidBarn(teal,dark_blue,cyan);
    glPopMatrix();

    glFlush();
    glutSwapBuffers()
Ejemplo n.º 2
0
def display():
    twDisplayInit(0.3,0.3,0.3)
    twCamera()
    fog(FogOption)

    twColorName(TW_GREEN)
    twGround()

    twColorName(TW_MAGENTA)
    glPushMatrix()
    glTranslatef(50,0,50)
    glScalef(1,40,1)                # for tall cubes
    for i in range(50):
        glutSolidCube(0.5)
        glTranslatef(-1,0,-1)
    glPopMatrix()

    glFlush()
    glutSwapBuffers()