From ef71b365ab10abe6260a6197a1ce93add3839de3 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Mon, 3 Feb 2014 10:42:40 +0100 Subject: [PATCH 1/7] asd --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 3 +++ Code/Game/GameLogic/GameLogic.vcxproj.user | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 6 ++++++ Code/Game/GameLogic/Level.cpp | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index a63b6e1d..bca972fd 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -46,7 +46,10 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) { +<<<<<<< HEAD +======= +>>>>>>> GL - mergeissues Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); diff --git a/Code/Game/GameLogic/GameLogic.vcxproj.user b/Code/Game/GameLogic/GameLogic.vcxproj.user index 2e28d6f7..4b847ee6 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj.user +++ b/Code/Game/GameLogic/GameLogic.vcxproj.user @@ -1,7 +1,7 @@  - true + false $(OutDir) diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index e19af2f3..1626f5b3 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -9,8 +9,14 @@ Game::PlayerData::PlayerData() Oyster::Physics::API::SimpleBodyDescription sbDesc; sbDesc.centerPosition = Oyster::Math::Float3(0,308,0); sbDesc.size = Oyster::Math::Float3(4,7,4); +<<<<<<< HEAD sbDesc.mass = 70; sbDesc.restitutionCoeff = 0.5; +======= + + sbDesc.mass = 90; + +>>>>>>> GL - mergeissues //create rigid body Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 50737eb9..0a1a37e6 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -43,8 +43,15 @@ void Level::InitiateLevel(float radius) API::SimpleBodyDescription sbDesc_TestBox; sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0); sbDesc_TestBox.ignoreGravity = false; +<<<<<<< HEAD sbDesc_TestBox.mass = 50; sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0); +======= + + sbDesc_TestBox.mass = 10; + sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0); + +>>>>>>> GL - mergeissues ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release(); rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel); From 8f234611d2c9691506876132ba1f6119937d4d20 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Mon, 3 Feb 2014 10:48:12 +0100 Subject: [PATCH 2/7] GL - mergeissues fixed --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 4 ---- Code/Game/GameLogic/Game_PlayerData.cpp | 5 ----- Code/Game/GameLogic/Level.cpp | 7 +------ 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index bca972fd..5f5834bb 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -46,10 +46,6 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) { -<<<<<<< HEAD - -======= ->>>>>>> GL - mergeissues Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 1626f5b3..18bb10a7 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -9,14 +9,9 @@ Game::PlayerData::PlayerData() Oyster::Physics::API::SimpleBodyDescription sbDesc; sbDesc.centerPosition = Oyster::Math::Float3(0,308,0); sbDesc.size = Oyster::Math::Float3(4,7,4); -<<<<<<< HEAD sbDesc.mass = 70; sbDesc.restitutionCoeff = 0.5; -======= - sbDesc.mass = 90; - ->>>>>>> GL - mergeissues //create rigid body Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 0a1a37e6..b070eb56 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -43,15 +43,10 @@ void Level::InitiateLevel(float radius) API::SimpleBodyDescription sbDesc_TestBox; sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10,320,0,0); sbDesc_TestBox.ignoreGravity = false; -<<<<<<< HEAD + sbDesc_TestBox.mass = 50; sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0); -======= - sbDesc_TestBox.mass = 10; - sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0); - ->>>>>>> GL - mergeissues ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release(); rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel); From e7fee8b2e7161d2768e914d398a424da151edb6a Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Mon, 3 Feb 2014 14:50:15 +0100 Subject: [PATCH 3/7] GL - Updated LevelLoader. Added lights. Added lights. Changed the return type to vector> Hid the LevelParser from the outside. --- Bin/Level.txt | Bin 156 -> 0 bytes Bin/map | Bin 156 -> 0 bytes Bin/map.txt | Bin 60 -> 0 bytes .../GameLogic/LevelLoader/LevelLoader.cpp | 22 ++++- Code/Game/GameLogic/LevelLoader/LevelLoader.h | 44 +++++----- .../GameLogic/LevelLoader/LevelParser.cpp | 81 +++++++++++++----- Code/Game/GameLogic/LevelLoader/LevelParser.h | 3 +- .../GameLogic/LevelLoader/ObjectDefines.h | 47 +++++++++- .../GameLogic/LevelLoader/ParseFunctions.h | 10 ++- 9 files changed, 156 insertions(+), 51 deletions(-) delete mode 100644 Bin/Level.txt delete mode 100644 Bin/map delete mode 100644 Bin/map.txt diff --git a/Bin/Level.txt b/Bin/Level.txt deleted file mode 100644 index d86dd3db4f89e0c84adfa01d7b0ec5a42dd61adb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 156 zcmZQzU|?VYV!y=PR7M~T0wBIiYH>0$&A`y$pam3X0x19jkXjHMgqeXjYRNaJ8F^XG hjYrow<6?ux*}DpzTmbMiDYF0o diff --git a/Bin/map b/Bin/map deleted file mode 100644 index a578cc3216cf4c730d47a3cae791ddccf2b29610..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 156 zcmZQ#U|?VZVrC$YTJp_lMqZY47AJ$m6N^*QIDs?+LxY1BkYob085kIWGyuTm1-1YH diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp index d60aac66..5bb916ab 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp @@ -3,16 +3,30 @@ ////////////////////////////////// #include "LevelLoader.h" +#include "LevelParser.h" using namespace GameLogic; using namespace GameLogic::LevelFileLoader; - -std::vector LevelLoader::LoadLevel(std::string fileName) +struct LevelLoader::PrivData { - return parser.Parse(fileName); + LevelParser parser; +}; + +LevelLoader::LevelLoader() + : pData(new PrivData) +{ +} + +LevelLoader::~LevelLoader() +{ +} + +std::vector> LevelLoader::LoadLevel(std::string fileName) +{ + return pData->parser.Parse(fileName); } LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName) { - return parser.ParseHeader(fileName); + return pData->parser.ParseHeader(fileName); } \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.h b/Code/Game/GameLogic/LevelLoader/LevelLoader.h index 4ac7a950..bcd6e587 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.h +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.h @@ -7,36 +7,36 @@ #include #include -#include +#include "../Misc/Utilities.h" #include "ObjectDefines.h" -#include "LevelParser.h" namespace GameLogic { - class LevelLoader - { + class LevelLoader + { - public: - LevelLoader(){this->parser = GameLogic::LevelFileLoader::LevelParser(); } - ~LevelLoader(){} + public: + LevelLoader(); + ~LevelLoader(); - /******************************************************** - * Loads the level and objects from file. - * @param fileName: Path to the level-file that you want to load. - * @return: Returns all structs with objects and information about the level. - ********************************************************/ - std::vector LoadLevel(std::string fileName); + /******************************************************** + * Loads the level and objects from file. + * @param fileName: Path to the level-file that you want to load. + * @return: Returns all structs with objects and information about the level. + ********************************************************/ + std::vector> LoadLevel(std::string fileName); - /******************************************************** - * Just for fast access for the meta information about the level. - * @param fileName: Path to the level-file that you want to load. - * @return: Returns the meta information about the level. - ********************************************************/ - LevelMetaData LoadLevelHeader(std::string fileName); //. + /******************************************************** + * Just for fast access for the meta information about the level. + * @param fileName: Path to the level-file that you want to load. + * @return: Returns the meta information about the level. + ********************************************************/ + LevelMetaData LoadLevelHeader(std::string fileName); //. - private: - GameLogic::LevelFileLoader::LevelParser parser; - }; + private: + struct PrivData; + Utility::DynamicMemory::SmartPointer pData; + }; } #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index 3ab3c203..3a20f192 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -5,6 +5,7 @@ using namespace GameLogic; using namespace ::LevelFileLoader; +using namespace Utility::DynamicMemory; LevelParser::LevelParser() { @@ -16,12 +17,12 @@ LevelParser::~LevelParser() { } -std::vector LevelParser::Parse(std::string filename) +std::vector> LevelParser::Parse(std::string filename) { int bufferSize = 0; int counter = 0; - std::vector objects; + std::vector> objects; //Read entire level file. Loader loader; @@ -42,26 +43,66 @@ std::vector LevelParser::Parse(std::string filename) ParseObject(&buffer[counter], &typeID, sizeof(typeID)); switch((int)typeID.typeID) { - case ObjectType_LevelMetaData: - { - LevelMetaData header; - ParseLevelMetaData(&buffer[counter], header, counter); - objects.push_back(header); - break; - } + case ObjectType_LevelMetaData: + { + LevelMetaData* header = new LevelMetaData; + ParseLevelMetaData(&buffer[counter], *header, counter); + objects.push_back(header); + break; + } - case ObjectType_Dynamic: - { - ObjectHeader header; - ParseObject(&buffer[counter], &header, sizeof(header)); - objects.push_back(header); - counter += sizeof(header); - break; - } + //This is by design, static and dynamic is using the same converter. Do not add anything inbetween them. + case ObjectType_Static: case ObjectType_Dynamic: + { + ObjectHeader* header = new ObjectHeader; + ParseObject(&buffer[counter], header, sizeof(*header)); + objects.push_back(header); + counter += sizeof(*header); + break; + } - default: - //Couldn't find typeID. FAIL!!!!!! - break; + case ObjectType_Light: + { + LightType lightType; + + //Get Light type + ParseObject(&buffer[counter+4], &lightType, sizeof(lightType)); + + switch(lightType) + { + case LightType_PointLight: + { + PointLight* header = new PointLight; + ParseObject(&buffer[counter], header, sizeof(*header)); + counter += sizeof(*header); + objects.push_back(header); + break; + } + case LightType_DirectionalLight: + { + DirectionalLight* header = new DirectionalLight; + ParseObject(&buffer[counter], header, sizeof(*header)); + counter += sizeof(*header); + objects.push_back(header); + break; + } + case LightType_SpotLight: + { + SpotLight* header = new SpotLight; + ParseObject(&buffer[counter], header, sizeof(*header)); + counter += sizeof(*header); + objects.push_back(header); + break; + } + default: + //Undefined LightType. + break; + } + break; + } + default: + //Couldn't find typeID. FAIL!!!!!! + break; } } diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.h b/Code/Game/GameLogic/LevelLoader/LevelParser.h index 6dce25f8..9ad30642 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.h +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.h @@ -4,6 +4,7 @@ #include #include #include "ObjectDefines.h" +#include "../Misc/Utilities.h" namespace GameLogic { @@ -16,7 +17,7 @@ namespace GameLogic ~LevelParser(); // - std::vector Parse(std::string filename); + std::vector> Parse(std::string filename); // LevelMetaData ParseHeader(std::string filename); diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index dcf960a5..21e3a7e3 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -15,11 +15,12 @@ namespace GameLogic ObjectType_LevelMetaData, ObjectType_Static, ObjectType_Dynamic, + ObjectType_Light, //Etc ObjectType_NUM_OF_TYPES, - ObjectType_Unknown = -1, + ObjectType_Unknown = -1 }; enum UsePhysics @@ -29,7 +30,17 @@ namespace GameLogic UsePhysics_IgnorePhysics, UsePhysics_Count, - UsePhysics_Unknown = -1, + UsePhysics_Unknown = -1 + }; + + enum LightType + { + LightType_PointLight, + LightType_DirectionalLight, + LightType_SpotLight, + + LightType_Count, + LightType_Unknown = -1 }; //Should this be moved somewhere else? @@ -40,7 +51,7 @@ namespace GameLogic //Etc GameMode_Count, - GameMode_Unknown = -1, + GameMode_Unknown = -1 }; @@ -104,6 +115,36 @@ namespace GameLogic //Scale float scale[3]; }; + + + /************************************ + Lights + *************************************/ + + struct BasicLight : public ObjectTypeHeader + { + LightType lightType; + float ambientColor[3]; + float diffuseColor[3]; + float specularColor[3]; + }; + + struct PointLight : public BasicLight + { + float position[3]; + }; + + struct DirectionalLight : public BasicLight + { + float direction[3]; + }; + + struct SpotLight : public BasicLight + { + float direction[3]; + float range; + float attenuation[3]; + }; } #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.h b/Code/Game/GameLogic/LevelLoader/ParseFunctions.h index 08962b4a..554b95db 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.h +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.h @@ -10,8 +10,16 @@ namespace GameLogic { namespace LevelFileLoader { + /* + These functions will copy data from where the buffer pointer points. + header is the destination where the data will be copied. + size is either the size of the data to be copied (if it is NOT sent by reference). + Or the current index that is being used to parse the entire file (if it is sent by reference) this means you have to increase size with the appropiate size after you have copied. + + */ + void ParseObject(char* buffer, void *header, int size); - void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size); + void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size); } } From dc5b4081962654e9f1d473eb62761f795258d309 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Mon, 3 Feb 2014 15:32:20 +0100 Subject: [PATCH 4/7] Network - Updated network api with comment. --- Code/Network/NetworkAPI/NetworkServer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Network/NetworkAPI/NetworkServer.h b/Code/Network/NetworkAPI/NetworkServer.h index 97a3e024..1a6af478 100644 --- a/Code/Network/NetworkAPI/NetworkServer.h +++ b/Code/Network/NetworkAPI/NetworkServer.h @@ -84,8 +84,8 @@ namespace Oyster */ std::string GetLanAddress(); - /** - * + /** Returns the port the server is listening on. + * @return Returns the port the server has been initiated with. */ int NetworkServer::GetPort(); From 99b041f1650009ebe1fed77706313db717a9c6b3 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Mon, 3 Feb 2014 15:32:46 +0100 Subject: [PATCH 5/7] GL - first implementation of weapons forcepull with pickup functionallity --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 72 ++++++++++++++++++- Code/Game/GameLogic/AttatchmentMassDriver.h | 21 ++++-- Code/Game/GameLogic/CollisionManager.cpp | 37 ++++++++++ Code/Game/GameLogic/CollisionManager.h | 1 + Code/Game/GameLogic/IAttatchment.h | 1 + Code/Game/GameLogic/Object.h | 4 +- Code/Game/GameLogic/Player.cpp | 12 ++++ Code/Game/GameLogic/Player.h | 3 + Code/Game/GameLogic/StaticObject.cpp | 4 +- Code/Game/GameLogic/Weapon.cpp | 5 ++ Code/Game/GameLogic/Weapon.h | 1 + 11 files changed, 152 insertions(+), 9 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 5f5834bb..837393db 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -9,12 +9,16 @@ using namespace GameLogic; AttatchmentMassDriver::AttatchmentMassDriver(void) { this->owner = 0; + this->heldObject = NULL; + this->hasObject = false; } AttatchmentMassDriver::AttatchmentMassDriver(Player &owner) { this->owner = &owner; + this->heldObject = NULL; + this->hasObject = false; } @@ -37,16 +41,51 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: ForcePull(usage,dt); break; + case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: + ForceZip(usage,dt); + break; } } +void AttatchmentMassDriver::Update(float dt) +{ + + //update position of heldObject if there is an object being held + if(hasObject) + { + Oyster::Physics::ICustomBody::State state; + state = heldObject->GetState(); + + Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized(); + + state.SetCenterPosition(pos); + + heldObject->SetState(state); + } +} + /******************************************************** * Pushes objects in a cone in front of the weapon when fired +*alternativly it puts a large force on the currently held object ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) { - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); + //if the weapon has an object then it is only the object that will be shot away + Oyster::Math::Float4 pushForce; + + if(hasObject) + { + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (800 * dt); + Oyster::Physics::ICustomBody::State state = heldObject->GetState(); + state.ApplyLinearImpulse((Oyster::Math::Float3)pushForce); + heldObject->SetState(state); + hasObject = false; + heldObject = NULL; + return; + } + + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); @@ -60,7 +99,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float /******************************************************** * Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack) ********************************************************/ -void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) +void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt) { Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState(); @@ -71,3 +110,32 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) } +void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) +{ + if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function + + PickUpObject(usage,dt); //first test if there is a nearby object to pickup + + if(hasObject) return; //this test checks if the weapon has now picked up an object, if so then it shall not apply a force to suck in objects + + + //if no object has been picked up then suck objects towards you + Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100 * dt); + Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); + + Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); + Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + forcePushData args; + args.pushForce = -pushForce; + + Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); +} + +void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) +{ + Oyster::Math::Float4 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized(); + Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,1); + + Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); + +} diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h index 594ea4fd..51368e91 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.h +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -16,29 +16,42 @@ namespace GameLogic void UseAttatchment(const WEAPON_FIRE &usage, float dt); + void Update(float dt); private: /******************************************************** * Pushes objects and players in a cone in front of the player - * @param fireInput: allows switching on different functionality in this specific function + * @param usage: allows switching on different functionality in this specific function ********************************************************/ void ForcePush(const WEAPON_FIRE &usage, float dt); /******************************************************** * Pulls the player forward, this is a movement tool - * @param fireInput: allows switching on different functionality in this specific function + * @param usage: allows switching on different functionality in this specific function + ********************************************************/ + void ForceZip(const WEAPON_FIRE &usage, float dt); + + /******************************************************** + * Sucks objects towards the player, the player can then pick up an object and throw it as a projectile + * @param usage: allows switching on different functionality in this specific function ********************************************************/ void ForcePull(const WEAPON_FIRE &usage, float dt); /******************************************************** * Sucks objects towards the player, the player can then pick up an object and throw it as a projectile - * @param fireInput: allows switching on different functionality in this specific function + * @param usage: allows switching on different functionality in this specific function ********************************************************/ - void ForceSuck(const WEAPON_FIRE &usage, float dt); + void PickUpObject(const WEAPON_FIRE &usage, float dt); + static void ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args); + static void AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args); + + private: + Oyster::Physics::ICustomBody *heldObject; + bool hasObject; }; } diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 019df6f4..afb94035 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -5,6 +5,7 @@ #include "Level.h" #include "AttatchmentMassDriver.h" #include "Game.h" +#include "CollisionManager.h" using namespace Oyster; @@ -77,6 +78,13 @@ using namespace GameLogic; { return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; } + + Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj) + { + return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; + } + + Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; @@ -93,4 +101,33 @@ using namespace GameLogic; state = obj->GetState(); state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce); obj->SetState(state); + } + + void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) + { + AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); + + if(weapon->hasObject) + { + //do nothing + } + else + { + Object* realObj = (Object*)(obj->GetCustomTag()); + //check so that it is an object that you can pickup + + switch(realObj->GetObjectType()) + { + case OBJECT_TYPE::OBJECT_TYPE_BOX: + obj->SetGravity(true); //will now ignore gravity, dont mind the naming + //move obj to limbo in physics to make sure it wont collide with anything + weapon->heldObject = obj; //weapon now holds the object + weapon->hasObject = true; + + break; + } + + } + + } \ No newline at end of file diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h index 6179333f..d3be9809 100644 --- a/Code/Game/GameLogic/CollisionManager.h +++ b/Code/Game/GameLogic/CollisionManager.h @@ -11,6 +11,7 @@ namespace GameLogic { public: //put general collision functions here that are not part of a specific object + static Oyster::Physics::ICustomBody::SubscriptMessage IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj); }; diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h index e458fdbf..9984303a 100644 --- a/Code/Game/GameLogic/IAttatchment.h +++ b/Code/Game/GameLogic/IAttatchment.h @@ -20,6 +20,7 @@ namespace GameLogic ~IAttatchment(void); virtual void UseAttatchment(const WEAPON_FIRE &usage, float dt) = 0; + virtual void Update(float dt) = 0; private: diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index d3a3690f..96d97591 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -35,8 +35,8 @@ namespace GameLogic Oyster::Physics::ICustomBody* GetRigidBody(); void ApplyLinearImpulse(Oyster::Math::Float3 force); - void BeginFrame(); - void EndFrame(); + virtual void BeginFrame(); + virtual void EndFrame(); void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)); void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index ea36b284..73ddb9fc 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -58,6 +58,18 @@ Player::~Player(void) } } +void Player::BeginFrame() +{ + weapon->Update(0.002f); + Object::BeginFrame(); +} + +void Player::EndFrame() +{ + + Object::EndFrame(); +} + void Player::Move(const PLAYER_MOVEMENT &movement) { switch(movement) diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 0df0d040..f44f98d1 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -71,6 +71,9 @@ namespace GameLogic void DamageLife(int damage); + void BeginFrame(); + void EndFrame(); + private: void Jump(); diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 21b339be..c007b919 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -1,4 +1,5 @@ #include "StaticObject.h" +#include "CollisionManager.h" using namespace GameLogic; @@ -17,7 +18,8 @@ StaticObject::StaticObject(OBJECT_TYPE type) StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) :Object(rigidBody,type) { - + this->rigidBody->SetGravity(true); + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision)); } StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index a4c87e9e..19b53a31 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -125,4 +125,9 @@ void Weapon::SelectAttatchment(int socketID) selectedSocketID = socketID; } +} + +void Weapon::Update(float dt) +{ + selectedAttatchment->Update(dt); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index 5138b2ac..8f226f12 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -20,6 +20,7 @@ namespace GameLogic ~Weapon(void); void Use(const WEAPON_FIRE &usage, float dt); + void Update(float dt); void AddNewAttatchment(IAttatchment *attatchment, Player *owner); void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner); From d77b3d92d8195447737ecad503554b3a5a5802aa Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Mon, 3 Feb 2014 15:45:48 +0100 Subject: [PATCH 6/7] GL - using movetolimbo in massdriver pickup functionallity --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 1 + Code/Game/GameLogic/CollisionManager.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 837393db..d5de9baa 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -80,6 +80,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float Oyster::Physics::ICustomBody::State state = heldObject->GetState(); state.ApplyLinearImpulse((Oyster::Math::Float3)pushForce); heldObject->SetState(state); + Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject); hasObject = false; heldObject = NULL; return; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index afb94035..d1e9a324 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -119,8 +119,8 @@ using namespace GameLogic; switch(realObj->GetObjectType()) { case OBJECT_TYPE::OBJECT_TYPE_BOX: - obj->SetGravity(true); //will now ignore gravity, dont mind the naming //move obj to limbo in physics to make sure it wont collide with anything + Oyster::Physics::API::Instance().MoveToLimbo(obj); weapon->heldObject = obj; //weapon now holds the object weapon->hasObject = true; From 7f29b62c6fd4214ecfd07ebb5ef6e693cce22ca7 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Mon, 3 Feb 2014 16:19:24 +0100 Subject: [PATCH 7/7] GL - YOU CAN NOW SHOOT STUFF YAAAAY --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 27 ++++++++++++++----- .../Implementation/GameSession_Gameplay.cpp | 4 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index d5de9baa..babb4916 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -39,6 +39,12 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, ForcePush(usage,dt); break; case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: + + if(hasObject) + { + ForcePush(usage,dt);//WARNING THIS IS A CRAP TEST TO MAKE SURE YOU CAN SHOOT BOXES + break; + } ForcePull(usage,dt); break; case WEAPON_FIRE::WEAPON_USE_UTILLITY_PRESS: @@ -56,8 +62,9 @@ void AttatchmentMassDriver::Update(float dt) { Oyster::Physics::ICustomBody::State state; state = heldObject->GetState(); - - Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized(); + Oyster::Math::Float3 ownerPos = owner->GetPosition(); + ownerPos.y += 2; + Oyster::Math::Float3 pos = ownerPos + owner->GetLookDir().GetNormalized()*2; state.SetCenterPosition(pos); @@ -76,11 +83,12 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float if(hasObject) { - pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (800 * dt); + Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject); + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (2000); Oyster::Physics::ICustomBody::State state = heldObject->GetState(); state.ApplyLinearImpulse((Oyster::Math::Float3)pushForce); heldObject->SetState(state); - Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject); + hasObject = false; heldObject = NULL; return; @@ -134,9 +142,14 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) { - Oyster::Math::Float4 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized(); - Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,1); + //Oyster::Math::Float4 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized(); + //Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,2000); + Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); - Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); + Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); + Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + + + Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,this,AttemptPickUp); } diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 8235c903..2b87e9cc 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -184,7 +184,9 @@ namespace DanBias } void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) { - c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + //c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); + //c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); } void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c ) {