From b39a6703477decfd76935c7879018f7324565a11 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 5 Feb 2014 15:46:45 +0100 Subject: [PATCH] GL - Updated LevelLoader, works with Fredricks level editor. --- .../GameLogic/LevelLoader/LevelLoader.cpp | 3 ++ .../GameLogic/LevelLoader/ObjectDefines.h | 38 +++++++++++++++---- .../GameLogic/LevelLoader/ParseFunctions.cpp | 13 +++++-- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp index 5bb916ab..55a39725 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp @@ -4,17 +4,20 @@ #include "LevelLoader.h" #include "LevelParser.h" + using namespace GameLogic; using namespace GameLogic::LevelFileLoader; struct LevelLoader::PrivData { LevelParser parser; + std::string folderPath; }; LevelLoader::LevelLoader() : pData(new PrivData) { + pData->folderPath = "Standard path"; } LevelLoader::~LevelLoader() diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index 7c924976..8287dafb 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -34,6 +34,15 @@ namespace GameLogic UsePhysics_Unknown = -1 }; + enum CollisionGeometryType + { + CollisionGeometryType_Box, + CollisionGeometryType_Sphere, + + CollisionGeometryType_Count, + CollisionGeometryType_Unknown = -1 + }; + enum LightType { LightType_PointLight, @@ -55,6 +64,18 @@ namespace GameLogic GameMode_Unknown = -1 }; + enum WorldSize + { + WorldSize_Tiny, + WorldSize_Small, + WorldSize_Medium, + WorldSize_Big, + WorldSize_Humongous, + + WorldSize_Count, + WorldSize_Unknown = -1 + }; + /************************************ Structs @@ -62,8 +83,8 @@ namespace GameLogic struct FormatVersion { - int formatVersionMajor; - int formatVersionMinor; + unsigned int formatVersionMajor; + unsigned int formatVersionMinor; bool operator ==(const FormatVersion& obj) { @@ -89,22 +110,22 @@ namespace GameLogic float inertiaRotation[3]; float frictionCoeffStatic; float frictionCoeffDynamic; - + CollisionGeometryType geometryType; }; - struct LevelMetaData : ObjectTypeHeader + struct LevelMetaData : public ObjectTypeHeader { std::string levelName; - int levelVersion; + unsigned int levelVersion; std::string levelDescription; std::string levelAuthor; - int maxNumberOfPlayer; - int worldSize; + unsigned int maxNumberOfPlayer; + WorldSize worldSize; std::string overviewPicturePath; std::vector gameModesSupported; }; - struct ObjectHeader : public ObjectTypeHeader + struct ObjectHeader : public ObjectTypeHeader, public PhysicsObject { //Model, std::string ModelFile; @@ -112,6 +133,7 @@ namespace GameLogic float position[3]; //Rotation float rotation[3]; + float angle; //Scale float scale[3]; }; diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index 68631bf0..95236c05 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -23,7 +23,7 @@ namespace GameLogic void ParseObject(char* buffer, ObjectHeader& header, int& size) { char tempName[128]; - int tempSize = 0; + unsigned int tempSize = 0; int start = 0; memcpy(&header.typeID, &buffer[start], 4); @@ -36,8 +36,13 @@ namespace GameLogic header.ModelFile.assign(&tempName[0], &tempName[tempSize]); start += tempSize; - memcpy(&header.position, &buffer[start], 36); - start += 36; + //3 float[3], 1 float + memcpy(&header.position, &buffer[start], 40); + start += 40; + + //2 float[3], 3 float, 2 uint + memcpy(&header.usePhysics, &buffer[start], 44); + start += 44; size += start; } @@ -45,7 +50,7 @@ namespace GameLogic void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size) { int start = 0; - int tempSize; + unsigned int tempSize; char tempName[128]; memcpy(&header.typeID, &buffer[start], 4);