def useRotorGeometry(self):
        '''
        Lese farben, texturen und geometrie ein
        '''
        lightPos = [0, 1, 1]

        # matDic[material][0] = diffColor, matDic[material][4] = alphaValue
        geo.sendVec4(self.program, "diffuseColor",\
                     self.matDic[self.rotorMat][0]\
                     + self.matDic[self.rotorMat][4])
        geo.sendVec4(self.program, "ambientColor",
                     self.matDic[self.rotorMat][1]\
                     + self.matDic[self.rotorMat][4])
        geo.sendVec4(self.program, "specularColor",
                     [x ** self.matDic[self.rotorMat][3][0]\
                      for x in self.matDic[self.rotorMat][2]\
                      + self.matDic[self.rotorMat][4]])
        geo.sendVec3(self.program, "lightPosition", lightPos)

        self.rotorVbo.bind()

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

        if self.rotorTextureId:
            glBindTexture(GL_TEXTURE_2D, self.rotorTextureId)
        else:
            glBindTexture(GL_TEXTURE_2D, 1)
        glDrawArrays(GL_TRIANGLES, 0, self.rotorDataLen)

        self.rotorVbo.unbind()
Beispiel #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 useHelicopterGeometry(self):
        '''
        Zeichne fuer jedes VBO farben, Texturen und Daten
        '''
        lightPos = [0, 1, 1]

        # vboTextureDic = {matName:[vbo],[textureId],[len(data)]}
        for material, value in self.vboTextureDic.items():
            if material != self.mainRotorMat:
                act_vbo = value[0]
                act_textureId = value[1]
                lenData = value[2]

                # colors to shader
                geo.sendVec4(self.program, "diffuseColor",
                             self.matDic[material][0]\
                             + self.matDic[material][4])

                # if texture, use white as ambient color
                if act_textureId:
                    geo.sendVec4(self.program, "ambientColor",
                                 [1.0, 1.0, 1.0] + self.matDic[material][4])
                else:
                    geo.sendVec4(self.program, "ambientColor",
                                self.matDic[material][1]\
                                + self.matDic[material][4])

                geo.sendVec4(self.program, "specularColor",
                            [x ** self.matDic[material][3][0]\
                             for x in self.matDic[material][2]\
                             + self.matDic[material][4]])
                geo.sendVec3(self.program, "lightPosition", lightPos)

                # use vbo
                act_vbo.bind()

                glVertexPointer(3, GL_FLOAT, 36, act_vbo)
                glNormalPointer(GL_FLOAT, 36, act_vbo + 24)
                glTexCoordPointer(3, GL_FLOAT, 36, act_vbo + 12)

                if act_textureId:
                    glBindTexture(GL_TEXTURE_2D, act_textureId)
                elif material == self.tailRotorMat:
                    glBindTexture(GL_TEXTURE_2D, 8)
                else:
                    glBindTexture(GL_TEXTURE_2D, 1)
                glDrawArrays(GL_TRIANGLES, 0, lenData)

                act_vbo.unbind()