diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index f3ce7b46..2d49da99 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -565,8 +565,6 @@ void GameState::Protocol( ObjPos* pos ) { if(dynamicObjects[i]->GetId() == pos->object_ID) { - - //dynamicObjects[i]->setPos(Float3(world[12], world[13], world[14])); dynamicObjects[i]->setWorld(world); @@ -592,10 +590,10 @@ void GameState::Protocol( ObjPos* pos ) //camera->setUp(up); //camera->setLook(objForward); - up *= 1; + up *= 2; objForward *= -2; Oyster::Math::Float3 cameraPos = pos + up + objForward; - //camera->SetPosition(cameraPos); + camera->SetPosition(cameraPos); //camera->UpdateViewMatrix(); } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index c8cbc997..6b25c94f 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -16,7 +16,7 @@ Game::PlayerData::PlayerData() //create rigid body 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 ); - //rigidBody->SetAngularFactor(0.0f); + rigidBody->SetAngularFactor(0.0f); //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); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 06d461fa..e2e52854 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -112,36 +112,8 @@ void Level::InitiateLevel(std::string levelPath) } void Level::InitiateLevel(float radius) { - float heading = Utility::Value::Radian(180.0f); - float attitude = Utility::Value::Radian(0.0f); - float bank = Utility::Value::Radian(0); - - double c1 = cos(heading/2); - double s1 = sin(heading/2); - double c2 = cos(attitude/2); - double s2 = sin(attitude/2); - double c3 = cos(bank/2); - double s3 = sin(bank/2); - double c1c2 = c1*c2; - double s1s2 = s1*s2; - double w =c1c2*c3 - s1s2*s3; - double x =c1c2*s3 + s1s2*c3; - double y =s1*c2*c3 + c1*s2*s3; - double z =c1*s2*c3 - s1*c2*s3; - double angle = 2 * acos(w); - - double norm = x*x+y*y+z*z; - if (norm < 0.001) { // when all euler angles are zero angle =0 so - // we can set axis to anything to avoid divide by zero - x=1; - y=z=0; - } else { - norm = sqrt(norm); - x /= norm; - y /= norm; - z /= norm; - } - + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); + API::Instance().SetGravity(50); 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, 0.5f, 0.8f, 0.6f); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 535268b7..6fbc8189 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -88,7 +88,7 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody() void Object::BeginFrame() { - + } // update physic void Object::EndFrame() diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 9e826ef5..039cae63 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -6,7 +6,7 @@ using namespace GameLogic; using namespace Oyster::Physics; -const int MOVE_FORCE = 500; +const int MOVE_FORCE = 30; Player::Player() :DynamicObject() { @@ -61,6 +61,8 @@ void Player::BeginFrame() { //weapon->Update(0.002f); Object::BeginFrame(); + + } void Player::EndFrame() @@ -98,31 +100,26 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * forward.GetNormalized() ); + rigidBody->SetLinearVelocity( MOVE_FORCE * forward.GetNormalized() ); } void Player::MoveBackwards() { Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * -forward.GetNormalized() ); + rigidBody->SetLinearVelocity( MOVE_FORCE * -forward.GetNormalized() ); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - - //Oyster::Math::Float3 forward = lookDir; Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(r * 10); + rigidBody->SetLinearVelocity(r * MOVE_FORCE); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(-r * 10); + rigidBody->SetLinearVelocity(-r * MOVE_FORCE); } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -153,6 +150,8 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir) Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; this->rigidBody->SetUpAndRight(up, lookDir.xyz); + this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); + } void Player::Jump() diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index b7d11e42..6cf5ec5c 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -97,59 +97,10 @@ namespace DanBias GameSession::gameSession->networkTimer.reset(); GameLogic::IObjectData* obj = movedObject; - if(movedObject->GetID() == testID) //TODO: TEST - { - float sec = (float)testTimer.getElapsedSeconds(); - sec = 0; - } int id = obj->GetID(); Protocol_ObjectPosition p(obj->GetOrientation(), id); - //if(id != 1) GameSession::gameSession->Send(p.GetProtocol()); - - - /* - if(dynamic_cast(obj)) - { - obj = ((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_WORLD) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world =obj->GetOrientation(); - - Protocol_ObjectPosition p(world, id); - gameSession->Send(p.GetProtocol()); - } - } - - obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_BOX) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world = obj->GetOrientation(); - Protocol_ObjectPosition p(world, id); - gameSession->Send(p.GetProtocol()); - } - } - - obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(2); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_BOX) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world = obj->GetOrientation(); - Protocol_ObjectPosition p(world, id); - GameSession::gameSession->Send(p.GetProtocol()); - } - } - } - */ } } diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index d6e6106c..941c4b6a 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -136,7 +136,7 @@ namespace DanBias } else { - Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_white.dan", readyList[i]->GetPlayer()->GetOrientation()); + Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_temporary.dan", readyList[i]->GetPlayer()->GetOrientation()); readyList[i]->GetClient()->Send(p); } } @@ -156,7 +156,7 @@ namespace DanBias { if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID()) { - Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later.. + Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_temporary.dan"); //The model name will be custom later.. readyList[i]->GetClient()->Send(p); } }