diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp
index 6d3de52c..9ba44ede 100644
--- a/Code/Game/GameLogic/Level.cpp
+++ b/Code/Game/GameLogic/Level.cpp
@@ -385,7 +385,7 @@ void Level::InitiateLevel(float radius)
//this->staticObjects[0]->objectID = idCount++;
// add jumppad
- ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
+ ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 0, 0.5f, 0.8f, 0.6f);
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp
index ad238d26..0fb93995 100644
--- a/Code/Game/GameLogic/Player.cpp
+++ b/Code/Game/GameLogic/Player.cpp
@@ -53,11 +53,15 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
this->teamID = teamID;
this->playerState = PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float3(0,0,-1);
- this->moveDir = Oyster::Math::Float3(0,0,0);
key_forward = 0;
key_backward = 0;
key_strafeRight = 0;
key_strafeLeft = 0;
+
+ this->moveDir = Oyster::Math::Float3(0,0,0);
+ this->moveSpeed = 100;
+ this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
+
}
Player::~Player(void)
@@ -73,48 +77,60 @@ void Player::BeginFrame()
{
//weapon->Update(0.002f);
Object::BeginFrame();
- Oyster::Math::Float3 forward(0,0,0);
- Oyster::Math::Float3 back(0,0,0);
- Oyster::Math::Float3 right(0,0,0);
- Oyster::Math::Float3 left(0,0,0);
- Oyster::Math::Float3 moveDirection(0,0,0);
+
+ if(this->moveDir != Oyster::Math::Float3::null)
+ {
+ Oyster::Math::Float3 velocity = this->rigidBody->GetLinearVelocity();
+ Oyster::Math::Float3 lostVelocity = (this->previousMoveSpeed - velocity).GetMagnitude()*this->moveDir;
+ this->rigidBody->SetLinearVelocity(velocity + lostVelocity - this->moveDir*this->moveSpeed );
+ }
+
+ this->moveDir = Oyster::Math::Float3::null;
+
if (key_forward > 0.001)
{
key_forward -= gameInstance->GetFrameTime(); // fixed timer
- forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
+ this->moveDir += this->rigidBody->GetState().GetOrientation().v[2].GetNormalized().xyz;
}
if (key_backward > 0.001)
{
key_backward -= gameInstance->GetFrameTime();
- back = -this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
+ this->moveDir -= this->rigidBody->GetState().GetOrientation().v[2].GetNormalized().xyz;
}
if (key_strafeRight > 0.001)
{
-
key_strafeRight -= gameInstance->GetFrameTime();
- Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
- Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize();
- right = -((up).Cross(forward).Normalize());
- right.Normalize();
+ Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
+ Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos;
+ this->moveDir -= (up).Cross(forward).GetNormalized();
}
if (key_strafeLeft > 0.001)
{
key_strafeLeft -= gameInstance->GetFrameTime();
- Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
- Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize();
- left = (up).Cross(forward).Normalize();
- left.Normalize();
+ Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
+ Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos;
+ this->moveDir += (up).Cross(forward).GetNormalized();
}
- moveDirection = forward + back + left + right;
- //moveDirection.Normalize();
- rigidBody->SetLinearVelocity( MOVE_FORCE * moveDirection );
- weapon->Update(0.01f);
+ if(this->moveDir != Oyster::Math::Float3::null)
+ {
+ this->moveDir.Normalize();
+ this->rigidBody->SetLinearVelocity(this->moveDir*this->moveSpeed + this->rigidBody->GetLinearVelocity());
+ this->previousMoveSpeed = this->rigidBody->GetLinearVelocity();
+ }
+
+
+ this->weapon->Update(0.01f);
}
void Player::EndFrame()
{
// snap to axis
+ Oyster::Math::Float4 rotation;
+
+ this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
+
+
Object::EndFrame();
}
@@ -181,7 +197,6 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
this->rigidBody->SetUpAndRight(up, right);
- this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized());
}
void Player::Jump()
@@ -237,4 +252,3 @@ void Player::DamageLife(int damage)
this->gameInstance->onDisableFnc(this, 0.0f);
}
}
-
diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h
index 17ad2095..b4929dfb 100644
--- a/Code/Game/GameLogic/Player.h
+++ b/Code/Game/GameLogic/Player.h
@@ -73,7 +73,6 @@ namespace GameLogic
void EndFrame();
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
-
private:
void Jump();
@@ -82,7 +81,6 @@ namespace GameLogic
int teamID;
Weapon *weapon;
PLAYER_STATE playerState;
- Oyster::Math::Float3 moveDir;
Oyster::Math::Float3 lookDir;
float key_forward;
float key_backward;
@@ -90,9 +88,14 @@ namespace GameLogic
float key_strafeLeft;
float key_jump;
+
+ Oyster::Math::Float3 moveDir;
+ Oyster::Math::Float moveSpeed;
+ Oyster::Math::Float3 previousMoveSpeed;
+
+
bool hasTakenDamage;
float invincibleCooldown;
-
};
}
#endif
\ No newline at end of file
diff --git a/Code/GamePhysics/GamePhysics.vcxproj b/Code/GamePhysics/GamePhysics.vcxproj
index 9b883bb3..475a05f9 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj
+++ b/Code/GamePhysics/GamePhysics.vcxproj
@@ -165,22 +165,16 @@
-
-
-
-
-
-
diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters
index aa3cbd73..5a3c6fb2 100644
--- a/Code/GamePhysics/GamePhysics.vcxproj.filters
+++ b/Code/GamePhysics/GamePhysics.vcxproj.filters
@@ -30,24 +30,12 @@
Header Files\Implementation
-
- Header Files\Implementation
-
-
- Header Files\Implementation
-
Header Files\Include
Header Files\Include
-
- Header Files\Include
-
-
- Header Files\Include
-
@@ -59,11 +47,5 @@
Source Files
-
- Source Files
-
-
- Source Files
-
\ No newline at end of file
diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp
deleted file mode 100644
index 4778e5f1..00000000
--- a/Code/GamePhysics/Implementation/Octree.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-#include "Octree.h"
-
-using namespace Oyster;
-using namespace Physics;
-using namespace ::Utility::DynamicMemory;
-
-const unsigned int Octree::invalid_ref = ::Utility::Value::numeric_limits::max();
-
-Octree::Octree(unsigned int bufferSize, unsigned char numLayers, Math::Float3 worldSize)
-{
- this->worldNode.dataPtr = NULL;
-
- this->worldNode.container.maxVertex = worldSize*0.5f;
- this->worldNode.container.minVertex = -worldSize*0.5f;
-}
-
-Octree::~Octree()
-{
-
-}
-
-Octree& Octree::operator=(const Octree& orig)
-{
- this->leafData = orig.leafData;
- this->updateQueue = orig.updateQueue;
- this->worldNode = orig.worldNode;
- this->mapReferences = orig.mapReferences;
-
- return *this;
-}
-
-void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef)
-{
- //customBodyRef->SetScene( this );
- Data data;
- //Data* tempPtr = this->worldNode.dataPtr;
-
- //data.container = customBodyRef->GetBoundingSphere();
- data.queueRef = -1;
- data.next = NULL;
- data.prev = NULL;
- data.customBodyRef = customBodyRef;
- data.limbo = false;
- this->mapReferences.insert(std::pair (data.customBodyRef, this->leafData.size()));
- this->leafData.push_back(data);
-
- /*if(tempPtr != NULL)
- {
- tempPtr->prev->next = &this->leafData[this->leafData.size() - 1];
- this->leafData[this->leafData.size() - 1].prev = tempPtr->prev;
- tempPtr->prev = &this->leafData[this->leafData.size() - 1];
- this->leafData[this->leafData.size() - 1].next = tempPtr;
- }
- else
- {
- this->worldNode.dataPtr = &this->leafData[this->leafData.size() - 1];
- this->worldNode.dataPtr->next = this->worldNode.dataPtr;
- this->worldNode.dataPtr->prev = this->worldNode.dataPtr;
- }*/
-}
-
-void Octree::MoveToUpdateQueue(UniquePointer< ICustomBody > customBodyRef)
-{
- /*this->leafData[this->mapReferences[customBodyRef]].queueRef = this->updateQueue.size();
- this->updateQueue.push_back(&this->leafData[this->mapReferences[customBodyRef]]);*/
-}
-
-void Octree::MoveToLimbo(const ICustomBody* customBodyRef)
-{
- auto object = this->mapReferences.find(customBodyRef);
-
- unsigned int tempRef = object->second;
-
- this->leafData[tempRef].limbo = true;
-}
-
-bool Octree::IsInLimbo(const ICustomBody* customBodyRef)
-{
- auto object = this->mapReferences.find(customBodyRef);
-
- unsigned int tempRef = object->second;
-
- return this->leafData[tempRef].limbo;
-}
-
-void Octree::ReleaseFromLimbo(const ICustomBody* customBodyRef)
-{
- auto object = this->mapReferences.find(customBodyRef);
-
- unsigned int tempRef = object->second;
-
- this->leafData[tempRef].limbo = false;
-}
-
-void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef)
-{
- std::map::iterator it = this->mapReferences.find(customBodyRef);
-
- this->mapReferences.erase(it);
-
- this->leafData.erase(this->leafData.begin() + this->leafData[this->mapReferences[customBodyRef]].queueRef);
-}
-
-std::vector& Octree::Sample(ICustomBody* customBodyRef, std::vector& updateList)
-{
- auto object = this->mapReferences.find(customBodyRef);
-
- if(object == this->mapReferences.end())
- {
- return updateList;
- }
-
- unsigned int tempRef = object->second;
-
- for(unsigned int i = 0; ileafData.size(); i++)
- {
- if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
- {
- updateList.push_back(this->leafData[i].customBodyRef);
- }
- }
-
- return updateList;
-}
-
-std::vector& Octree::Sample(const Oyster::Collision3D::ICollideable& collideable, std::vector& updateList)
-{
- for(unsigned int i = 0; ileafData.size(); i++)
- {
- if(!this->leafData[i].limbo && this->leafData[i].container.Intersects(collideable))
- {
- updateList.push_back(this->leafData[i].customBodyRef);
- }
- }
-
- return updateList;
-}
-
-void Octree::Visit(ICustomBody* customBodyRef, VisitorAction hitAction )
-{
- auto object = this->mapReferences.find(customBodyRef);
-
- // If rigid body is not found
- if(object == this->mapReferences.end())
- {
- return;
- }
-
- unsigned int tempRef = object->second;
-
- // Go through all object and test for intersection
- for(unsigned int i = 0; ileafData.size(); i++)
- {
- // If objects intersect call collision response function
- if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
- {
- hitAction(*this, tempRef, i);
- }
- }
-}
-
-void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, void* args, VisitorActionCollideable hitAction)
-{
- for(unsigned int i = 0; ileafData.size(); i++)
- {
- if(!this->leafData[i].limbo && collideable.Intersects(this->leafData[i].container))
- {
- hitAction( this->GetCustomBody(i), args );
- }
- }
-}
-
-ICustomBody* Octree::GetCustomBody(const unsigned int tempRef)
-{
- return this->leafData[tempRef].customBodyRef;
-}
-
-UniquePointer Octree::Extract( const ICustomBody* objRef )
-{ // Dan Andersson
- auto iter = this->mapReferences.find( objRef );
- if( iter != this->mapReferences.end() )
- {
- return this->Extract( iter->second );
- }
- else
- {
- return NULL;
- }
-}
-
-UniquePointer Octree::Extract( unsigned int tempRef )
-{
- if( tempRef != Octree::invalid_ref )
- {
- //! @todo TODO: implement stub
- return NULL;
- }
- else
- {
- return NULL;
- }
-}
-
-unsigned int Octree::GetTemporaryReferenceOf( const ICustomBody* objRef ) const
-{ // Dan Andersson
- auto iter = this->mapReferences.find( objRef );
- if( iter != this->mapReferences.end() )
- {
- return iter->second;
- }
- else
- {
- return Octree::invalid_ref;
- }
-}
-
-void Octree::SetAsAltered( unsigned int tempRef )
-{
- //this->leafData[tempRef].container = this->leafData[tempRef].customBodyRef->GetBoundingSphere();
- //! @todo TODO: implement stub
-}
-
-void Octree::EvaluatePosition( unsigned int tempRef )
-{
- //! @todo TODO: implement stub
-}
\ No newline at end of file
diff --git a/Code/GamePhysics/Implementation/Octree.h b/Code/GamePhysics/Implementation/Octree.h
deleted file mode 100644
index 573738f2..00000000
--- a/Code/GamePhysics/Implementation/Octree.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef OCTREE_H
-#define OCTREE_H
-
-#include
-#include