From 9bddfc9ffaf4e6c4ec075f0cc103e524a5b4c0b5 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 28 Nov 2013 09:26:29 +0100 Subject: [PATCH] changed collision manager is now a namespace with functions that are to be sent to a rigidbody --- Code/GameLogic/CollisionManager.cpp | 65 +++++++++++++++-------------- Code/GameLogic/CollisionManager.h | 11 +---- Code/GameLogic/Object.cpp | 59 +++----------------------- Code/GameLogic/Object.h | 5 ++- 4 files changed, 43 insertions(+), 97 deletions(-) diff --git a/Code/GameLogic/CollisionManager.cpp b/Code/GameLogic/CollisionManager.cpp index 7e0ad977..86f7c37a 100644 --- a/Code/GameLogic/CollisionManager.cpp +++ b/Code/GameLogic/CollisionManager.cpp @@ -1,46 +1,47 @@ #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; - case Object::OBJECT_TYPE_BOX: - - if (realObj2->GetType() == Object::OBJECT_TYPE_PLAYER) + void PlayerVBox(Player &player, DynamicObject &box) { - 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 } \ No newline at end of file diff --git a/Code/GameLogic/CollisionManager.h b/Code/GameLogic/CollisionManager.h index 8bbc06c7..eedac2cc 100644 --- a/Code/GameLogic/CollisionManager.h +++ b/Code/GameLogic/CollisionManager.h @@ -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; - }; } diff --git a/Code/GameLogic/Object.cpp b/Code/GameLogic/Object.cpp index f4d2c6d0..21087448 100644 --- a/Code/GameLogic/Object.cpp +++ b/Code/GameLogic/Object.cpp @@ -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); - 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() diff --git a/Code/GameLogic/Object.h b/Code/GameLogic/Object.h index 61b58a5e..57ec2c67 100644 --- a/Code/GameLogic/Object.h +++ b/Code/GameLogic/Object.h @@ -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 rigidBody; - Utility::DynamicMemory::UniquePointer model; + Oyster::Physics::ICustomBody *rigidBody; + Oyster::Graphics::Model::Model *model; };