void Player::process() { //the process functions is called by the SimulationMain each renderloop to move the player and camera //velo 0, -0.01f, 0 für schwerkraft if (flying) velo = velo + glm::vec3(0.0f, -0.01f, 0.0f); else velo = velo + glm::vec3(0.0f, -0.0f, 0.0f); glm::vec3 tmp = camera->getPosition(); //camera->translate(velo); tmp = tmp + camera->getMoveForwarBackwardOrientation() * velo; AABB testAABB; testAABB.createAABB(tmp.x + dx, tmp.y + dy, tmp.z + dz, tmp.x - dx, tmp.y - dy, tmp.z - dz); //updatePlayerPosition(camera->getPosition()); if (simulation->testPlayerCollision(testAABB)) { // camera->translate(camera->getPosition() - tmp); // updatePlayerPosition(camera->getPosition()); velo = glm::vec3(0.0f, 0.0f, 0.0f); midAir = false; } else { camera->translate(velo); updatePlayerPosition(camera->getPosition()); midAir = true; } prevCameraPosition = camera->getCenterPoint(); }
void Player::translate(glm::vec3 translation) { glm::vec3 tmp = camera->getPosition(); tmp = tmp + camera->getMoveForwarBackwardOrientation() * translation; AABB testAABB; testAABB.createAABB(tmp.x + dx, tmp.y + dy, tmp.z + dz, tmp.x - dx, tmp.y - dy, tmp.z - dz); if (simulation->testPlayerCollision(testAABB)) { // camera->translate(camera->getPosition()-tmp); // updatePlayerPosition(camera->getPosition()); } else { camera->translate(translation); updatePlayerPosition(camera->getPosition()); } }