changed collision manager

is now a namespace with functions that are to be sent to a rigidbody
This commit is contained in:
Erik Persson 2013-11-28 09:26:29 +01:00
parent b3ec2f3aa1
commit 9bddfc9ffa
4 changed files with 43 additions and 97 deletions

View File

@ -1,46 +1,47 @@
#include "CollisionManager.h"
using namespace GameLogic;
CollisionManager::CollisionManager(void)
namespace GameLogic
{
refManager = new RefManager();
}
CollisionManager::~CollisionManager(void)
namespace CollisionManager
{
SAFE_DELETE(refManager);
}
void CollisionManager::ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
void ColisionEvent(Oyster::Physics::ICustomBody &obj1, Oyster::Physics::ICustomBody &obj2)
{
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 )
{
PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
}
//Object *realObj1 = refManager.GetMap(obj1);
//Object *realObj2 = refManager.GetMap(obj2);
//
//switch(realObj1->GetType())
//{
//case Object::OBJECT_TYPE_PLAYER:
break;
case Object::OBJECT_TYPE_BOX:
// if (realObj2->GetType() == Object::OBJECT_TYPE_BOX )
// {
//CollisionManager::PlayerVBox(*((Player*)realObj1),*((DynamicObject*)realObj2));
// }
if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
{
PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
}
// break;
//case Object::OBJECT_TYPE_BOX:
break;
}
// if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER)
// {
// CollisionManager::PlayerVBox(*((Player*)realObj2),*((DynamicObject*)realObj1));
// }
// break;
//}
}
void CollisionManager::PlayerVBox(Player &player, DynamicObject &box)
void PlayerVBox(Player &player, DynamicObject &box)
{
//spela ljud? ta skada? etc etc
}
}
}

View File

@ -9,21 +9,14 @@
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 PlayerVBox(Player &player, DynamicObject &box);
private:
RefManager *refManager;
};
}

View File

@ -1,6 +1,7 @@
#include "Object.h"
#include "OysterMath.h"
#include "DllInterfaces\GFXAPI.h"
#include "CollisionManager.h"
using namespace GameLogic;
@ -12,78 +13,28 @@ using namespace Utility::DynamicMemory;
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 = 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)
{
<<<<<<< HEAD
=======
//SAFE_DELETE(model->info);
Oyster::Graphics::API::DeleteModel(model);
>>>>>>> 01515a4d2d309cfebf4e3dab3ad68787f93050e1
}
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);
this->rigidBody->GetOrientation(model->WorldMatrix);
return model;
>>>>>>> 01515a4d2d309cfebf4e3dab3ad68787f93050e1
}
Object::OBJECT_TYPE Object::GetType()

View File

@ -13,6 +13,7 @@
#include "Utilities.h"
namespace GameLogic
{
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
//rigidBody
Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> rigidBody;
Utility::DynamicMemory::UniquePointer<Oyster::Graphics::Model::Model> model;
Oyster::Physics::ICustomBody *rigidBody;
Oyster::Graphics::Model::Model *model;
};