def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    if cam.projection_mode == "ortho":
        width_ratio = DISPLAY_WIDTH / DISPLAY_HEIGHT
        zoom = -cam.cur_position.z
        if zoom > 0:
            glOrtho(-zoom * width_ratio, zoom * width_ratio, -zoom, zoom, .5, 100)
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()
            glRotated(cam.cur_rotation, 0, 1, 0)
            glTranslated(cam.cur_position.x, cam.cur_position.y, cam.cur_position.z)

    else:
        gluPerspective(60, (DISPLAY_WIDTH / DISPLAY_HEIGHT), 0.1, 100.0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glRotated(cam.cur_rotation, 0, 1, 0)
        glTranslated(cam.cur_position.x, cam.cur_position.y, cam.cur_position.z)

    draw_neighborhood()
    animate_car()

    glFlush()
예제 #2
0
 def draw(self, line_width=1, color=(1.0, 0.0, 0.0)):
     glEnable(GL_DEPTH_TEST)
     glEnable(GL_LINE_SMOOTH)
     glShadeModel(GL_FLAT)
     glPushMatrix()
     glLineWidth(line_width)
     glColor3f(*color)
     glBegin(GL_LINES)
     glVertex3f(-1.0, 0.0, 0.0)
     glVertex3f(1.0, 0.0, 0.0)
     glEnd()
     glPushMatrix()
     glTranslated(1.0, 0.0, 0.0)
     glRotated(90, 0.0, 1.0, 0.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glBegin(GL_LINES)
     glVertex3f(0.0, -1.0, 0.0)
     glVertex3f(0.0, 1.0, 0.0)
     glEnd()
     glPushMatrix()
     glTranslated(0.0, 1.0, 0.0)
     glRotated(-90, 1.0, 0.0, 0.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glBegin(GL_LINES)
     glVertex3f(0.0, 0.0, -1.0)
     glVertex3f(0.0, 0.0, 1.0)
     glEnd()
     glPushMatrix()
     glTranslated(0.0, 0.0, 1.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glPopMatrix()
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    if projection_mode == "ortho":
        width_ratio = DISPLAY_WIDTH / DISPLAY_HEIGHT
        zoom = -cam_z
        if zoom > 0:
            glOrtho(-zoom * width_ratio, zoom * width_ratio, -zoom, zoom, .5,
                    100)
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()
            glRotated(rot_deg, 0, 1, 0)
            glTranslated(cam_x, cam_y, cam_z)

    else:
        gluPerspective(55, (DISPLAY_WIDTH / DISPLAY_HEIGHT), 0.1, 100.0)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glRotated(rot_deg, 0, 1, 0)
        glTranslated(cam_x, cam_y, cam_z)

    drawTestShape()

    drawAxisOfRotation()

    if transform:
        shape_offset = [30, 0, 40]
        # problem 1
        transform_shape(shape_offset, 40)

    glFlush()
예제 #4
0
def draw_house_row(mirror=False):
    for i in range(3):
        glPushMatrix()
        z_placement = 30 if mirror else 0
        rotation = 180 if mirror else 0
        glTranslated(-i * 15, 0, z_placement)
        glRotated(rotation, 0, 1, 0)
        drawHouse()
        glPopMatrix()
예제 #5
0
파일: lab6.1.py 프로젝트: brasm94/oldschool
def drawCarTurned():
    global seconds
    print(seconds)
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix()
    glTranslated(0, 0, -10 + seconds)
    glRotated(90, 0, 1, 0)
    drawCar()
    glPopMatrix()
예제 #6
0
 def rotate(self, axis, angle):
     # rotate the object
     self.makeCurrent()
     glMatrixMode(GL_MODELVIEW)
     glLoadIdentity()
     t = [self._modelview_matrix[3][0], self._modelview_matrix[3][1], self._modelview_matrix[3][2]]
     glTranslatef(t[0], t[1], t[2])
     glRotated(angle, axis[0], axis[1], axis[2])
     glTranslatef(-t[0], -t[1], -t[2])
     glMultMatrixd(self._modelview_matrix)
     # update _modelview_matrix
     self._modelview_matrix = glGetDoublev(GL_MODELVIEW_MATRIX)
예제 #7
0
 def rotate(self, axis, angle):
     # rotate the object
     self.makeCurrent()
     glMatrixMode(GL_MODELVIEW)
     glLoadIdentity()
     t = [self._modelview_matrix[3][0], self._modelview_matrix[3][1], self._modelview_matrix[3][2]]
     glTranslatef(t[0], t[1], t[2])
     glRotated(angle, axis[0], axis[1], axis[2])
     glTranslatef(-t[0], -t[1], -t[2])
     glMultMatrixd(self._modelview_matrix)
     # update _modelview_matrix
     self._modelview_matrix = glGetDoublev(GL_MODELVIEW_MATRIX)
예제 #8
0
def draw_tires():
    anim_time = get_time()
    x_car_offset = 2.0
    z_car_offset = 1.5
    for i in range(2):
        for j in range(2):
            glPushMatrix()
            x_placement = x_car_offset if i == 1 else -x_car_offset
            z_placement = z_car_offset if j == 1 else -z_car_offset
            glTranslated(x_placement, 0, z_placement)
            glRotated(-50 * anim_time, 0, 0, 1)
            drawTire()
            glPopMatrix()
예제 #9
0
파일: lab6.1.py 프로젝트: brasm94/oldschool
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    global chHor
    global chVert
    global home
    global ortho
    global chDepth
    global persz
    global chRot
    global totHor
    global totDepth
    global totRot
    global seconds
    #Your Code Here
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslated(chHor, chVert, chDepth)
    glRotated(chRot, 0, 1, 0)

    if home == True:
        init()
        chRot = -45
        chDepth = 0
        chVert = 0
        chHor = -20
        seconds = 0
    if ortho == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-10.0, 10.0, -10.0, 10.0, -100.0, 100.0)
        seconds = 0
    if pers == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(60, 1, 0, 100)
    home = False
    ortho = False
    pers = False
    drawCarTurned()
    drawWheels()
    drawNeighboorhood()
    print(seconds)
    # drawWheels()
    glFlush()
    bob = 0
예제 #10
0
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    #Your Code Here
    glLoadIdentity()
    if (view_mode == "perspective"):
        gluPerspective(90, 1, .1, 50)
    else:
        glOrtho(-10, 10, -10, 10, 0.1, 50.0)
    glRotated(view_angle, 0.0, 1.0,
              0.0)  # this rotates the y axis by the view_angle
    glTranslatef(translate_x, translate_y, translate_z)

    draw_neighborhood()
    draw_full_car()

    glFlush()
예제 #11
0
파일: Lab5-OpenGL.py 프로젝트: jtreim/cs355
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

    if camera['perspective']:
        gluPerspective(50, DISPLAY_WIDTH / DISPLAY_HEIGHT, camera['near'],
                       camera['far'])
    else:
        glOrtho(-10, 10, -10, 10, camera['near'], camera['far'])

    glRotated(camera['rotate'], 0, 1, 0)
    glTranslated(camera['x'], camera['y'], camera['z'])

    drawHouse()

    glFlush()
예제 #12
0
def display():
    glClear (GL_COLOR_BUFFER_BIT)
    glColor3f (1.0, 1.0, 1.0)
    # viewing transformation
    global chHor
    global chVert
    global home
    global ortho
    global chDepth
    global pers
    global chRot
    global totHor
    global totDepth
    global totRot
    #Your Code Here
    glMatrixMode(GL_MODELVIEW)


    glRotated(-totRot,0,10,0)

    glTranslated(-totHor,0,-totDepth)
    glRotated(chRot, 0, 1, 0)
    glTranslated(+totHor,0,+totDepth)
    glTranslated(chHor, chVert, chDepth)
    glRotated(totRot, 0, 10, 0)
    rad = math.radians(chRot)

    if(chRot  > 0 or chRot < 0):
        totHor = totHor * math.cos(rad) + totDepth * math.sin(rad)
        totHorTemp = totHor
        totDepth = -totHorTemp * math.sin(rad) + totDepth * math.cos(rad)


    totHor += chHor
    totDepth += chDepth
    totRot += chRot

    if home == True:
        init()
        totRot = 0
        totHor = 0
    if ortho == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-10.0,10.0,-10.0,10.0,-100.0, 100.0)
    if pers == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(60, 1, 0, 100)
    chHor = 0
    chVert = 0
    home = False
    chDepth = 0
    ortho = False
    pers = False
    chRot = 0

    drawHouse()
    glFlush()
예제 #13
0
 def paintGL(self):
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
     glLoadIdentity()
     glTranslated(0.0, 0.0, -10.0)
     glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
     glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
     glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
     glCallList(self.object)
예제 #14
0
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

    if camera.perspective:
        gluPerspective(50, DISPLAY_WIDTH / DISPLAY_HEIGHT, camera.near,
                       camera.far)
    else:
        glOrtho(-10, 10, -10, 10, camera.near, camera.far)

    glRotated(camera.rotate, 0, 1, 0)
    glTranslated(camera.x, camera.y, camera.z)

    for house in houses:
        glPushMatrix()
        glTranslated(house.x, house.y, house.z)
        glRotated(house.rotate_y, 0, 1, 0)
        drawHouse()
        glPopMatrix()

    glPushMatrix()
    glTranslated(car.x, car.y, car.z)
    glRotated(car.rotate_y, 0, 1, 0)
    drawCar()
    for tire in tires:
        glPushMatrix()
        glTranslated(tire.x, tire.y, tire.z)
        glRotated(tire.rotate_y, 0, 1, 0)
        glRotated(tire.rotate_z, 0, 0, 1)
        drawTire()
        glPopMatrix()
    glPopMatrix()

    glFlush()
예제 #15
0
def animate_car():
    """Use push so that you can apply some transformations at the same time?
       1. Push the matrix from stack
       2. Translate to position
       3. Rotate it
       4. Draw it
       5. Pop the matrix
       """
    # move car along
    glPushMatrix()
    glTranslated(car.position.x, car.position.y, car.position.z)
    drawCar()

    # translate and rotate tires
    for tire in car.tires:
        glPushMatrix()
        glTranslated(tire.x, tire.y, tire.z)
        car.tire_rotation -= .2
        glRotated(car.tire_rotation, 0, 0, 1)
        drawTire()
        glPopMatrix()

    glPopMatrix()
예제 #16
0
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation
    global chHor
    global chVert
    global home
    global ortho
    global chDepth
    global pers
    global chRot
    global totHor
    global totVert
    global totRot
    #Your Code Here
    glMatrixMode(GL_MODELVIEW)
    glRotated(-totRot, 0, 10, 0)
    glRotated(chRot, 0, 10, 0)

    glTranslated(chHor, chVert, chDepth)
    glRotated(totRot, 0, 10, 0)
    totHor += chHor
    totVert += chVert
    totRot += chRot

    if home == True:
        init()
        totRot = 0
        totVert = 0
        totHor = 0
    if ortho == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-20.0, 20.0, -20.0, 20.0, -100.0, 100.0)
    if pers == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(60, 1, 0, 100)
    chHor = 0
    chVert = 0
    home = False
    chDepth = 0
    ortho = False
    pers = False
    chRot = 0

    drawHouse()
    glFlush()
예제 #17
0
    def paintGL(self):
        #        inicio=datetime.datetime.now()
        glLoadIdentity()
        self.qglClearColor(QColor())
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
                | GL_STENCIL_BUFFER_BIT)
        if self.mem.maxplayers == 8:
            glTranslated(-31.5, -16.5, self.z)
        elif self.mem.maxplayers == 4:
            glTranslated(-31.5, -31.5, self.z)
        elif self.mem.maxplayers == 6:
            glTranslated(-31.5, -23.85, self.z)
        elif self.mem.maxplayers == 3:
            glTranslated(-31.5, -36, self.z)

        if self.rotatecenter == 1:
            #Para rotar desde elcentro, hay que llevar el centro al origen
            if self.mem.maxplayers == 4:
                glTranslated(31.5, 31.5, 0)
                glRotated(self.rotCenter, 0, 0, 1)
                glTranslated(-31.5, -31.5, 0)
            elif self.mem.maxplayers == 3:
                glTranslated(31.5, 24, 0)
                glRotated(self.rotCenter, 0, 0, 1)
                glTranslated(-31.5, -24, 0)
            elif self.mem.maxplayers == 6:
                glTranslated(31.5, 24, 0)
                glRotated(self.rotCenter, 0, 0, 1)
                glTranslated(-31.5, -24, 0)
            elif self.mem.maxplayers == 8:
                glTranslated(31.5, 17, 0)
                glRotated(self.rotCenter, 0, 0, 1)
                glTranslated(-31.5, -17, 0)
        glRotated(self.rotX, 1, 0, 0)
        glRotated(self.rotY, 0, 1, 0)
        glRotated(self.rotZ, 0, 0, 1)

        self.mem.tablero.draw(self)

        for c in self.mem.casillas.arr:
            if c.id != 0:
                c.draw(self)

        self.mem.dado.draw(self)
def transform_shape(shape_offset, rotation):
    glPushMatrix()
    glTranslated(shape_offset[0], shape_offset[1], shape_offset[2])
    glRotated(rotation, 0, 1, 0)
    drawTestShape()
    glPopMatrix()
예제 #19
0
def keyboard(key, x, y):
    import math
    global Xdisp
    global Ydisp
    global Zdisp
    global Rotate
    global PERSPECTIVE
    if key == chr(27):
        import sys
        sys.exit(0)

    if key == b'w':
        Xdisp += math.sin(math.radians(Rotate))
        Zdisp += math.cos(math.radians(Rotate))
        glTranslated(math.sin(math.radians(Rotate)), 0,
                     math.cos(math.radians(Rotate)))

    if key == b'a':
        Xdisp += math.cos(math.radians(Rotate))
        Zdisp -= math.sin(math.radians(Rotate))
        glTranslated(math.cos(math.radians(Rotate)), 0,
                     -math.sin(math.radians(Rotate)))

    if key == b'd':
        Xdisp -= math.cos(math.radians(Rotate))
        Zdisp += math.sin(math.radians(Rotate))
        glTranslated(-math.cos(math.radians(Rotate)), 0,
                     math.sin(math.radians(Rotate)))

    if key == b's':
        Xdisp -= math.sin(math.radians(Rotate))
        Zdisp -= math.cos(math.radians(Rotate))
        glTranslated(-math.sin(math.radians(Rotate)), 0,
                     -math.cos(math.radians(Rotate)))

    if key == b'q':
        Rotate += 1
        if Rotate > 360:
            Rotate -= 360
        glTranslated(-Xdisp, 0, -Zdisp)
        glRotated(-1, 0, 1, 0)
        glTranslated(Xdisp, 0, Zdisp)

    if key == b'e':
        Rotate -= 1
        if Rotate < 0:
            Rotate += 360

        glTranslated(-Xdisp, 0, -Zdisp)
        glRotated(1, 0, 1, 0)
        glTranslated(Xdisp, 0, Zdisp)

    if key == b'r':
        glTranslated(0, -1, 0)

    if key == b'f':
        glTranslated(0, 1, 0)

    if key == b'h':
        start()

    if key == b'o':
        PERSPECTIVE = 'o'

    if key == b'p':
        PERSPECTIVE = 'p'
    #Your Code Here

    glutPostRedisplay()
예제 #20
0
def display():
    global x_coord
    global y_coord
    global z_coord
    global angle
    global ortho
    global x_car
    global y_car
    global z_car
    global angle_car

    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    #Your Code Here
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glRotated(angle % 360, 0, 1, 0)
    glTranslated(x_coord, y_coord, z_coord)

    # drawHouse()
    #
    # glTranslated(15, 0, 0)
    #
    # drawHouse()
    #
    # glTranslated(15, 0, 0)
    #
    # drawHouse()
    #
    # glRotated(180, 0, 1, 0)
    # glTranslated(0,0,-30)
    #
    # drawHouse()
    #
    # glTranslated(15,0,0)
    #
    # drawHouse()
    #
    # glTranslated(15,0,0)
    #
    # drawHouse()

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()

    if ortho:
        glOrtho(-20, 20, -20, 20, 0, 10000)
    else:
        gluPerspective(60, 1, 2, 200)

    glMatrixMode(GL_MODELVIEW)
    drawHouse()

    glTranslated(15, 0, 0)

    drawHouse()

    glTranslated(15, 0, 0)

    drawHouse()

    glRotated(180, 0, 1, 0)
    glTranslated(0, 0, -30)

    drawHouse()

    glTranslated(15, 0, 0)

    drawHouse()

    glTranslated(15, 0, 0)

    drawHouse()

    glTranslated(x_car, y_car, z_car)
    drawCar()
    glPushMatrix()

    #glRotated(angle_car,0,0,1)
    glTranslate(1, 0, 1)
    glRotated(angle_car, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()

    #glRotated(angle_car,0,0,1)
    glTranslate(1, 0, -1)
    glRotated(angle_car, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()

    #glRotated(angle_car,0,0,1)
    glTranslate(-1, 0, -1)
    glRotated(angle_car, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()

    #glRotated(angle_car,0,0,1)
    glTranslate(-1, 0, 1)
    glRotated(angle_car, 0, 0, 1)
    drawTire()
    glPopMatrix()

    #drawCar()

    glFlush()
예제 #21
0
def keyboard(key, x, y):

    global rot
    global xdisp
    global ydisp
    global zdisp
    global project
    glMatrixMode(GL_MODELVIEW)

    if key == chr(27):
        import sys
        sys.exit(0)

    if key == b'w':
        z = 1.0 * math.cos(math.radians(rot))
        x = 1.0 * math.sin(math.radians(rot))
        zdisp += z
        xdisp += x
        glTranslated(x, 0.0, z)

    if key == b's':
        z = -1.0 * math.cos(math.radians(rot))
        x = -1.0 * math.sin(math.radians(rot))
        zdisp += z
        xdisp += x
        glTranslated(x, 0.0, z)

    if key == b'a':
        z = -1.0 * math.sin(math.radians(rot))
        x = 1.0 * math.cos(math.radians(rot))
        zdisp += z
        xdisp += x
        glTranslated(x, 0.0, z)

    if key == b'd':
        z = 1.0 * math.sin(math.radians(rot))
        x = -1.0 * math.cos(math.radians(rot))
        zdisp += z
        xdisp += x
        glTranslated(x, 0.0, z)

    if key == b'r':
        ydisp += 1
        glTranslated(0.0, -1.0, 0.0)

    if key == b'f':
        ydisp -= 1
        glTranslated(0.0, 1.0, 0.0)

    if key == b'q':
        rot += 1
        if rot > 360:
            rot = 0
        glTranslated(-xdisp, -ydisp, -zdisp)
        glRotated(-1.0, 0.0, 1.0, 0.0)
        glTranslated(xdisp, ydisp, zdisp)

    if key == b'e':
        rot -= 1
        if rot < 0:
            rot = 360
        glTranslated(-xdisp, -ydisp, -zdisp)
        glRotated(1.0, 0.0, 1.0, 0.0)
        glTranslated(xdisp, ydisp, zdisp)

    if key == b'h':
        start()

    if key == b'o':
        project = 'o'

    if key == b'p':
        project = 'p'

    glutPostRedisplay()
예제 #22
0
파일: lab6.py 프로젝트: brasm94/oldschool
def display():
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation

    global chHor
    global chVert
    global home
    global ortho
    global chDepth
    global pers
    global chRot
    global totHor
    global totDepth
    global totRot
    global seconds

    if home == True:
        init()
        totRot = 0
        totDepth = 0
        totVert = 0
        totHor = 0
        seconds = 0
        chDepth = DEPTH_INIT
        chVert = VER_INIT
        chHor = HOR_INIT
        chRot = ROT_INIT
    if ortho == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glOrtho(-10.0, 10.0, -10.0, 10.0, -100.0, 100.0)
        seconds = 0
    if pers == True:
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(60, 1, 0, 100)
    #Your Code Here
    glMatrixMode(GL_MODELVIEW)

    glRotated(-totRot, 0, 10, 0)

    glTranslated(-totHor, 0, -totDepth)
    glRotated(chRot, 0, 1, 0)
    glTranslated(+totHor, 0, +totDepth)
    glTranslated(chHor, chVert, chDepth)

    glRotated(totRot, 0, 10, 0)
    rad = math.radians(chRot)

    if (chRot > 0 or chRot < 0):
        totHor = totHor * math.cos(rad) + totDepth * math.sin(rad)
        totHorTemp = totHor
        totDepth = -totHorTemp * math.sin(rad) + totDepth * math.cos(rad)

    totHor += chHor
    totDepth += chDepth
    totRot += chRot

    chHor = 0
    chVert = 0
    chDepth = 0
    chRot = 0

    home = False
    ortho = False
    pers = False
    drawCarTurned()
    drawWheels()
    drawNeighboorhood()
    # drawWheel()
    # print(seconds)
    # drawWheels()
    glFlush()
    bob = 0
예제 #23
0
파일: lab6.1.py 프로젝트: brasm94/oldschool
def drawNeighboorhood():
    horOfset = 15
    glMatrixMode(GL_MODELVIEW)
    #left part of neighboorhood
    glPushMatrix()
    glTranslated(-horOfset, 0, 20)
    glRotated(90, 0, 1, 0)
    drawHouse()
    glPopMatrix()

    glPushMatrix()
    glTranslated(-horOfset, 0, 0)
    glRotated(90, 0, 1, 0)
    drawHouse()
    glPopMatrix()

    glPushMatrix()
    glTranslated(-horOfset, 0, -20)
    glRotated(90, 0, 1, 0)
    drawHouse()
    glPopMatrix()

    #right part of neighboorhood

    glPushMatrix()
    glTranslated(horOfset, 0, 20)
    glRotated(-90, 0, 1, 0)
    drawHouse()
    glPopMatrix()

    glPushMatrix()
    glTranslated(horOfset, 0, 0)
    glRotated(-90, 0, 1, 0)
    drawHouse()
    glPopMatrix()

    glPushMatrix()
    glTranslated(horOfset, 0, -20)
    glRotated(-90, 0, 1, 0)
    drawHouse()
    glPopMatrix()
예제 #24
0
파일: lab6.1.py 프로젝트: brasm94/oldschool
def drawWheels():
    global seconds
    wheelXOff = 2
    wheelZOff = 2
    wheelSpreed = 10
    glMatrixMode(GL_MODELVIEW)
    glPushMatrix()
    glTranslated(-wheelXOff, 0, wheelZOff + seconds - 10)
    glRotated(seconds * wheelSpreed, 1, 0, 0)
    glRotated(90, 0, 1, 0)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslated(wheelXOff, 0, wheelZOff + seconds - 10)
    glRotated(seconds * wheelSpreed, 1, 0, 0)
    glRotated(90, 0, 1, 0)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslated(-wheelXOff, 0, -wheelZOff + seconds - 10)
    glRotated(seconds * wheelSpreed, 1, 0, 0)
    glRotated(90, 0, 1, 0)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslated(wheelXOff, 0, -wheelZOff + seconds - 10)
    glRotated(seconds * wheelSpreed, 1, 0, 0)
    glRotated(90, 0, 1, 0)
    drawTire()
    glPopMatrix()
예제 #25
0
def transform_house(house_offset, rotation):
    glPushMatrix()
    glTranslated(house_offset[0], house_offset[1], house_offset[2])
    glRotated(rotation, 0, 1, 0)
    drawHouse()
    glPopMatrix()
예제 #26
0
 def paintGL(self):
     glLoadIdentity()
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
             | GL_STENCIL_BUFFER_BIT)
     glTranslated(0.0, 0.0, self.z)
     glRotated(self.xRot / 16.0, 1.0, 0.0, 0.0)
     glRotated(self.yRot / 16.0, 0.0, 1.0, 0.0)
     glRotated(self.zRot / 16.0, 0.0, 0.0, 1.0)
     if self.objeto == 0:
         glScaled(0.1, 0.1, 0.1)
         self.tablero3.draw(self)
     elif self.objeto == 1:
         glScaled(0.1, 0.1, 0.1)
         self.tablero4.draw(self)
     elif self.objeto == 2:
         glScaled(0.1, 0.1, 0.1)
         self.tablero6.draw(self)
     elif self.objeto == 3:
         glScaled(0.1, 0.1, 0.1)
         self.tablero8.draw(self)
     elif self.objeto == 4:
         self.z = -10
         self.pawnred.draw(self)
     elif self.objeto == 5:
         self.z = -15
         self.dado.draw_alone(self)
     elif self.objeto == 6:
         self.z = -12
         self.cas.draw(self)
     elif self.objeto == 7:
         self.z = -36
         self.squareInitial3.draw(self)
     elif self.objeto == 8:
         self.z = -36
         self.casinicio.draw(self)
     elif self.objeto == 9:
         self.z = -40
         self.squareInitial6.draw(self)
     elif self.objeto == 10:
         self.z = -40
         self.squareInitial8.draw(self)
     elif self.objeto == 11:
         self.z = -40
         self.squareFinal3.draw(self)
     elif self.objeto == 12:
         self.z = -40
         self.squareFinal4.draw(self)
     elif self.objeto == 13:
         self.z = -40
         self.squareFinal6.draw(self)
     elif self.objeto == 14:
         self.z = -40
         self.squareFinal8.draw(self)
     elif self.objeto == 15:
         self.z = -40
         glScaled(2, 2, 2)
         self.squareleftobliquei4.draw(self)
     elif self.objeto == 16:
         self.z = -40
         glScaled(2, 2, 2)
         self.squareleftobliquei6.draw(self)
     elif self.objeto == 17:
         self.z = -40
         glScaled(2, 2, 2)
         self.squareleftobliquei8.draw(self)
     elif self.objeto == 18:
         self.z = -40
         glScaled(2, 2, 2)
         self.squarerightobliquei4.draw(self)
     elif self.objeto == 19:
         self.z = -40
         glScaled(2, 2, 2)
         self.squarerightobliquei6.draw(self)
     elif self.objeto == 20:
         self.z = -40
         glScaled(2, 2, 2)
         self.squarerightobliquei8.draw(self)
예제 #27
0
def display():
    import math
    global PERSPECTIVE
    global Ztire
    global tireRotate
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1.0, 1.0, 1.0)
    # viewing transformation
    #Your Code Here

    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    if PERSPECTIVE == 'p':
        gluPerspective(90, 1, 1, 250)
    else:
        glOrtho(-10, 10, -10, 10, 1, 100)
    #first house
    glMatrixMode(GL_MODELVIEW)
    drawHouse()
    # car
    glPushMatrix()
    glTranslatef(Ztire, 0, 15)
    drawCar()
    # tires
    glTranslatef(-2, 0, -2)
    glRotatef(tireRotate, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslatef(Ztire - 2, 0, 15 + 2)
    glRotatef(tireRotate, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslatef(Ztire + 2, 0, 15 + 2)
    glRotatef(tireRotate, 0, 0, 1)
    drawTire()
    glPopMatrix()
    glPushMatrix()
    glTranslatef(Ztire + 2, 0, 15 - 2)
    glRotatef(tireRotate, 0, 0, 1)
    drawTire()

    # the rest of the houses on the street
    glPopMatrix()
    glPushMatrix()
    glTranslated(-20, 0, 0)
    drawHouse()
    glRotated(90, 0, 1, 0)
    glTranslated(-20, 0, -20)
    drawHouse()
    glTranslated(-20, 0, 20)
    glRotated(90, 0, 1, 0)
    drawHouse()
    glTranslated(-20, 0, 0)
    drawHouse()
    glTranslated(-20, 0, 0)
    drawHouse()
    glTranslated(-20, 0, 0)
    drawHouse()
    glRotated(180, 0, 1, 0)
    glTranslated(0, 0, -40)
    drawHouse()
    glTranslated(-20, 0, 0)
    drawHouse()
    glPopMatrix()
    glFlush()
예제 #28
0
def draw_edge_house():
    glPushMatrix()
    glTranslated(-40, 0, 15)
    glRotated(90, 0, 1, 0)
    drawHouse()
    glPopMatrix()