def processMoveInput(self, window, deltaTime): move = np.zeros(3, np.float32) if glfw.GetKey(window, glfw.KEY_W) == glfw.PRESS: move[0] += 1 if glfw.GetKey(window, glfw.KEY_S) == glfw.PRESS: move[0] -= 1 if glfw.GetKey(window, glfw.KEY_D) == glfw.PRESS: move[1] += 1 if glfw.GetKey(window, glfw.KEY_A) == glfw.PRESS: move[1] -= 1 if glfw.GetKey(window, glfw.KEY_E) == glfw.PRESS: move[2] += 1 if glfw.GetKey(window, glfw.KEY_Q) == glfw.PRESS: move[2] -= 1 if np.linalg.norm(move) > 0: move = move / np.linalg.norm(move) if glfw.GetKey(window, glfw.KEY_LEFT_SHIFT): move *= 5 if glfw.GetKey(window, glfw.KEY_LEFT_CONTROL): move *= 0.2 dir = sphericalToCartesian(self.sphericalDir) right = np.cross(dir, self.up) forwardVec = dir * move[0] * self.speed * deltaTime rightVec = right * move[1] * self.speed * deltaTime upVec = self.up * move[2] * self.speed * deltaTime self.pos += forwardVec + rightVec + upVec
def processPlayerInput(self, window): currentTime = glfw.GetTime() deltaTime = float(currentTime - self.lastUpdateTime) self.lastUpdateTime = currentTime # print 'self.pos', self.pos # print 'self.sphericalDir', self.sphericalDir self.processMoveInput(window, deltaTime) self.processLookInput(window, deltaTime) dir = sphericalToCartesian(self.sphericalDir) self.updateMatrix(self.f, self.framebufferSize, self.pos, dir, self.up)