From 3a80a711439acd736fb893f78921ae5eb8a15d73 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 12 Feb 2014 11:32:30 +0100 Subject: [PATCH] GL - working on weapon --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 16 ++++++++-------- Code/Game/GameLogic/CollisionManager.cpp | 9 +++++---- Code/OysterPhysics3D/Cone.cpp | 9 +++++++-- Code/OysterPhysics3D/Cone.h | 9 +++++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 2b66bcde..bd52029d 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -95,22 +95,22 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float heldObject = NULL; return; } - Oyster::Math::Float3 up = owner->GetOrientation().v[1]; - Oyster::Math::Float3 look = owner->GetLookDir(); - Oyster::Math::Float3 pos = owner->GetPosition(); + + Oyster::Math::Float radius = 2; + Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); + Oyster::Math::Float lenght = 5; + Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (200 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(look, up, pos); - Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/8,1,1,50); - Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(look*5,pos,radius); + - Oyster::Collision3D::Cone *hitCone; forcePushData args; args.pushForce = pushForce; - //Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); } /******************************************************** diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 9c6f6aca..9f71f249 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -123,19 +123,20 @@ using namespace GameLogic; void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) { - Oyster::Physics::ICustomBody::State state; + if(obj->GetState().mass == 0) return; + Object *realObj = (Object*)obj->GetCustomTag(); if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD) return; - state = obj->GetState(); - //state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce); - obj->SetState(state); + obj->ApplyImpulse(((forcePushData*)(args))->pushForce); } void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) { + if(obj->GetState().mass == 0) return; + AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); if(weapon->hasObject) diff --git a/Code/OysterPhysics3D/Cone.cpp b/Code/OysterPhysics3D/Cone.cpp index a336f820..61d7faf3 100644 --- a/Code/OysterPhysics3D/Cone.cpp +++ b/Code/OysterPhysics3D/Cone.cpp @@ -15,14 +15,14 @@ Cone::Cone( ) : ICollideable(Type_cone) this->height = Oyster::Math::Float3(0,0,0); } -Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) +Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { this->radius = radius; this->height = height; this->position = position; } -Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) +Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { this->radius = radius; this->height = (Oyster::Math::Float3)height; @@ -42,3 +42,8 @@ Cone & Cone::operator = ( const Cone &cone ) return *this; } +::Utility::DynamicMemory::UniquePointer Cone::Clone( ) const +{ + return ::Utility::DynamicMemory::UniquePointer( new Cone(*this) ); +} + diff --git a/Code/OysterPhysics3D/Cone.h b/Code/OysterPhysics3D/Cone.h index 0c12201a..3bae3df3 100644 --- a/Code/OysterPhysics3D/Cone.h +++ b/Code/OysterPhysics3D/Cone.h @@ -25,6 +25,15 @@ namespace Oyster Cone & operator = ( const Cone &Cone ); + virtual ::Utility::DynamicMemory::UniquePointer Clone( ) const; + + bool Intersects( const ICollideable &target ) const{return false;}; + bool Intersects( const ICollideable &target, ::Oyster::Math::Float4 &worldPointOfContact ) const{return false;}; + bool Contains( const ICollideable &target ) const{return false;}; + + ::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const{return 0;}; + + Oyster::Math::Float3 height; Oyster::Math::Float3 position; Oyster::Math::Float radius;