Made it possible again to move the camera upwards.

This commit is contained in:
Steffen Fündgens 2015-02-13 12:47:34 +01:00
parent 012d117c7e
commit cb6f535382

View File

@ -43,13 +43,14 @@ void Physics::takeUpdateStep(float timeDiff)
} }
btVector3 position = cameraBody->getCenterOfMassPosition() - playerBall->getCenterOfMassPosition(); //gets a vector from the player to the camera btVector3 position = cameraBody->getCenterOfMassPosition() - playerBall->getCenterOfMassPosition(); //gets a vector from the player to the camera
position.normalize(); position.normalize();
position *= 5; position *= 5;
position += playerBall->getCenterOfMassPosition(); //is the position 5 units away from the player in the direction of the camera position += playerBall->getCenterOfMassPosition(); //is the position 5 units away from the player in the direction of the camera
position.setY(playerBall->getCenterOfMassPosition().getY() + 1);
//prevent the camera from being dragged along on the ground
if (position.getY() < playerBall->getCenterOfMassPosition().getY() + 1)
position.setY(playerBall->getCenterOfMassPosition().getY() + 1);
btVector3 dir = cameraBody->getCenterOfMassPosition() - position; btVector3 dir = cameraBody->getCenterOfMassPosition() - position;
float str = cameraBody->getInvMass()*50 * dir.length(); float str = cameraBody->getInvMass()*50 * dir.length();
@ -355,7 +356,7 @@ glm::vec3 Physics::getCameraPosition()
return save; return save;
} }
glm::vec3 Physics::getCameraToPlayer()//returns a glm::vec3 the goes from the player to the camera glm::vec3 Physics::getCameraToPlayer()//returns a glm::vec3 the goes from the camera to the player
{ {
btVector3 origin = playerBall->getCenterOfMassPosition() - cameraBody->getCenterOfMassPosition(); btVector3 origin = playerBall->getCenterOfMassPosition() - cameraBody->getCenterOfMassPosition();
glm::vec3 save(origin.getX(),origin.getY(),origin.getZ()); glm::vec3 save(origin.getX(),origin.getY(),origin.getZ());