From 1fc6f16409c38806efbdaaf883398c83b1a304b2 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 10:09:03 +0100 Subject: [PATCH] GL - rotation testing --- .../DanBiasGame/GameClientState/GameState.cpp | 74 +++++++++++-------- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 7 +- Code/Game/GameLogic/Level.cpp | 11 ++- Code/Game/GameLogic/Player.cpp | 7 +- 5 files changed, 58 insertions(+), 43 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 0a732062..6dc53c47 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -60,22 +60,7 @@ GameState::gameStateState GameState::LoadGame() plight.Radius = 300; plight.Bright = 0.5f; Oyster::Graphics::API::AddLight(plight); - //plight.Pos = Float3(350,350,5); - //plight.Color = Float3(0.9f,0.7f,0.3f); - //plight.Radius = 200; - //plight.Bright = 0.7f; - //Oyster::Graphics::API::AddLight(plight); - //plight.Pos = Float3(10,350,350); - //plight.Color = Float3(0.9f,0.7f,0.3f); - //plight.Radius = 200; - //plight.Bright = 0.7f; - //Oyster::Graphics::API::AddLight(plight); - //plight.Pos = Float3(10,-15,5); - //plight.Color = Float3(0,0,1); - //plight.Radius = 50; - //plight.Bright = 0.5f; - //Oyster::Graphics::API::AddLight(plight); // use level loader LoadModels("../Content/Worlds/ccc.bias"); @@ -143,7 +128,7 @@ bool GameState::LoadModels() this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); // add jumppad - modelData.position = Oyster::Math::Float3(4, 600.3, 0); + modelData.position = Oyster::Math::Float3(4, 600.3f, 0); modelData.modelPath = L"jumppad_round.dan"; modelData.id = id++; // load models @@ -244,24 +229,51 @@ bool GameState::LoadModels(std::string mapFile) break; } } - //myId += modelId++; - // add player model - //modelData.position = ; - //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1); - //modelData.scale = Oyster::Math::Float3(2,2,2); + + Oyster::Math::Quaternion first = Oyster::Math::Quaternion(Float3(0.3536,0.3536,-0.146), 0.8536); + Oyster::Math::Quaternion second = Oyster::Math::Quaternion(Float3(0.3536,0.3536,-0.146), 0.8536); + Oyster::Math::Quaternion result = first * second; + Oyster::Math::Quaternion total = Oyster::Math::Quaternion(Float3(0.5,0.5,-0.5), 0.5); + modelData.visible = true; + modelData.position = Oyster::Math::Float3(20, 127,0); + modelData.rotation = first; + modelData.scale = Oyster::Math::Float3(1,1,1); + modelData.modelPath = L"char_still_sizeref.dan"; + modelData.id = myId; + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - //modelData.visible = true; - //modelData.modelPath = L"char_still_sizeref.dan"; - //modelData.id = myId; - //// load models - //this->dynamicObjects.Push(new C_DynamicObj()); - //this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); + modelData.visible = true; + modelData.position = Oyster::Math::Float3(22, 127,0); + modelData.rotation = second; + modelData.scale = Oyster::Math::Float3(1,1,1); + modelData.modelPath = L"char_still_sizeref.dan"; + modelData.id = myId; + + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); + + modelData.visible = true; + modelData.position = Oyster::Math::Float3(24, 127,0); + modelData.rotation = result; + modelData.scale = Oyster::Math::Float3(1,1,1); + modelData.modelPath = L"char_still_sizeref.dan"; + modelData.id = myId; + + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); + + modelData.visible = true; + modelData.position = Oyster::Math::Float3(26, 127,0); + modelData.rotation = total; + modelData.scale = Oyster::Math::Float3(1,1,1); + modelData.modelPath = L"char_still_sizeref.dan"; + modelData.id = myId; + + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - /*C_Player* obj = new C_Player(); - privData->object.push_back(obj); - privData->object[privData->object.size() -1 ]->Init(modelData); - */ return true; } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 86560164..3102b9f2 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -61,7 +61,7 @@ void AttatchmentMassDriver::Update(float dt) Oyster::Math::Float3 ownerPos = owner->GetPosition(); Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState(); Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2]; - up *= -0.3; + up *= -0.3f; Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5); //state.centerPos = pos; diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index acdcd2f3..914dd52b 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -11,9 +11,9 @@ Game::PlayerData::PlayerData() Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f); Oyster::Math::Float mass = 60; - Oyster::Math::Float restitutionCoeff = 0.5; - Oyster::Math::Float frictionCoeff_Static = 0.4; - Oyster::Math::Float frictionCoeff_Dynamic = 0.3; + Oyster::Math::Float restitutionCoeff = 0.5f; + Oyster::Math::Float frictionCoeff_Static = 0.4f; + Oyster::Math::Float frictionCoeff_Dynamic = 0.3f; //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body @@ -28,6 +28,7 @@ Game::PlayerData::PlayerData() Game::PlayerData::PlayerData(int playerID,int teamID) { this->player = new Player(); + } Game::PlayerData::~PlayerData() { diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 9a91744e..50b8ba9e 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -137,6 +137,7 @@ ICustomBody* Level::InitRigidBodyCube( const ObjectHeader* obj) //offset the rigidPosition from modelspace to worldspace; rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.box.position; + //scales the position so the collision geomentry is in the right place rigidWorldPos = rigidWorldPos * obj->scale; @@ -182,7 +183,7 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj) rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.sphere.mass; //Radius scaled - //rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; + //rigidBodyRadius = (staticObjData->scale[0] + staticObjData->scale[1] + staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; //create the rigid body @@ -230,7 +231,7 @@ void Level::InitiateLevel(std::string levelPath) else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box) { - rigidBody_Static = InitRigidBodySphere(staticObjData); + rigidBody_Static = InitRigidBodyCube(staticObjData); } else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder) @@ -241,7 +242,8 @@ void Level::InitiateLevel(std::string levelPath) if(rigidBody_Static != NULL) { // create game object - Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static); + //Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static); + Object* staticGameObj = new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID); if(staticGameObj != NULL) { this->staticObjects.Push((StaticObject*)staticGameObj); @@ -278,7 +280,8 @@ void Level::InitiateLevel(std::string levelPath) if(rigidBody_Dynamic != NULL) { // create game object - Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic); + //Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic); + Object* dynamicGameObj =new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID); if (dynamicGameObj != NULL) { this->dynamicObjects.Push((DynamicObject*)dynamicGameObj); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index f6dddb85..12a655da 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 = 30; +const float MOVE_FORCE = 30; const float KEY_TIMER = 0.03f; Player::Player() :DynamicObject() @@ -162,8 +162,7 @@ void Player::UseWeapon(const WEAPON_FIRE &usage) } void Player::Respawn(Oyster::Math::Float3 spawnPoint) -{ - key_jump = +{ this->life = 100; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float4(1,0,0); @@ -184,7 +183,7 @@ void Player::Jump() { Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); this->rigidBody->ApplyImpulse(up *1500); - this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING; + this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; } bool Player::IsWalking()