def initHelicopter(self): self.objectVertices, self.objectTextures, self.objectNormals, self.objectFaces = self.objLoader.loadObjFile(self.filename) self.data, self.heli_vbo = self.objLoader.createDataFromObj() # Create BoundingBox self.boundingBox = [map(min, zip(*self.objectVertices)), map(max, zip(*self.objectVertices))] self.center = [(x[0]+x[1])/2.0 for x in zip(*self.boundingBox)] self.scaleFactor = 2.0/max([(x[1]-x[0]) for x in zip(*self.boundingBox)]) # Scale, Center self.handler.pushModelMatrix(geo.scaleMatrix(self.scaleFactor, self.scaleFactor, self.scaleFactor)) self.handler.pushModelMatrix(geo.translationMatrix(-self.center[0], -self.center[1], -self.center[2])) im = Image.open("./heli_data/500DLINE.JPG") width, height = im.size image = array(im)[::-1,:].tostring() self.textureIDs = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, self.textureIDs) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image) glGenerateMipmap(GL_TEXTURE_2D)
def initHelicopter(self): self.objectVertices, self.objectTextures, self.objectNormals, self.objectFaces = self.objLoader.loadObjFile( self.filename) self.data, self.heli_vbo = self.objLoader.createDataFromObj() # Create BoundingBox self.boundingBox = [ map(min, zip(*self.objectVertices)), map(max, zip(*self.objectVertices)) ] self.center = [(x[0] + x[1]) / 2.0 for x in zip(*self.boundingBox)] self.scaleFactor = 2.0 / max([(x[1] - x[0]) for x in zip(*self.boundingBox)]) # Scale, Center self.handler.pushModelMatrix( geo.scaleMatrix(self.scaleFactor, self.scaleFactor, self.scaleFactor)) self.handler.pushModelMatrix( geo.translationMatrix(-self.center[0], -self.center[1], -self.center[2])) im = Image.open("./heli_data/500DLINE.JPG") width, height = im.size image = array(im)[::-1, :].tostring() self.textureIDs = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, self.textureIDs) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image) glGenerateMipmap(GL_TEXTURE_2D)
def zoom(self, zoom): """ Zoom der Camera, strekt die Matrix mit Zoomfaktor @param zoom: zoomfaktor """ self.zoomMat = geo.scaleMatrix(zoom, zoom, zoom)