From 2dee9dd084230a523ecba8aaea4fc9fa296e41d0 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 13 Feb 2014 16:33:26 +0100 Subject: [PATCH] GL - initiating ccc map from folder ../Content/Worlds. Sync with graphics content. --- .../DanBiasGame/GameClientState/GameState.cpp | 20 +- .../LevelLoader/ParseFunctions.cpp | 2 +- Code/Game/GameLogic/CollisionManager.cpp | 1 + Code/Game/GameLogic/Game.cpp | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 4 +- Code/Game/GameLogic/Level.cpp | 302 +++++++++++------- Code/Game/GameLogic/Level.h | 5 +- .../GameLogic/LevelLoader/ParseFunctions.cpp | 2 +- Code/Game/GameLogic/Portal.cpp | 2 +- Code/Game/GameLogic/Portal.h | 2 +- 10 files changed, 212 insertions(+), 130 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 17ac3677..0a732062 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -77,10 +77,10 @@ GameState::gameStateState GameState::LoadGame() //Oyster::Graphics::API::AddLight(plight); // use level loader - //LoadModels("3bana.bias"); + LoadModels("../Content/Worlds/ccc.bias"); // hardcoded objects - LoadModels("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias"); + //LoadModels(); Float3 startPos = Float3(0,0,20.0f); InitCamera(startPos); return gameStateState_playing; @@ -185,7 +185,7 @@ bool GameState::LoadModels(std::string mapFile) objects = levelLoader.LoadLevel(mapFile); int objCount = objects.size(); - int modelId = 0; + int modelId = 100; ModelInitData modelData; for (int i = 0; i < objCount; i++) { @@ -244,19 +244,19 @@ bool GameState::LoadModels(std::string mapFile) break; } } - myId += modelId++; + //myId += modelId++; // add player model //modelData.position = ; //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1); //modelData.scale = Oyster::Math::Float3(2,2,2); - modelData.visible = true; - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = myId; - // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); + //modelData.visible = true; + //modelData.modelPath = L"char_still_sizeref.dan"; + //modelData.id = myId; + //// load models + //this->dynamicObjects.Push(new C_DynamicObj()); + //this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); /*C_Player* obj = new C_Player(); privData->object.push_back(obj); diff --git a/Code/Game/DanBiasGame/GameClientState/LevelLoader/ParseFunctions.cpp b/Code/Game/DanBiasGame/GameClientState/LevelLoader/ParseFunctions.cpp index 7f5550d7..59f967de 100644 --- a/Code/Game/DanBiasGame/GameClientState/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LevelLoader/ParseFunctions.cpp @@ -147,7 +147,7 @@ namespace GameLogic //Läs in filen. int fileLength = 0; Loader loader; - char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength); + char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength); start = 0; LevelLoaderInternal::FormatVersion version; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 857c135c..c3b70cce 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -37,6 +37,7 @@ using namespace GameLogic; PlayerVObject(*player,*realObj, kineticEnergyLoss); //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; break; + } //return Physics::ICustomBody::SubscriptMessage_none; diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index 8be3f7a8..5bf18dc4 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -82,7 +82,7 @@ Game::LevelData* Game::CreateLevel() this->level = new LevelData(); //this->level->level->InitiateLevel(1000); - this->level->level->InitiateLevel("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias"); + this->level->level->InitiateLevel("../Content/Worlds/ccc.bias"); return this->level; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index efeab2ee..acdcd2f3 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -7,9 +7,9 @@ Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0); - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); + Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f); Oyster::Math::Float mass = 60; Oyster::Math::Float restitutionCoeff = 0.5; Oyster::Math::Float frictionCoeff_Static = 0.4; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 3cdab709..9a91744e 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -16,48 +16,190 @@ Level::~Level(void) delete this->levelObj; this->levelObj = NULL; } -void Level::parseObjectType(ObjectTypeHeader* obj) +Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) { - /*switch (obj->objectTypeID) + Object* gameObj =NULL; + switch ((ObjectSpecialType)obj->specialTypeID) { - case skySphere: - // save the skysphere to be able to rotate it + case ObjectSpecialType_None: + { + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } break; - case jumppad: - // save direction - break; - case portal: - // save portal destination - break; - case world: - // add gravitation well here - // add outer limit of the world - case spawn: - // save spawnpoint pos + case ObjectSpecialType_Sky: + { + float skySize = ((SkyAttributes*)obj)->skySize; + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } break; + case ObjectSpecialType_World: + { + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); + API::Instance().SetGravity(200); // could balance gravitation with the world size - default: + float worldSize = ((WorldAttributes*)obj)->worldSize; + float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize; + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } break; - }*/ + case ObjectSpecialType_Building: + { + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + case ObjectSpecialType_Stone: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_StandarsBox: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_RedExplosiveBox: + { + int dmg = 50; + //gameObj = new ExplosiveBox(rigidBody, ObjectSpecialType_RedExplosiveBox); + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + //case ObjectSpecialType_BlueExplosiveBox: + // int dmg = 70; + // gameObj = new ExplosiveBox(rigidBody, ObjectSpecialType_BlueExplosiveBox); + // break; + case ObjectSpecialType_SpikeBox: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_Spike: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_CrystalFormation: + { + int dmg = 50; + //gameObj = new Crystal(rigidBody); + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_CrystalShard: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_JumpPad: + { + float power = ((JumpPadAttributes*)obj)->power; + Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction; + //gameObj = JumpPad(rigidBody, ); + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_Portal: + { + Oyster::Math::Float3 destination = ((PortalAttributes*)obj)->destination; + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_SpawnPoint: + { + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_Player: + { + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + case ObjectSpecialType_Generic: + { + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + default: + { + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID); + } + break; + } + return gameObj; } -void Level::parsePhysicsObj(LevelLoaderInternal::BoundingVolumeBase* obj) + +ICustomBody* Level::InitRigidBodyCube( const ObjectHeader* obj) { - // offset physObj med modelObj + ICustomBody* rigidBody = NULL; + Oyster::Math::Float3 rigidWorldPos; + Oyster::Math::Float4 rigidWorldRotation; + float rigidBodyMass; + Oyster::Math::Float3 rigidBodySize; + + //offset the rigidPosition from modelspace to worldspace; + rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.box.position; + //scales the position so the collision geomentry is in the right place + rigidWorldPos = rigidWorldPos * obj->scale; + + //offset the rigidRotation from modelspace to worldspace; + Oyster::Math::Quaternion worldPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->rotation[0],obj->rotation[1],obj->rotation[2]), obj->rotation[3]); + Oyster::Math::Quaternion physicsPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->boundingVolume.sphere.rotation[0],obj->boundingVolume.sphere.rotation[1],obj->boundingVolume.sphere.rotation[2]), obj->boundingVolume.sphere.rotation[3]); + Oyster::Math::Quaternion rigidWorldQuaternion = worldPosQuaternion * physicsPosQuaternion; + + rigidWorldRotation = Oyster::Math::Float4(rigidWorldQuaternion); + + //mass scaled + rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.box.mass; + + //size scaled + rigidBodySize = (Oyster::Math::Float3)obj->boundingVolume.box.size * (Oyster::Math::Float3)obj->scale; + + //create the rigid body + rigidBody = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.box.restitutionCoeff , obj->boundingVolume.box.frictionCoeffStatic , obj->boundingVolume.box.frictionCoeffDynamic); + return rigidBody; +} +ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj) +{ + ICustomBody* rigidBody = NULL; + Oyster::Math::Float3 rigidWorldPos; + Oyster::Math::Float4 rigidWorldRotation; + float rigidBodyMass; + float rigidBodyRadius; + + //offset the rigidPosition from modelspace to worldspace; + rigidWorldPos = (Oyster::Math::Float3)obj->position + (Oyster::Math::Float3)obj->boundingVolume.sphere.position; + //scales the position so the collision geomentry is in the right place + rigidWorldPos = rigidWorldPos * obj->scale; + + //offset the rigidRotation from modelspace to worldspace; + Oyster::Math::Quaternion worldPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->rotation[0],obj->rotation[1],obj->rotation[2]), obj->rotation[3]); + Oyster::Math::Quaternion physicsPosQuaternion = Oyster::Math::Quaternion(Oyster::Math::Float3(obj->boundingVolume.sphere.rotation[0],obj->boundingVolume.sphere.rotation[1],obj->boundingVolume.sphere.rotation[2]), obj->boundingVolume.sphere.rotation[3]); + Oyster::Math::Quaternion rigidWorldQuaternion = worldPosQuaternion * physicsPosQuaternion; + + rigidWorldRotation = Oyster::Math::Float4(rigidWorldQuaternion); + + + //mass scaled + rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.sphere.mass; + + //Radius scaled + //rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; + rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; + + //create the rigid body + rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic); + return rigidBody; } void Level::InitiateLevel(std::string levelPath) { LevelLoader ll; std::vector> objects; objects = ll.LoadLevel(levelPath); + + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); + API::Instance().SetGravity(200); int objCount = objects.size(); - int modelCount = 0; - int staticObjCount = 0; - int dynamicObjCount = 0; - Oyster::Math::Float3 rigidWorldPos; - Oyster::Math::Float4 rigidWorldRotation; - float rigidBodyMass; - float rigidBodyRadius; - Oyster::Math::Float3 rigidBodySize; + int modelCount = 100; + for (int i = 0; i < objCount; i++) { ObjectTypeHeader* obj = objects.at(i); @@ -75,69 +217,37 @@ void Level::InitiateLevel(std::string levelPath) { ObjectHeader* staticObjData = ((ObjectHeader*)obj); - //LevelLoaderInternal::BoundingVolumeBase* staticObjPhysicData = ((ObjectHeader*)obj); staticObjData->ModelFile; ICustomBody* rigidBody_Static = NULL; - // collision shape - // radius, rotation in world, position in world, mass, restitution, static and dynamic friction if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere) { - //offset the rigidPosition from modelspace to worldspace; - rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.sphere.position; - //scales the position so the collision geomentry is in the right place - rigidWorldPos = rigidWorldPos * staticObjData->scale; - - //offset the rigidRotation from modelspace to worldspace; - rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.sphere.rotation; - - //mass scaled - rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.sphere.mass; - - //Radius scaled - rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; - - //create the rigid body - rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.sphere.restitutionCoeff , staticObjData->boundingVolume.sphere.frictionCoeffStatic , staticObjData->boundingVolume.sphere.frictionCoeffDynamic); + rigidBody_Static = InitRigidBodySphere(staticObjData); } else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box) { - //offset the rigidPosition from modelspace to worldspace; - rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.box.position; - //scales the position so the collision geomentry is in the right place - rigidWorldPos = rigidWorldPos * staticObjData->scale; - //offset the rigidRotation from modelspace to worldspace; - rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.box.rotation; - - //mass scaled - rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.box.mass; - - //size scaled - rigidBodySize = (Oyster::Math::Float3)staticObjData->boundingVolume.box.size * (Oyster::Math::Float3)staticObjData->scale; - - //create the rigid body - rigidBody_Static = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.box.restitutionCoeff , staticObjData->boundingVolume.box.frictionCoeffStatic , staticObjData->boundingVolume.box.frictionCoeffDynamic); + rigidBody_Static = InitRigidBodySphere(staticObjData); } else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder) { - + //rigidBody_Static = InitRigidBodyCylinder(staticObjData); } - - // add rigidbody to the logical obj - // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this - // set object_type to objID - if(rigidBody_Static != NULL) { - this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID)); - this->staticObjects[staticObjCount]->objectID = modelCount++; - rigidBody_Static->SetCustomTag(this->staticObjects[staticObjCount]); + // create game object + Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static); + if(staticGameObj != NULL) + { + this->staticObjects.Push((StaticObject*)staticGameObj); + this->staticObjects[this->staticObjects.Size()-1]->objectID = modelCount++; + rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]); + } } } @@ -150,61 +260,31 @@ void Level::InitiateLevel(std::string levelPath) ICustomBody* rigidBody_Dynamic = NULL; // collision shape - // radius, rotation in world, position in world, mass, restitution, static and dynamic friction if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Sphere) { - //offset the rigidPosition from modelspace to worldspace; - rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.sphere.position; - //scales the position so the collision geomentry is in the right place - rigidWorldPos = rigidWorldPos * dynamicObjData->scale; - - //offset the rigidRotation from modelspace to worldspace; - rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.sphere.rotation; - - //mass scaled - rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.sphere.mass; - - //size scaled - rigidBodyRadius = (dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] / 3) * dynamicObjData->boundingVolume.sphere.radius; - - //create the rigid body - rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.sphere.restitutionCoeff , dynamicObjData->boundingVolume.sphere.frictionCoeffStatic , dynamicObjData->boundingVolume.sphere.frictionCoeffDynamic); + rigidBody_Dynamic = InitRigidBodySphere(dynamicObjData); } else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Box) { - //offset the rigidPosition from modelspace to worldspace; - rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.position; - //scales the position so the collision geomentry is in the right place - rigidWorldPos = rigidWorldPos * dynamicObjData->scale; - - //offset the rigidRotation from modelspace to worldspace; - rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.box.rotation; - - //mass scaled - rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.box.mass; - - //size scaled - rigidBodySize = (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.size * (Oyster::Math::Float3)dynamicObjData->scale; - - //create the rigid body - rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.box.restitutionCoeff , dynamicObjData->boundingVolume.box.frictionCoeffStatic , dynamicObjData->boundingVolume.box.frictionCoeffDynamic); + rigidBody_Dynamic = InitRigidBodyCube(dynamicObjData); } else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder) { - + //rigidBody_Dynamic = InitRigidBodyCylinder(dynamicObjData); } - - // add rigidbody to the logical obj - // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this - // set object_type to objID if(rigidBody_Dynamic != NULL) { - this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic , Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID)); - this->dynamicObjects[dynamicObjCount]->objectID = modelCount++; - rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]); + // create game object + Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic); + if (dynamicGameObj != NULL) + { + this->dynamicObjects.Push((DynamicObject*)dynamicGameObj); + this->dynamicObjects[this->dynamicObjects.Size()-1]->objectID = modelCount++; + rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]); + } } } diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index b8c3f744..c069ac1e 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -32,9 +32,10 @@ namespace GameLogic ********************************************************/ void InitiateLevel(std::string levelPath); void InitiateLevel(float radius); + Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj); + Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj); - void parseObjectType(ObjectTypeHeader* obj); - void parsePhysicsObj(LevelLoaderInternal::BoundingVolumeBase* obj); + Object* createGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody); /******************************************************** * Creates a team in the level * @param teamSize: The size of the team you want to create diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index 54c41b12..1caa840f 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -149,7 +149,7 @@ namespace GameLogic //Läs in filen. int fileLength = 0; Loader loader; - char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength); + char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength); start = 0; LevelLoaderInternal::FormatVersion version; diff --git a/Code/Game/GameLogic/Portal.cpp b/Code/Game/GameLogic/Portal.cpp index ac44d529..6fc787fa 100644 --- a/Code/Game/GameLogic/Portal.cpp +++ b/Code/Game/GameLogic/Portal.cpp @@ -9,7 +9,7 @@ Portal::Portal(void) this->portalExit = Float3(0,0,0); } -Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 portalExit) +Portal::Portal(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 portalExit) :StaticObject(rigidBody, collisionFuncAfter, type) { this->portalExit = portalExit; diff --git a/Code/Game/GameLogic/Portal.h b/Code/Game/GameLogic/Portal.h index 5b31c8b5..a8d308f4 100644 --- a/Code/Game/GameLogic/Portal.h +++ b/Code/Game/GameLogic/Portal.h @@ -10,7 +10,7 @@ namespace GameLogic Portal(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss) - ,OBJECT_TYPE type, Oyster::Math::Float3 portalExit); + ,ObjectSpecialType type, Oyster::Math::Float3 portalExit); ~Portal(void);