From 0f5517398dbb4b72c5395d13b918fcc8d5acdf11 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Fri, 24 Jan 2014 09:00:59 +0100 Subject: [PATCH 1/2] GL - Update uml, LevelParser.h.cpp ObjectDefines.h --- Code/Dokumentation/LevelLoader.uxf | 46 +++++++++++++-------------- Code/Game/GameLogic/GameLogic.vcxproj | 3 ++ Code/Game/GameLogic/LevelParser.cpp | 2 ++ Code/Game/GameLogic/LevelParser.h | 28 ++++++++++++++++ Code/Game/GameLogic/ObjectDefines.h | 38 ++++++++++++++++++++++ 5 files changed, 94 insertions(+), 23 deletions(-) create mode 100644 Code/Game/GameLogic/LevelParser.cpp create mode 100644 Code/Game/GameLogic/LevelParser.h create mode 100644 Code/Game/GameLogic/ObjectDefines.h diff --git a/Code/Dokumentation/LevelLoader.uxf b/Code/Dokumentation/LevelLoader.uxf index 723857bb..fd3e9c79 100644 --- a/Code/Dokumentation/LevelLoader.uxf +++ b/Code/Dokumentation/LevelLoader.uxf @@ -1,11 +1,11 @@ - + 8 com.umlet.element.Package 552 - 320 + 360 584 368 @@ -16,7 +16,7 @@ com.umlet.element.Class 440 - 88 + 128 128 40 @@ -28,7 +28,7 @@ com.umlet.element.Relation 768 - 472 + 512 136 104 @@ -39,12 +39,12 @@ com.umlet.element.Class 560 - 544 + 584 232 136 <<Interface>> -Parser +LevelParser -- Functions: vector<struct> Parse(); @@ -60,7 +60,7 @@ const int FileVersion; com.umlet.element.Class 624 - 208 + 248 80 24 @@ -72,7 +72,7 @@ const int FileVersion; com.umlet.element.Relation 640 - 208 + 248 40 168 @@ -83,7 +83,7 @@ const int FileVersion; com.umlet.element.Relation 384 - 176 + 216 256 56 @@ -97,7 +97,7 @@ m2=1..1 com.umlet.element.Package 248 - 320 + 360 248 160 @@ -108,7 +108,7 @@ m2=1..1 com.umlet.element.Class 800 - 360 + 400 208 136 @@ -127,7 +127,7 @@ Privates: com.umlet.element.Class 328 - 208 + 248 80 24 @@ -138,11 +138,11 @@ Privates: com.umlet.element.Class 256 - 360 + 400 232 104 - Defines.h + ObjectDefines.h <<Header file>> -- Enum ObjectType(static, dynamic, specials); @@ -156,7 +156,7 @@ Struct specials com.umlet.element.Relation 680 - 176 + 216 152 56 @@ -170,7 +170,7 @@ Uses> com.umlet.element.Class 816 - 192 + 232 128 40 @@ -182,7 +182,7 @@ Uses> com.umlet.element.Class 928 - 560 + 600 200 120 @@ -196,7 +196,7 @@ functions for creating the right structs com.umlet.element.Relation 768 - 576 + 616 176 56 @@ -210,7 +210,7 @@ Uses> com.umlet.element.Class 560 - 360 + 400 232 136 @@ -230,7 +230,7 @@ Privates: com.umlet.element.Relation 344 - 208 + 248 40 168 @@ -241,7 +241,7 @@ Privates: com.umlet.element.Relation 840 - 208 + 248 88 168 @@ -253,7 +253,7 @@ Privates: com.umlet.element.Relation 656 - 472 + 512 40 88 @@ -264,7 +264,7 @@ Privates: com.umlet.element.Relation 544 - 64 + 104 136 160 diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 6b66a9d5..da052b70 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -185,6 +185,8 @@ + + @@ -202,6 +204,7 @@ + diff --git a/Code/Game/GameLogic/LevelParser.cpp b/Code/Game/GameLogic/LevelParser.cpp new file mode 100644 index 00000000..65b63aef --- /dev/null +++ b/Code/Game/GameLogic/LevelParser.cpp @@ -0,0 +1,2 @@ +#include "LevelParser.h" + diff --git a/Code/Game/GameLogic/LevelParser.h b/Code/Game/GameLogic/LevelParser.h new file mode 100644 index 00000000..f1904d9c --- /dev/null +++ b/Code/Game/GameLogic/LevelParser.h @@ -0,0 +1,28 @@ +#ifndef LEVEL_PARSER_H +#define LEVEL_PARSER_H + +#include +#include "ObjectDefines.h" + +namespace GameLogic +{ + namespace LevelLoader + { + class LevelParser + { + public: + LevelParser(); + ~LevelParser(); + + // + std::vector Parse(); + + // + ObjectTypeHeader ParseHeader(); + + private: + + }; + } +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/ObjectDefines.h b/Code/Game/GameLogic/ObjectDefines.h new file mode 100644 index 00000000..74bca42c --- /dev/null +++ b/Code/Game/GameLogic/ObjectDefines.h @@ -0,0 +1,38 @@ +#ifndef OBJECT_DEFINES_H +#define OBJECT_DEFINES_H + +namespace GameLogic +{ + enum ObjectType + { + ObjectType_Static, + ObjectType_Dynamic, + + + ObjectType_NUM_OF_TYPES, + + ObjectType_Unknow = -1, + }; + + struct ObjectTypeHeader + { + ObjectType typeID; + + }; + + struct ObjectHeader : public ObjectTypeHeader + { + //Model, + + //Texture + + //Position + float position[3]; + //Rotation + float rotation[3]; + //Scale + float scale[3]; + }; +} + +#endif \ No newline at end of file From aaf3bf30f9a19644dc6480cbcc3d0097dec073fd Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Fri, 24 Jan 2014 10:01:58 +0100 Subject: [PATCH 2/2] GL - LevelParser half way implemented. --- Code/Game/GameLogic/LevelParser.cpp | 80 +++++++++++++++++++++++++++++ Code/Game/GameLogic/LevelParser.h | 27 +++++++++- Code/Game/GameLogic/ObjectDefines.h | 3 +- 3 files changed, 107 insertions(+), 3 deletions(-) diff --git a/Code/Game/GameLogic/LevelParser.cpp b/Code/Game/GameLogic/LevelParser.cpp index 65b63aef..21e6c020 100644 --- a/Code/Game/GameLogic/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelParser.cpp @@ -1,2 +1,82 @@ #include "LevelParser.h" +using namespace GameLogic; +using namespace ::LevelLoader; + +LevelParser::LevelParser() +{ +} + +LevelParser::~LevelParser() +{ +} + +// +std::vector LevelParser::Parse(std::string filename) +{ + //Read entire level file. + + std::vector objects; + + unsigned int counter = 0; + unsigned int stringSize = 0; + while(counter < stringSize) + { + //Get typeID + int typeID = 0; + + + switch(typeID) + { + case TypeID_LevelHeader: + //Call function + counter += LevelHeaderSize; + break; + + case TypeID_Object: + //Call function + counter += ObjectHeaderSize; + break; + default: + //Couldn't find typeID. FAIL!!!!!! + break; + } + } + + return objects; +} + +// +ObjectTypeHeader LevelParser::ParseHeader(std::string filename) +{ + //Read entire level file. + + //Find the header in the returned string. + unsigned int counter = 0; + unsigned int stringSize = 0; + + ObjectTypeHeader header; + header.typeID = ObjectType_Level; + + while(counter < stringSize) + { + int typeID = 0; + switch(typeID) + { + case TypeID_LevelHeader: + //Call function + + break; + case TypeID_Object: + //Call function + counter += ObjectHeaderSize; + break; + + default: + //Couldn't find typeID. FAIL!!!!!! + break; + } + } + + return header; +} \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelParser.h b/Code/Game/GameLogic/LevelParser.h index f1904d9c..f261004b 100644 --- a/Code/Game/GameLogic/LevelParser.h +++ b/Code/Game/GameLogic/LevelParser.h @@ -1,6 +1,7 @@ #ifndef LEVEL_PARSER_H #define LEVEL_PARSER_H +#include #include #include "ObjectDefines.h" @@ -15,12 +16,34 @@ namespace GameLogic ~LevelParser(); // - std::vector Parse(); + std::vector Parse(std::string filename); // - ObjectTypeHeader ParseHeader(); + ObjectTypeHeader ParseHeader(std::string filename); private: + static const int TypeHeaderSize = 4; //Including the TypeID + static const int ObjectHeaderSize = 10; //Including modelID, textureID, position, rotation, scale. + static const int LevelHeaderSize = 10; //Including Format version, Name, Map version etc. + + static const int FormatVersionMajor = 1; + static const int FormatVersionMinor = 0; + + /************************************* + Question + *************************************/ + //Could we use the IDs in "ObjectDefines.h" or do we have to use our own??? + enum TypeID + { + TypeID_LevelHeader, + TypeID_Player, + TypeID_Object, + + + TypeID_NUM_OF_TYPES, + + ObjectType_Unknown = -1, + }; }; } diff --git a/Code/Game/GameLogic/ObjectDefines.h b/Code/Game/GameLogic/ObjectDefines.h index 74bca42c..eae1b0c9 100644 --- a/Code/Game/GameLogic/ObjectDefines.h +++ b/Code/Game/GameLogic/ObjectDefines.h @@ -5,13 +5,14 @@ namespace GameLogic { enum ObjectType { + ObjectType_Level, ObjectType_Static, ObjectType_Dynamic, ObjectType_NUM_OF_TYPES, - ObjectType_Unknow = -1, + ObjectType_Unknown = -1, }; struct ObjectTypeHeader