def __init__(self, pos): """ Initialisiere ActionCamera @param pos: Position an der Kamera steht. Punkt e """ Camera.__init__(self) self.pos = Vector(pos[0], pos[1], pos[2]) self.actOri = geo.identity() self.rotation = geo.identity()
def __init__(self, e, c, up): """ Konstruktor fuer FreeCamera mit Arcball rotation @param e: standpunkt der camera @param c: blickpunkt der camera @param up: up-vektor der camera """ Camera.__init__(self) self.mvMat = geo.lookAtMatrix(e[0], e[1], e[2], # position c[0], c[1], c[2], # center up[0], up[1], up[2]) # up vector self.actOri = geo.identity() self.rotation = geo.identity() self.zoomMat = geo.identity()
def reset(self): """ setzt helicopter an Ursprung zurueck """ self.heli.position = self.heli.startPosition self.heli.translationMatrix =\ geo.translationMatrix(self.heli.position[0], self.heli.position[1], self.heli.position[2]) self.heli.speed = 1 self.heli.actOri = geo.identity() self.heli.collision = False
def initHelicopter(self): """ initialisiere Helicopter mit Hilfe von Obj-Loader """ # load obj File self.objectVertices, self.facesDic, self.matDic, self.bb =\ self.objLoader.loadObjFile(self.filename) (a, b, c), (d, e, f) = self.bb[0], self.bb[1] self.bb = [Vector(a, b, c), Vector(d, e, f)] self.startPosition[1] += abs(b) # vector self.position = self.startPosition self.translationMatrix = geo.translationMatrix(self.position[0], self.position[1], self.position[2]) # initial Helicopter Geometry self.initHelicopterGeometry() rojoData = self.objLoader.createData(self.facesDic["500-D_Rojo"]) maxRotor = [max([x[0] for x in rojoData]), max([x[1] for x in rojoData]), max([x[2] for x in rojoData])] minRotor = [min([x[0] for x in rojoData]), min([x[1] for x in rojoData]), min([x[2] for x in rojoData])] mittel = map(lambda x, y: x + (y - x) / 2, minRotor, maxRotor) #### MAIN self.mainRotor = Rotor(self.vboTextureDic[self.mainRotorMat][0], self.vboTextureDic[self.mainRotorMat][1], self.vboTextureDic[self.mainRotorMat][2], self.objLoader.createData(self.facesDic[ self.mainRotorMat]), self.matDic, self.program, self.mainRotorMat, "main", mittel) #### TAIL und FrontLine separieren tailRotorFaces = [] frontLine = [] for facesList in self.facesDic[self.tailRotorMat]: for faces in facesList: if [singleFace for singleFace in faces if singleFace > 2720]\ != []: tailRotorFaces.append([singleFace for singleFace in faces\ if singleFace > 2720]) if [singleFace for singleFace in faces if singleFace < 2720]\ != []: frontLine.append([singleFace for singleFace in faces]) self.tailRotorData = self.objLoader.createData([tailRotorFaces]) self.tailRotorDataLen = len(self.tailRotorData) self.tailRotorVbo = vbo.VBO(np.array(self.tailRotorData, 'f')) self.tailRotorTextureId = self.vboTextureDic[self.tailRotorMat][1] frontLineData = self.objLoader.createData([frontLine]) frontLineDataLen = len(frontLineData) self.frontLineDataLenList = [] self.frontLineDataLenList.append(frontLineDataLen) frontLineVbo = vbo.VBO(np.array(frontLineData, 'f')) self.frontLineVboList = [] self.frontLineVboList.append(frontLineVbo) frontLineTextureId = self.vboTextureDic[self.tailRotorMat][1] self.frontLineTextureIdList = [] self.frontLineTextureIdList.append(frontLineTextureId) maxRotor = [max([x[0] for x in self.tailRotorData]), max([x[1] for x in self.tailRotorData]), max([x[2] for x in self.tailRotorData])] minRotor = [min([x[0] for x in self.tailRotorData]), min([x[1] for x in self.tailRotorData]), min([x[2] for x in self.tailRotorData])] mittel = map(lambda x, y: x + (y - x) / 2, minRotor, maxRotor) self.tailRotor = Rotor(vbo.VBO(np.array(self.tailRotorData, 'f')), self.vboTextureDic[self.tailRotorMat][1], len(self.tailRotorData), self.objLoader.createData([tailRotorFaces]), self.matDic, self.program, self.tailRotorMat, "heck", mittel, 12) self.actOri = geo.identity() # Frontline zum vboTextureDic hinzufuegen del(self.vboTextureDic[self.tailRotorMat]) if not self.tailRotorMat in self.vboTextureDic.keys(): self.vboTextureDic[self.tailRotorMat] =\ self.vboTextureDic.get(self.tailRotorMat, self.frontLineVboList\ + self.frontLineTextureIdList\ + self.frontLineDataLenList) else: self.vboTextureDic[self.tailRotorMat].append(self.frontLineVboList\ + self.frontLineTextureIdList\ + self.frontLineDataLenList)
HeliCamera(5, 0), # back cam HeliCamera(-0.1, 0.6), # rotor cam ActionCamera((0, 0, 0)), ActionCamera((-GAMESIZE * 0.1, GAMESIZE * 0.1, GAMESIZE * 0.1)), ActionCamera((-GAMESIZE * 0.04, 0, GAMESIZE * 0.04)), ActionCamera((1, GAMESIZE * 0.4, 1))] actCam = 2 # counter for actual camera perspectiveMatrix =\ g.perspectiveMatrix(45, WIDTH / HEIGHT, NEARPLANE, FARPLANE) HELI_OBJ_FILE = 'heli_data/HELICOPTER500D.obj' axis = [1, 0, 0] actOri = g.identity() angle = 0 moveP = (0.1, 0.1, 0.1) def init(): """ erstellt Spielobjekte und setzt OpenGL Zustaende """ global skybox, helicopter, helipad, space, helipad2 initShader() ### create objects for simulation skybox = Skybox(shader['image'], TEXTURE_LOCATION, GAMESIZE) helicopter = Helicopter(shader['heli'], ObjLoader(GAMESIZE), Vector(-40, HELIPADPOS - GAMESIZE, -40), HELI_OBJ_FILE) helipad = HeliPad(shader['image'], 2, GAMESIZE, HELIPADPOS, 10, -40, -40)