def drawHelicopter(self, pMatrix, mvMatrix):
        '''
        Zeichne den Helicopter pro Step
        @param pMatrix: die Perspektivische Matrix der Camera
        @param mvMatrix: die Modelviewmatrix der Camera
        '''
        self.mainRotor.drawRotor(pMatrix, mvMatrix, self.actOri,
                                 self.translationMatrix, self.speed)
        self.tailRotor.drawRotor(pMatrix, mvMatrix, self.actOri,
                                 self.translationMatrix, self.speed)

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

        glEnable(GL_TEXTURE_2D)

        mvMat = mvMatrix * self.translationMatrix * self.actOri
        mvpMatrix = pMatrix * mvMat

        normalMat = np.linalg.inv(mvMat[0:3, 0:3]).T

        glUseProgram(self.program)
        geo.sendMat4(self.program, "mvMatrix", mvMat)
        geo.sendMat4(self.program, "mvpMatrix", mvpMatrix)
        geo.sendMat3(self.program, "normalMatrix", normalMat)

        self.useHelicopterGeometry()

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
Exemple #2
0
    def drawHelicopter(self, pMatrix, mvMatrix):
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY)

        temp = mvMatrix * self.handler.mvMat
        mvpMatrix = pMatrix * temp

        normalMat = linalg.inv(mvMatrix[0:3, 0:3]).T

        glUseProgram(self.program)
        geo.sendMat4(self.program, "mvMatrix", mvMatrix)
        geo.sendMat4(self.program, "mvpMatrix", mvpMatrix)
        geo.sendMat3(self.program, "normalMatrix", normalMat)
        geo.sendVec4(self.program, "diffuseColor", self.diffCol)
        geo.sendVec4(self.program, "ambientColor", self.ambCol)
        geo.sendVec4(self.program, "specularColor", self.specCol)
        geo.sendVec3(self.program, "lightPosition", self.lightPos)

        self.heli_vbo.bind()

        glVertexPointer(3, GL_FLOAT, 36, self.heli_vbo)
        glNormalPointer(GL_FLOAT, 36, self.heli_vbo + 24)
        glTexCoordPointer(3, GL_FLOAT, 36, self.heli_vbo + 12)

        glBindTexture(GL_TEXTURE_2D, self.textureIDs)
        glDrawArrays(GL_TRIANGLES, 0, len(self.data))

        self.heli_vbo.unbind()

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
    def drawHelicopter(self, pMatrix, mvMatrix):
        glEnableClientState(GL_VERTEX_ARRAY)
        glEnableClientState(GL_NORMAL_ARRAY)
        glEnableClientState(GL_TEXTURE_COORD_ARRAY)

        temp = mvMatrix *  self.handler.mvMat
        mvpMatrix = pMatrix * temp

        normalMat = linalg.inv(mvMatrix[0:3, 0:3]).T

        glUseProgram(self.program)
        geo.sendMat4(self.program, "mvMatrix", mvMatrix)
        geo.sendMat4(self.program, "mvpMatrix", mvpMatrix)
        geo.sendMat3(self.program, "normalMatrix", normalMat)
        geo.sendVec4(self.program, "diffuseColor", self.diffCol)
        geo.sendVec4(self.program, "ambientColor", self.ambCol)
        geo.sendVec4(self.program, "specularColor", self.specCol)
        geo.sendVec3(self.program, "lightPosition", self.lightPos)

        self.heli_vbo.bind()
        
        glVertexPointer(3, GL_FLOAT, 36, self.heli_vbo)
        glNormalPointer(GL_FLOAT, 36, self.heli_vbo + 24)
        glTexCoordPointer(3, GL_FLOAT, 36, self.heli_vbo + 12)

        glBindTexture(GL_TEXTURE_2D, self.textureIDs)
        glDrawArrays(GL_TRIANGLES, 0, len(self.data))

        self.heli_vbo.unbind()

        glDisableClientState(GL_VERTEX_ARRAY)
        glDisableClientState(GL_NORMAL_ARRAY)
        glDisableClientState(GL_TEXTURE_COORD_ARRAY)
    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)