From d32e614b0000cb43342091b13d43a220a00f67a7 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 16:03:46 +0100 Subject: [PATCH] GL - Hax to get the world model initiated. reading spawnpoints --- .../DanBiasGame/GameClientState/GameState.cpp | 61 +++++++++++++++---- Code/Game/GameLogic/Level.cpp | 41 ++++++++++++- 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 22194795..6d0c21c5 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -189,24 +189,59 @@ bool GameState::LoadModels(std::string mapFile) break; case GameLogic::ObjectType::ObjectType_Static: { + GameLogic::ObjectHeader* staticObjData = ((GameLogic::ObjectHeader*)obj); + if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_Sky) { - int i = 0; - } - modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); - modelData.visible = true; - modelData.position = staticObjData->position; - modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(staticObjData->rotation), staticObjData->rotation[3]); - modelData.scale = staticObjData->scale; - modelData.id = modelId++; + modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); + modelData.visible = true; + modelData.position = Oyster::Math::Float3(0,0,0); + modelData.rotation = Oyster::Math::Quaternion::identity; + modelData.scale = Oyster::Math::Float3(600, 600, 600); + modelData.id = modelId++; - this->staticObjects.Push(new C_StaticObj()); - if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + this->staticObjects.Push(new C_StaticObj()); + if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->staticObjects.Remove(this->staticObjects.Size() -1 ); + modelId--; + } + } + if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_World) { - // the model don't exist - this->staticObjects.Remove(this->staticObjects.Size() -1 ); - modelId--; + modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); + modelData.visible = true; + modelData.position = Oyster::Math::Float3(0,0,0); + modelData.rotation = Oyster::Math::Quaternion::identity; + modelData.scale = Oyster::Math::Float3(300,300,300); + modelData.id = modelId++; + + this->staticObjects.Push(new C_StaticObj()); + if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->staticObjects.Remove(this->staticObjects.Size() -1 ); + modelId--; + } + } + else + { + modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); + modelData.visible = true; + modelData.position = staticObjData->position; + modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(staticObjData->rotation), staticObjData->rotation[3]); + modelData.scale = staticObjData->scale; + modelData.id = modelId++; + + this->staticObjects.Push(new C_StaticObj()); + if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->staticObjects.Remove(this->staticObjects.Size() -1 ); + modelId--; + } } } break; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 6b9081d7..030f0eca 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -43,6 +43,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) float worldSize = ((WorldAttributes*)obj)->worldSize; float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize; + gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); } break; @@ -224,9 +225,39 @@ void Level::InitiateLevel(std::string levelPath) staticObjData->ModelFile; ICustomBody* rigidBody_Static = NULL; + if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_Sky) + { + + } + if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_World) + { + Oyster::Math::Float3 rigidWorldPos; + Oyster::Math::Float4 rigidWorldRotation; + float rigidBodyMass; + float rigidBodyRadius; + + //offset the rigidPosition from modelspace to worldspace; + rigidWorldPos = Oyster::Math::Float3(0,0,0); + //scales the position so the collision geomentry is in the right place + + //offset the rigidRotation from modelspace to worldspace; + + rigidWorldRotation = Oyster::Math::Float4(0,0,0,1); + + + //mass scaled + rigidBodyMass = 100; + + //Radius scaled + rigidBodyRadius = 150; + + //create the rigid body + rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, 1,1,1); + + } // collision shape - if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere) + else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere) { rigidBody_Static = InitRigidBodySphere(staticObjData); } @@ -289,6 +320,14 @@ void Level::InitiateLevel(std::string levelPath) case ObjectType::ObjectType_Light: // read on client break; + case ObjectType::ObjectType_SpawnPoint: + { + Oyster::Math::Float3 pos; + pos.x = ((SpawnPointAttributes*)obj)->position[0]; + pos.y = ((SpawnPointAttributes*)obj)->position[1]; + pos.z = ((SpawnPointAttributes*)obj)->position[2]; + spawnPoints.Push(pos); + } default: break; }