From b731c206f4d4590c8d148588e661d9bed47446e3 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Mon, 10 Feb 2014 15:54:38 +0100 Subject: [PATCH] GL - physics merge 2 --- .../Game/DanBiasGame/GameClientState/GameState.cpp | 14 +++++++------- Code/Game/GameLogic/Game.cpp | 4 ++-- Code/Game/GameLogic/Game_PlayerData.cpp | 10 +++++----- Code/Game/GameLogic/Level.cpp | 9 ++------- Code/Game/GameLogic/Object.cpp | 6 +++--- Code/Game/GameLogic/Player.cpp | 7 ++++--- 6 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index abc0e96e..9a14fa25 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -311,9 +311,9 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo C_Object* obj; modelData.visible = true; //modelData.world = world; - //modelData.position = ; - //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1); - //modelData.scale = Oyster::Math::Float3(2,2,2); + modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]); + modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1); + modelData.scale = Oyster::Math::Float3(2,2,2); modelData.modelPath = modelName; modelData.id = myId; @@ -612,15 +612,15 @@ void GameState::Protocol( ObjPos* pos ) Oyster::Math::Float3 newLook = up.Cross(right); newLook.Normalize();*/ - camera->setRight(right); - camera->setUp(up); + //camera->setRight(right); + //camera->setUp(up); //camera->setLook(objForward); up *= 1; objForward *= -2; Oyster::Math::Float3 cameraPos = pos + up + objForward; - camera->SetPosition(cameraPos); - camera->UpdateViewMatrix(); + //camera->SetPosition(cameraPos); + //camera->UpdateViewMatrix(); } } diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index ab10fcd2..c78abb09 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -81,8 +81,8 @@ Game::LevelData* Game::CreateLevel() if(this->level) return this->level; this->level = new LevelData(); - //this->level->level->InitiateLevel(1000); - this->level->level->InitiateLevel("3bana.bias"); + this->level->level->InitiateLevel(1000); + //this->level->level->InitiateLevel("3bana.bias"); return this->level; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index d598c27e..25fd51c1 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -15,16 +15,16 @@ Game::PlayerData::PlayerData() //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); //create player with this rigid body this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); - Oyster::Physics::ICustomBody::State state; - this->player->GetRigidBody()->GetState(state); - //state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0)); - this->player->GetRigidBody()->SetState(state); + //Oyster::Physics::ICustomBody::State state; + //this->player->GetRigidBody()->GetState(state); + ////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0)); + //this->player->GetRigidBody()->SetState(state); player->EndFrame(); } Game::PlayerData::PlayerData(int playerID,int teamID) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index bff1d5c3..0e96be28 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -230,12 +230,7 @@ void Level::InitiateLevel(float radius) int idCount = 100; // add level sphere - ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0); - - ICustomBody::State state; - rigidBody->GetState(state); - state.restitutionCoeff = 0.2f; - rigidBody->SetState(state); + ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); this->levelObj->objectID = idCount++; rigidBody->SetCustomTag(levelObj); @@ -247,7 +242,7 @@ void Level::InitiateLevel(float radius) int offset = 0; for(int i =0; i< nrOfBoxex; i ++) { - rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5); + rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[i]->objectID = idCount++; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index f099be18..77c256eb 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -16,7 +16,7 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance()); Object::Object() { - this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0); + this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN; this->objectID = GID(); @@ -26,7 +26,7 @@ Object::Object() Object::Object(OBJECT_TYPE type) { - this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0); + this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); this->type = type; this->objectID = GID(); this->currPhysicsState = this->rigidBody->GetState(); @@ -44,7 +44,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) { - this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0); + this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); this->type = type; this->objectID = GID(); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index f407d8f0..de45f8cb 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -109,6 +109,7 @@ void Player::MoveForward() Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; //Oyster::Math::Float3 forward = lookDir; //newPhysicsState.ApplyLinearImpulse(forward * (MOVE_FORCE * this->gameInstance->GetFrameTime())); + //rigidBody->SetLinearVelocity( 10 * this->gameInstance->GetFrameTime() ); } void Player::MoveBackwards() { @@ -120,10 +121,10 @@ void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; + //Oyster::Math::Float3 forward = lookDir; - //Oyster::Math::Float3 r = (-currPhysicsState.GetGravityNormal()).Cross(forward); - //newPhysicsState.ApplyLinearImpulse(-r * MOVE_FORCE * this->gameInstance->GetFrameTime()); - + Oyster::Math::Float3 r = (-currPhysicsState.centerPos.Normalize()).Cross(forward); + //rigidBody->SetLinearVelocity(-r * 10 * this->gameInstance->GetFrameTime() ); } void Player::MoveLeft() {