GL - Updated LevelLoader, works with Fredricks level editor.

This commit is contained in:
Pontus Fransson 2014-02-05 15:46:45 +01:00
parent ac278555ea
commit b39a670347
3 changed files with 42 additions and 12 deletions

View File

@ -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()

View File

@ -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<GameMode> 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];
};

View File

@ -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);