Пример #1
0
def keyPressed(key, x, y):
    global actCam
    if key == chr(27):
        sys.exit(1)
    elif key == 't':
        stack.pushModelMatrix(geo.rotationMatrix(0.1, (0, 1, 0)))

    elif key == '+':  # next texture
        skybox.nextTexture()

    elif key == '-':
        skybox.preTexture()

    elif key == '1':
        actCam = (actCam + 1) % len(camList)
        glutReshapeWindow(WIDTH, HEIGHT)

    elif key == 'a':
        helicopter.rotate(0.01)
        glutReshapeWindow(WIDTH, HEIGHT)

    elif key == 'd':
        helicopter.rotate(-0.01)
        glutReshapeWindow(WIDTH, HEIGHT)

    elif key == 'w':
        helicopter.gier(-0.01)
        glutReshapeWindow(WIDTH, HEIGHT)
    glutPostRedisplay()
def keyPressed(key, x, y):
    global actCam
    if key == chr(27):
        sys.exit(1)
    elif key == 't':
        stack.pushModelMatrix(geo.rotationMatrix(0.1, (0, 1, 0)))
      
    elif key == '+':  # next texture
        skybox.nextTexture()
        
    elif key == '-':
        skybox.preTexture()
       
    elif key == '1':
        actCam = (actCam + 1) % len(camList)
        glutReshapeWindow(WIDTH, HEIGHT)
       
    elif key == 'a':
        helicopter.rotate(0.01)
        glutReshapeWindow(WIDTH, HEIGHT)
       
    elif key == 'd':
        helicopter.rotate(-0.01)
        glutReshapeWindow(WIDTH, HEIGHT)
       
    elif key == 'w':
        helicopter.gier(-0.01)
        glutReshapeWindow(WIDTH, HEIGHT)
    glutPostRedisplay()
    def drawRotor(self, pMat, mvMat, rotMat, transMat, speed):
        """
        Zeichne den Rotor mit allen Matrizen. Berechne Drehungen
        korrekt
        @param pMat: perspektivische Matrix des Helis
        @param mvMat: modelviewMatrix der Camera
        @param rotMat: vorberechnete Rotationsmatrix des Rotors
        @param transMat: translationsmatrix des Helicopters
        @param speed: aktueller Auftrieb des Helicopters
        """
        if self.start and self.r < self.maximum:
            if speed < 1:
                if self.r < self.maximum + 4:
                    self.r += 0.009
            elif speed > 1:
                if self.r > self.maximum - 1:
                    self.r -= 0.009
            else:
                if self.r < self.maximum - 1:
                    self.r += 0.009
        else:
            if self.r > 1:
                self.r -= 0.009

        (a, b, c) = self.dist
        t = geo.translationMatrix(a, b, c)
        tb = geo.translationMatrix(-a, -b, -c)
        f = geo.rotationMatrix(self.r, self.axis)
        self.rotationMatrix = self.rotationMatrix * t * f * tb

        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY)

        glEnable(GL_TEXTURE_2D)

        modelMatrix = mvMat * transMat * rotMat * self.rotationMatrix
        mvpMatrix = pMat * modelMatrix

        normalMat = linalg.inv(modelMatrix[0:3, 0:3]).transpose()
        glUseProgram(self.program)
        geo.sendMat4(self.program, "mvMatrix", modelMatrix)
        geo.sendMat4(self.program, "mvpMatrix", mvpMatrix)
        geo.sendMat3(self.program, "normalMatrix", normalMat)

        self.useRotorGeometry()

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
Пример #4
0
 def gier(self, angle):
     self.handler.pushModelMatrix(geo.rotationMatrix(angle, (1, 0, 0)))
     self.handler.pushModelMatrix(geo.translationMatrix(0, 0, 1))
Пример #5
0
 def rotate(self, angle):
     self.handler.pushModelMatrix(geo.rotationMatrix(angle, (0, 1, 0)))
 def gier(self, angle):
     self.handler.pushModelMatrix(geo.rotationMatrix(angle, (1, 0, 0)))
     self.handler.pushModelMatrix(geo.translationMatrix(0, 0, 1))
 def rotate(self, angle):
     self.handler.pushModelMatrix(geo.rotationMatrix(angle, (0, 1, 0)))