changed collision manager
is now a namespace with functions that are to be sent to a rigidbody
This commit is contained in:
parent
b3ec2f3aa1
commit
9bddfc9ffa
|
@ -1,46 +1,47 @@
|
||||||
#include "CollisionManager.h"
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
|
||||||
|
|
||||||
CollisionManager::CollisionManager(void)
|
|
||||||
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
refManager = new RefManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CollisionManager::~CollisionManager(void)
|
|
||||||
{
|
|
||||||
SAFE_DELETE(refManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CollisionManager::ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
|
|
||||||
{
|
|
||||||
Object *realObj1 = refManager->GetMap(obj1);
|
|
||||||
Object *realObj2 = refManager->GetMap(obj2);
|
|
||||||
|
|
||||||
switch(realObj1->GetType())
|
|
||||||
|
namespace CollisionManager
|
||||||
{
|
{
|
||||||
case Object::OBJECT_TYPE_PLAYER:
|
|
||||||
|
|
||||||
if (realObj2->GetType() == Object::OBJECT_TYPE_BOX )
|
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
|
||||||
{
|
{
|
||||||
PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
|
|
||||||
|
|
||||||
|
//Object *realObj1 = refManager.GetMap(obj1);
|
||||||
|
//Object *realObj2 = refManager.GetMap(obj2);
|
||||||
|
//
|
||||||
|
//switch(realObj1->GetType())
|
||||||
|
//{
|
||||||
|
//case Object::OBJECT_TYPE_PLAYER:
|
||||||
|
|
||||||
|
// if (realObj2->GetType() == Object::OBJECT_TYPE_BOX )
|
||||||
|
// {
|
||||||
|
//CollisionManager::PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// break;
|
||||||
|
//case Object::OBJECT_TYPE_BOX:
|
||||||
|
|
||||||
|
// if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
|
||||||
|
// {
|
||||||
|
// CollisionManager::PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
void PlayerVBox(Player &player, DynamicObject &box)
|
||||||
case Object::OBJECT_TYPE_BOX:
|
|
||||||
|
|
||||||
if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
|
|
||||||
{
|
{
|
||||||
PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
|
//spela ljud? ta skada? etc etc
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CollisionManager::PlayerVBox(Player &player, DynamicObject &box)
|
|
||||||
{
|
|
||||||
//spela ljud? ta skada? etc etc
|
|
||||||
}
|
}
|
|
@ -9,21 +9,14 @@
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
RefManager refManager;
|
||||||
|
|
||||||
class CollisionManager
|
namespace CollisionManager
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
|
||||||
CollisionManager(void);
|
|
||||||
~CollisionManager(void);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2);
|
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2);
|
||||||
void PlayerVBox(Player &player, DynamicObject &box);
|
void PlayerVBox(Player &player, DynamicObject &box);
|
||||||
|
|
||||||
private:
|
|
||||||
RefManager *refManager;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "DllInterfaces\GFXAPI.h"
|
#include "DllInterfaces\GFXAPI.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
@ -12,78 +13,28 @@ using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
Object::Object(void)
|
Object::Object(void)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
model = new Oyster::Graphics::Model::Model();
|
|
||||||
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
|
|
||||||
|
|
||||||
model->WorldMatrix *= 0.1f;
|
|
||||||
model->WorldMatrix.m44 = 1.0f;
|
|
||||||
=======
|
|
||||||
model = new Model();
|
model = new Model();
|
||||||
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
|
model = Oyster::Graphics::API::CreateModel(L"bth.obj");
|
||||||
|
refManager.AddMapping(*rigidBody, *this);
|
||||||
|
|
||||||
/*struct float4
|
|
||||||
{
|
|
||||||
float x,y,z,w;
|
|
||||||
};
|
|
||||||
|
|
||||||
float4 mesh[] =
|
|
||||||
{
|
|
||||||
{-1.0f,1.0f,0.0f,1.0f},
|
|
||||||
{1.0f,1.0f,0.0f,1.0f},
|
|
||||||
{1.0f,-1.0f,0.0f,1.0f},
|
|
||||||
};
|
|
||||||
|
|
||||||
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
|
||||||
desc.ElementSize= sizeof(float4);
|
|
||||||
desc.NumElements = 3;
|
|
||||||
desc.InitData=mesh;
|
|
||||||
desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
|
||||||
desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
|
||||||
|
|
||||||
Oyster::Graphics::Buffer *b = new Oyster::Graphics::Buffer();
|
|
||||||
b->Init(desc);
|
|
||||||
|
|
||||||
ModelInfo* modelInfo = new ModelInfo();
|
|
||||||
modelInfo->Vertices = *b;
|
|
||||||
|
|
||||||
modelInfo->Indexed = false;
|
|
||||||
modelInfo->VertexCount = 3;
|
|
||||||
|
|
||||||
|
|
||||||
Float4x4 matrix = Float4x4::identity;
|
|
||||||
|
|
||||||
model->World = &matrix;
|
|
||||||
model->info = modelInfo;
|
|
||||||
model->Visible = true;*/
|
|
||||||
>>>>>>> 01515a4d2d309cfebf4e3dab3ad68787f93050e1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object::~Object(void)
|
Object::~Object(void)
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
Oyster::Graphics::API::DeleteModel(model);
|
||||||
//SAFE_DELETE(model->info);
|
|
||||||
|
|
||||||
Oyster::Graphics::API::DeleteModel(model);
|
|
||||||
>>>>>>> 01515a4d2d309cfebf4e3dab3ad68787f93050e1
|
|
||||||
}
|
}
|
||||||
Model* Object::Render()
|
Model* Object::Render()
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
//Oyster::Graphics::API::RenderScene(model,1);
|
||||||
Oyster::Graphics::API::RenderScene(model,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::Update()
|
|
||||||
{
|
|
||||||
//dummy implementation that will be overloaded if the other class implements it in a different way
|
|
||||||
=======
|
|
||||||
//model->info->Vertices.Apply(0);
|
//model->info->Vertices.Apply(0);
|
||||||
this->rigidBody->GetOrientation(model->WorldMatrix);
|
this->rigidBody->GetOrientation(model->WorldMatrix);
|
||||||
return model;
|
return model;
|
||||||
>>>>>>> 01515a4d2d309cfebf4e3dab3ad68787f93050e1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::OBJECT_TYPE Object::GetType()
|
Object::OBJECT_TYPE Object::GetType()
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class Object
|
class Object
|
||||||
|
@ -38,8 +39,8 @@ namespace GameLogic
|
||||||
//either a model pointer or an ID to an arraypos filled with models that are to be rendered
|
//either a model pointer or an ID to an arraypos filled with models that are to be rendered
|
||||||
//rigidBody
|
//rigidBody
|
||||||
|
|
||||||
Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> rigidBody;
|
Oyster::Physics::ICustomBody *rigidBody;
|
||||||
Utility::DynamicMemory::UniquePointer<Oyster::Graphics::Model::Model> model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue