예제 #1
0
def display_callback():

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glEnable(GL_TEXTURE_2D)

    if cam.asteroid is True:
        cam.forward = Vertex4(asteroid.ellipse.lastCoords[0], 0,
                              asteroid.ellipse.lastCoords[1], 0.0)
        cam.up = Vertex4(0.0, 1.0, 0.0, 0.0)
        cam.setSide()
        cam.yaw(35)

    cam.look()
    glLightfv(GL_LIGHT0, GL_POSITION, light_pos_0)

    for i in planets:
        i.draw()

    sun.render()

    asteroid.draw()

    obj.render()

    # SPACESHIP
    glPushMatrix()
    glTranslatef(25.0, 10.0, 12.5)
    glRotatef(55, 0.0, 1.0, 0.0)
    visualization.draw(ship)
    glPopMatrix()

    # SATURN RINGS
    glTranslatef(saturn.lastCoords[0], 0.0, saturn.lastCoords[1])
    glRotatef(90, 1.0, 0.0, 0.0)
    glRotatef(25, 1.0, 1.0, 0.0)
    glColor4f(1.0, 1.0, 1.0, 0.5)
    glScalef(0.2, 0.2, 0.2)
    glEnable(GL_TEXTURE_2D)
    glDisable(GL_LIGHTING)
    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE)
    glBindTexture(GL_TEXTURE_2D, t.textureId)
    gluDisk(quad, 9, 14, 64, 1)
    glDisable(GL_BLEND)
    glEnable(GL_LIGHTING)
    glDisable(GL_TEXTURE_2D)

    # CONTROL KEYS LINES
    draw_text("CONTROL KEYS", 5, 190)
    draw_text("(a)->left, (s)->down, (d)->up, (w)->right", 5, 150)
    draw_text("(z)->zoom +, (x)->zoom -", 5, 110)
    draw_text(
        "(1)->yaw left, (2)->yaw right, (3)->roll left, (4)->roll right, (5)->pitch down, (6)->pitch up",
        5, 70)
    draw_text("(7)->top-bottom view, (8)->spaceship view, (9)->asteroid view",
              5, 30)

    glutSwapBuffers()
예제 #2
0
    def on_draw(self):
        self.clear()
        pyglet.gl.glLoadIdentity()

        pyglet.gl.glLightfv(pyglet.gl.GL_LIGHT0, pyglet.gl.GL_POSITION,
                            self.lightfv(-40.0, 200.0, 100.0, 0.0))
        pyglet.gl.glLightfv(pyglet.gl.GL_LIGHT0, pyglet.gl.GL_AMBIENT,
                            self.lightfv(0.2, 0.2, 0.2, 1.0))
        pyglet.gl.glLightfv(pyglet.gl.GL_LIGHT0, pyglet.gl.GL_DIFFUSE,
                            self.lightfv(0.5, 0.5, 0.5, 1.0))
        pyglet.gl.glEnable(pyglet.gl.GL_LIGHT0)
        pyglet.gl.glEnable(pyglet.gl.GL_LIGHTING)

        pyglet.gl.glEnable(pyglet.gl.GL_COLOR_MATERIAL)
        pyglet.gl.glEnable(pyglet.gl.GL_DEPTH_TEST)
        pyglet.gl.glShadeModel(pyglet.gl.GL_SMOOTH)

        pyglet.gl.glMatrixMode(pyglet.gl.GL_MODELVIEW)

        # pyglet.gl.glTranslated(0, .8, -20)
        pyglet.gl.glRotatef(-90, 0, 0, 1)
        pyglet.gl.glRotatef(self.rotation, 1, 0, 0)
        pyglet.gl.glRotatef(90, 0, 0, 1)
        pyglet.gl.glRotatef(0, 0, 1, 0)

        visualization.draw(self.meshes)
예제 #3
0
def on_draw():
    window.clear()

    glLoadIdentity()

    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-40.0, 200.0, 100.0, 0.0))
    glLightfv(GL_LIGHT0, GL_AMBIENT, lightfv(0.2, 0.2, 0.2, 1.0))
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightfv(0.5, 0.5, 0.5, 1.0))
    glEnable(GL_LIGHT0)
    glEnable(GL_LIGHTING)

    glEnable(GL_COLOR_MATERIAL)
    glEnable(GL_DEPTH_TEST)
    glShadeModel(GL_SMOOTH)

    glMatrixMode(GL_MODELVIEW)

    # glTranslated(0, 4, -8)
    # glRotatef(90, 0, 1, 0)
    # glRotatef(-60, 0, 0, 1)

    # Rotations for sphere on axis - useful
    glTranslated(0, .8, -20)
    glRotatef(-66.5, 0, 0, 1)
    glRotatef(rotation, 1, 0, 0)
    glRotatef(90, 0, 0, 1)
    glRotatef(0, 0, 1, 0)

    visualization.draw(meshes)
예제 #4
0
def draw_link0(link, x, y, z, link0Rot):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glRotatef(link0Rot, 0.0, 1.0, 0.0)
    glTranslatef(x, y, z)

    visualization.draw(link)
예제 #5
0
def mirroir2(a, c):
    glRotate(-a, 0, 1, 0)

    glTranslatef(0, 0, 3)
    glTranslatef(0, -3 * (1 - cos(3.14 * c / 180)),
                 -3 * (1 - sin(3.14 * c / 180)))
    visualization.draw(obj)
예제 #6
0
def on_draw():
    window.clear()

    glLoadIdentity()

    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-40.0, 200.0, 100.0, 0.0))
    glLightfv(GL_LIGHT0, GL_AMBIENT, lightfv(0.2, 0.2, 0.2, 1.0))
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightfv(0.5, 0.5, 0.5, 1.0))
    glEnable(GL_LIGHT0)
    glEnable(GL_LIGHTING)

    glEnable(GL_COLOR_MATERIAL)
    glEnable(GL_DEPTH_TEST)
    glShadeModel(GL_SMOOTH)

    glMatrixMode(GL_MODELVIEW)

    # glTranslated(0, 4, -8)
    # glRotatef(90, 0, 1, 0)
    # glRotatef(-60, 0, 0, 1)

    # Rotations for sphere on axis - useful
    glTranslated(0, .8, -20)
    glRotatef(-66.5, 0, 0, 1)
    glRotatef(rotation, 1, 0, 0)
    glRotatef(90, 0, 0, 1)
    glRotatef(0, 0, 1, 0)

    visualization.draw(meshes)
예제 #7
0
def draw_link1(link, x, y, z, link0Rot, link1Rot):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    #glRotatef(180,0,1,0) #flips l1 around so it isnt bending backwards
    glRotatef(link0Rot, 0.0, 1.0, 0.0)
    glRotatef(link1Rot, 1.0, 0.0, 0.0)

    visualization.draw(link)
예제 #8
0
파일: obj.py 프로젝트: HemuManju/shasta
    def update(self):
        # Draw OBJ
        self.apply_transformation()
        visualization.draw(self.meshes)

        # # Draw UxV
        for i, sphere in enumerate(self.spheres):
            sphere.draw()
예제 #9
0
def draw_box(box, x, y):
    glLoadIdentity()
    glTranslated(x, y, -10.0)
    glRotatef(rotation, 0.0, 1.0, 0.0)
    glRotatef(-25.0, 1.0, 0.0, 0.0)
    glRotatef(45.0, 0.0, 0.0, 1.0)

    visualization.draw(box)
예제 #10
0
def display():
    movimentOfCamera()
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glPushMatrix()
    color = [1.0, 0., 0., 1.]
    visualization.draw(home)
    glPopMatrix()
    glutSwapBuffers()
예제 #11
0
 def on_draw():
     window.clear()
     gl.glLoadIdentity()
     gl.glTranslated(self.x, self.y, self.z)
     gl.glRotatef(self.rx, 1, 0, 0)
     gl.glRotatef(self.ry, 0, 1, 0)
     gl.glRotatef(self.rz, 0, 0, 1)
     visualization.draw(self.mesh)
예제 #12
0
def draw_head(link, x, y, z, thetaHead, phiHead):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glScalef(0.8, 0.8, 0.8)
    glTranslatef(x, y, z)
    glRotatef(thetaHead, 0, 1, 0)
    glRotatef(phiHead, 1, 0, 0)

    visualization.draw(link)
예제 #13
0
def draw_torso(link, x, y, z, bodyRot, bodyTilt):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glScalef(0.8, 0.8, 0.8)
    glTranslatef(x, y, z)
    glRotatef(bodyRot + 180, 0, 1, 0)
    glRotatef(bodyTilt, 1, 0, 0)

    visualization.draw(link)
예제 #14
0
def display():
    glFlush()
    if demonstrateMode:
        demonstrate()
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    
    visualization.draw(objeto)
    glutSwapBuffers()
    glFlush()
예제 #15
0
def draw_upperArm(link, x, y, z, thetaArm0, thetaArm1):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glScalef(0.8, 0.8, 0.8)
    glTranslatef(x, y, z)
    glRotatef(180, 0, 1, 0)
    glRotatef(thetaArm0, 0, 1, 0)
    glRotatef(thetaArm1, -1, 0, 0)
    visualization.draw(link)
예제 #16
0
def on_draw():
    window.clear()
    glLoadIdentity()
    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-1.0, 1.0, 1.0, 0.0))
    glEnable(GL_LIGHT0)
    glTranslated(0.0, 0.0, -3.0)
    glRotatef(rotation, x, y, x)
    glEnable(GL_LIGHTING)
    visualization.draw(meshes)
예제 #17
0
파일: obj.py 프로젝트: HemuManju/shasta
    def do_draw(self):
        # Draw OBJ
        self.apply_transformation()
        visualization.draw(self.meshes)

        if self.active:
            self.prepare_projection()
            if self.vertex_list is not None:
                self.vertex_list.draw(gl.GL_LINE_LOOP)
예제 #18
0
def display():
    global obj, holder

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    visualization.draw(obj)

    glutSwapBuffers()
    return
예제 #19
0
def display():
    global obj

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE)
    visualization.draw(obj)

    glutSwapBuffers()
    return
예제 #20
0
    def display(self, fusionQPose):
        glClearColor(0, .2, .7, 0)
        glClearDepth(100)
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        glPushMatrix()

        def glRotateQ(q):
            try:
                glRotatef(quaternion.angle(q)*180/math.pi, q[1], q[2], q[3])
            except:
                pass

        dist = 12
        glTranslatef(0, 0, -dist)
        glScalef(self.Scale, self.Scale, self.Scale)
        glRotateQ(self.Q)

        if self.obj:
            glPushMatrix()
            #q = quaternion.multiply(fusionQPose, quaternion.angvec2quat(-math.pi/2, [1, 0, 0]))
            q = fusionQPose
            glRotateQ(q)
            #OAglTranslatef(0, 0, -.7)


            s = .2
            glScalef(s,s,s)
            #        glTranslated(0, 0, -3)
            glRotatef(90, 0, 0, -1)
            glRotatef(90, -1, 0, 0)
            glEnable(GL_LIGHTING)
            
            lightfv = ctypes.c_float * 4
            glLightfv(GL_LIGHT0, GL_DIFFUSE, lightfv(1.0, 1.0, 1.0, 1.0))
            glEnable(GL_LIGHT0)
            visualization.draw(self.obj)
            glDisable(GL_LIGHTING)

            glPopMatrix()

        elif pywavefront:
            self.chdir()
            try:
                self.obj = pywavefront.Wavefront('Vagabond.obj')
            except Exception as e:
                print('Vagabond.obj failed to load', e)
                print('Did you add the pypilot_data repository?')

        glEnable(GL_DEPTH_TEST)
        if self.texture_compass:
            self.draw_texture_compass()
        else:
            self.draw_vector_compass()
        glPopMatrix()
예제 #21
0
def draw_hand(link, x, y, z, thetaHand, phiHand):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glScalef(0.8, 0.8, 0.8)
    glTranslatef(x, y, z)
    glRotatef(270 + 0.25 * phiHand, 1, 0, 0)
    glRotatef(180, 0, 0, 1)
    glRotatef(thetaHand, 0, 1, 0)

    visualization.draw(link)
예제 #22
0
def draw_box(box, cx, cy, cz, x, y, z):
    glLoadIdentity()
    glTranslated(cx, cy, -10)
    glRotatef(rotation, 0.0, 1.0, 0.0)
    glTranslated(x, y, 00)
    #glTranslated(x, y, 1.0)
    #glRotatef(-25.0, 1.0, 0.0, 0.0)
    #glRotatef(45.0, 0.0, 0.0, 1.0)

    visualization.draw(box)
예제 #23
0
def display():
    global incx1
    global mesh

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    visualization.draw(mesh)

    glutSwapBuffers()

    return
예제 #24
0
def display():
    global obj

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    gluLookAt(CameraPosition[0],CameraPosition[1],CameraPosition[2],
              CameraPosition[0]+CameraTarget[0],CameraPosition[1]+CameraTarget[1],CameraPosition[2]+CameraTarget[2],
              up_axis[0],up_axis[1],up_axis[2])
    visualization.draw(obj)
    glutSwapBuffers()
    return
예제 #25
0
def draw_link1(link, x, y, z, link0Rot, link1Rot):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glRotatef(180, 0, 1, 0)  #flips l1 around so it isnt bending backwards
    glRotatef(link0Rot, 0.0, 1.0, 0.0)
    glRotatef(link1Rot, 1.0, 0.0, 0.0)
    #glTranslated(x, y, z) # link 1 does not translate about workspace, only pivots on shoulder base
    #    glRotatef(-25.0, 1.0, 0.0, 0.0)
    #    glRotatef(45.0, 0.0, 0.0, 1.0)

    visualization.draw(link)
예제 #26
0
def draw_lowerArm(link,elbowX,elbowY,elbowZ,thetaArm0,thetaArm1,thetaArm2):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glScalef(0.8,0.8,0.8)
    glScalef(1.0,0.96,1.0) #make arm segments same length for simplicity
    glTranslatef(elbowX,elbowY,elbowZ)
    # glTranslatef(1,0,0.5) #sets offset from slanted upper arm
    glRotatef(180,0,1,0)
    glRotatef(thetaArm0,0,1,0)
    glRotatef(thetaArm1,-1,0,0)
    glRotatef(thetaArm2,-1,0,0)
    visualization.draw(link)
예제 #27
0
def draw_link3(link, x, y, z, link0Rot, link1Rot, link2Rot, rotation):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glTranslatef(x, y, z)
    glRotatef(link0Rot, 0.0, 1.0, 0.0)
    glRotatef(link1Rot, -1.0, 0.0, 0.0)
    glRotatef(link2Rot + 90, 1.0, 0.0, 0.0)
    glRotatef(rotation, 0.0, 0.0, 1.0)

    #    glRotatef(45.0, 0.0, 0.0, 1.0)

    visualization.draw(link)
예제 #28
0
def display():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glMatrixMode(GL_MODELVIEW)

    #criaçao dos inimigos
    glPushMatrix()
    glTranslatef(move_inimigo, 4.0, -4.0)
    glColor3f(0.0, 0.0, 1.0)
    visualization.draw(inimigo)
    glPopMatrix()

    glPushMatrix()
    glTranslatef((move_inimigo + 4), 4.0, -4.0)  #(x, y z)
    glColor3f(0.0, 0.0, 1.0)
    visualization.draw(inimigo)
    glPopMatrix()

    glPushMatrix()
    glTranslatef((move_inimigo - 4), 4.0, -4.0)
    glColor3f(0.0, 0.0, 1.0)
    visualization.draw(inimigo)
    glPopMatrix()
    #fim criaçao dos inimigos

    #inicio da criação da nave
    glPushMatrix()
    glTranslatef(Move_nave, 0.0, 0.0)
    glTranslatef(0.0, 0.0, 5.0)  #(x, y, z)
    visualization.draw(aviao_corpo)
    glPopMatrix()

    ##fim da criação da nave

    glutSwapBuffers()
예제 #29
0
def on_draw():
    window.clear()
    glLoadIdentity()

    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-1.0, 1.0, 1.0, 0.0))
    glEnable(GL_LIGHT0)

    glTranslated(0.0, 0.0, -3.0)
    glRotatef(rotation, 0.0, 1.0, 0.0)
    glRotatef(-25.0, 1.0, 0.0, 0.0)
    glRotatef(45.0, 0.0, 0.0, 1.0)

    glEnable(GL_LIGHTING)

    visualization.draw(meshes)
예제 #30
0
def on_draw():

    window.clear()
    glLoadIdentity()

    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-1.0, 1.0, 1.0, 0.0))
    glEnable(GL_LIGHT0)

    glTranslated(0, 150, -500)
    glRotatef(float(yaw), 0, 1, 0)
    glRotatef(float(pitch), 1, 0, 0)
    glRotatef(float(roll), 0, 0, 1)
    glEnable(GL_LIGHTING)

    visualization.draw(rov)
def on_draw():
    window.clear()
    glLoadIdentity()

    glLightfv(GL_LIGHT0, GL_POSITION, lightfv(-1.0, 1.0, 1.0, 0.0))
    glEnable(GL_LIGHT0)

    glTranslated(tvec[0][0][0] * 6, -tvec[0][0][1] * 6, -tvec[0][0][2] * 4)
    glRotatef(rotation1, 1, 0, 0)
    glRotatef(rotation2, 0, 1, 0)
    glRotatef(rotation3, 0, 0, 1)

    glEnable(GL_LIGHTING)

    visualization.draw(meshes)
예제 #32
0
def draw_link2(link, x, y, z, link0Rot, link1Rot, link2Rot):
    glLoadIdentity()
    glMatrixMode(GL_MODELVIEW)
    glTranslatef(x, y, z)
    #print("link0Rot: ", link0Rot, " Link1Rot: ", link1Rot, " Link2Rot: ", link2Rot)
    glRotatef(link0Rot, 0.0, 1.0, 0.0)
    glRotatef(link1Rot, -1.0, 0.0, 0.0)
    glRotatef(link2Rot, 1.0, 0.0, 0.0)
    glRotatef(180, 0, 1, 0)  #flipped around to match l1

    #glTranslatef(-x, -y, -z)

    #    glRotatef(45.0, 0.0, 0.0, 1.0)

    visualization.draw(link)