changed hight of camera and added camera move methode in physics

This commit is contained in:
Jasper 2015-02-13 17:47:21 +01:00
parent 3d59fb43c8
commit 760a7c9d86
2 changed files with 9 additions and 3 deletions

View File

@ -48,8 +48,8 @@ void Physics::takeUpdateStep(float timeDiff)
position += playerBall->getCenterOfMassPosition(); //is the position cameraDistance away from the player in the direction of the camera position += playerBall->getCenterOfMassPosition(); //is the position cameraDistance away from the player in the direction of the camera
//prevent the camera from being dragged along on the ground //prevent the camera from being dragged along on the ground
if (position.getY() < playerBall->getCenterOfMassPosition().getY() + 1) if (position.getY() < playerBall->getCenterOfMassPosition().getY() + cameraDistance/2)
position.setY(playerBall->getCenterOfMassPosition().getY() + 1); position.setY(playerBall->getCenterOfMassPosition().getY() + cameraDistance/2);
btVector3 dir = cameraBody->getCenterOfMassPosition() - position; btVector3 dir = cameraBody->getCenterOfMassPosition() - position;
float str = 50 * dir.length() / cameraBody->getInvMass(); //getInvMass() returns the inverted mass float str = 50 * dir.length() / cameraBody->getInvMass(); //getInvMass() returns the inverted mass
@ -478,11 +478,16 @@ void Physics::addStaticGroundPlane()
void Physics::forceMove(glm::vec3 newPosition, unsigned indice) void Physics::forceMove(glm::vec3 newPosition, unsigned indice)//ugly, but needed for reset
{ {
bodies[indice]->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z))); bodies[indice]->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z)));
} }
void Physics::forceMoveCamera(glm::vec3 newPosition)
{
cameraBody->setCenterOfMassTransform(btTransform(btQuaternion(0,0,0,1),btVector3(newPosition.x,newPosition.y,newPosition.z)));
}
void Physics::kill() //delete dynamically allocated memory void Physics::kill() //delete dynamically allocated memory
{ {
if (world == NULL) { if (world == NULL) {

View File

@ -69,6 +69,7 @@ class Physics {
void kill(); void kill();
void addButtonFrame(Entity entity); void addButtonFrame(Entity entity);
void forceMove(glm::vec3 newPosition, unsigned indice); void forceMove(glm::vec3 newPosition, unsigned indice);
void forceMoveCamera(glm::vec3 newPosition);
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;}; struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};