2013-11-19 18:35:35 +01:00
|
|
|
#include "Object.h"
|
2013-11-21 12:05:39 +01:00
|
|
|
#include "OysterMath.h"
|
2013-12-12 12:16:13 +01:00
|
|
|
#include "CollisionManager.h"
|
2013-12-18 13:01:13 +01:00
|
|
|
#include "GID.h"
|
2013-12-21 17:37:30 +01:00
|
|
|
#include "PhysicsAPI.h"
|
2014-01-20 15:47:52 +01:00
|
|
|
#include "Game.h"
|
2013-11-21 12:05:39 +01:00
|
|
|
|
2013-11-19 18:35:35 +01:00
|
|
|
|
|
|
|
using namespace GameLogic;
|
|
|
|
|
2013-11-21 12:05:39 +01:00
|
|
|
using namespace Oyster::Math;
|
2013-11-28 11:23:11 +01:00
|
|
|
using namespace Oyster::Physics;
|
2013-11-19 18:35:35 +01:00
|
|
|
|
2014-01-20 15:47:52 +01:00
|
|
|
const Game *Object::gameInstance = (Game*)(&Game::Instance());
|
|
|
|
|
2013-12-12 09:36:14 +01:00
|
|
|
Object::Object()
|
|
|
|
{
|
2014-02-10 15:54:38 +01:00
|
|
|
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
2014-01-16 12:26:14 +01:00
|
|
|
|
2014-02-12 14:48:58 +01:00
|
|
|
this->type = ObjectSpecialType_Unknown;
|
2014-02-14 09:53:02 +01:00
|
|
|
this->objectID = -1;
|
2014-02-19 10:36:45 +01:00
|
|
|
this->scale = Float3(1.0f, 1.0f, 1.0f);
|
2013-12-12 09:36:14 +01:00
|
|
|
}
|
2013-11-19 18:35:35 +01:00
|
|
|
|
2014-02-14 09:53:02 +01:00
|
|
|
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
2014-01-29 14:33:21 +01:00
|
|
|
{
|
|
|
|
this->rigidBody = rigidBody;
|
2014-02-12 13:11:35 +01:00
|
|
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
2013-12-12 09:36:14 +01:00
|
|
|
this->type = type;
|
2014-02-14 09:53:02 +01:00
|
|
|
this->objectID = objectID;
|
2014-02-14 10:56:38 +01:00
|
|
|
this->extraDamageOnCollision = 0;
|
2014-02-14 09:53:02 +01:00
|
|
|
this->rigidBody->SetCustomTag(this);
|
2013-11-21 12:05:39 +01:00
|
|
|
}
|
2013-11-28 08:33:29 +01:00
|
|
|
|
2014-02-12 14:48:58 +01:00
|
|
|
|
2014-02-14 09:53:02 +01:00
|
|
|
Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
2014-01-27 08:54:25 +01:00
|
|
|
{
|
2014-01-27 13:54:57 +01:00
|
|
|
this->rigidBody = rigidBody;
|
2014-02-12 13:11:35 +01:00
|
|
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
2014-01-27 13:54:57 +01:00
|
|
|
this->type = type;
|
2014-02-14 09:53:02 +01:00
|
|
|
this->objectID = objectID;
|
2014-02-14 10:56:38 +01:00
|
|
|
this->extraDamageOnCollision = 0;
|
2014-02-14 09:53:02 +01:00
|
|
|
this->rigidBody->SetCustomTag(this);
|
2014-01-27 08:54:25 +01:00
|
|
|
}
|
|
|
|
|
2013-12-12 09:36:14 +01:00
|
|
|
Object::~Object(void)
|
2013-11-28 11:23:11 +01:00
|
|
|
{
|
2013-12-12 09:36:14 +01:00
|
|
|
|
2013-11-19 18:35:35 +01:00
|
|
|
}
|
2013-11-26 11:30:49 +01:00
|
|
|
|
2014-01-20 15:47:52 +01:00
|
|
|
|
2014-02-19 10:36:45 +01:00
|
|
|
void Object::SetOnCollision(OnCollisionCallback func)
|
2014-01-20 15:47:52 +01:00
|
|
|
{
|
2014-02-19 10:36:45 +01:00
|
|
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
|
2014-01-28 15:04:25 +01:00
|
|
|
}
|
2014-01-29 16:01:56 +01:00
|
|
|
|
|
|
|
|
2014-01-28 15:04:25 +01:00
|
|
|
Oyster::Math::Float3 Object::GetPosition()
|
|
|
|
{
|
|
|
|
Oyster::Physics::ICustomBody::State state;
|
|
|
|
state = this->rigidBody->GetState();
|
2014-02-09 21:24:09 +01:00
|
|
|
return state.centerPos;
|
2014-01-28 15:04:25 +01:00
|
|
|
}
|
2014-02-11 13:03:37 +01:00
|
|
|
Oyster::Math::Quaternion Object::GetRotation()
|
|
|
|
{
|
|
|
|
Oyster::Physics::ICustomBody::State state;
|
|
|
|
state = this->rigidBody->GetState();
|
|
|
|
return state.quaternion;
|
|
|
|
}
|
2014-01-28 15:04:25 +01:00
|
|
|
Oyster::Math::Float4x4 Object::GetOrientation()
|
|
|
|
{
|
|
|
|
Oyster::Physics::ICustomBody::State state;
|
|
|
|
state = this->rigidBody->GetState();
|
|
|
|
return state.GetOrientation();
|
2014-02-14 10:56:38 +01:00
|
|
|
}
|