Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
81d43b59c0
|
@ -4,17 +4,20 @@
|
||||||
|
|
||||||
#include "LevelLoader.h"
|
#include "LevelLoader.h"
|
||||||
#include "LevelParser.h"
|
#include "LevelParser.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace GameLogic::LevelFileLoader;
|
using namespace GameLogic::LevelFileLoader;
|
||||||
|
|
||||||
struct LevelLoader::PrivData
|
struct LevelLoader::PrivData
|
||||||
{
|
{
|
||||||
LevelParser parser;
|
LevelParser parser;
|
||||||
|
std::string folderPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelLoader::LevelLoader()
|
LevelLoader::LevelLoader()
|
||||||
: pData(new PrivData)
|
: pData(new PrivData)
|
||||||
{
|
{
|
||||||
|
pData->folderPath = "Standard path";
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelLoader::~LevelLoader()
|
LevelLoader::~LevelLoader()
|
||||||
|
|
|
@ -34,6 +34,15 @@ namespace GameLogic
|
||||||
UsePhysics_Unknown = -1
|
UsePhysics_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CollisionGeometryType
|
||||||
|
{
|
||||||
|
CollisionGeometryType_Box,
|
||||||
|
CollisionGeometryType_Sphere,
|
||||||
|
|
||||||
|
CollisionGeometryType_Count,
|
||||||
|
CollisionGeometryType_Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
enum LightType
|
enum LightType
|
||||||
{
|
{
|
||||||
LightType_PointLight,
|
LightType_PointLight,
|
||||||
|
@ -55,6 +64,18 @@ namespace GameLogic
|
||||||
GameMode_Unknown = -1
|
GameMode_Unknown = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum WorldSize
|
||||||
|
{
|
||||||
|
WorldSize_Tiny,
|
||||||
|
WorldSize_Small,
|
||||||
|
WorldSize_Medium,
|
||||||
|
WorldSize_Big,
|
||||||
|
WorldSize_Humongous,
|
||||||
|
|
||||||
|
WorldSize_Count,
|
||||||
|
WorldSize_Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
Structs
|
Structs
|
||||||
|
@ -62,8 +83,8 @@ namespace GameLogic
|
||||||
|
|
||||||
struct FormatVersion
|
struct FormatVersion
|
||||||
{
|
{
|
||||||
int formatVersionMajor;
|
unsigned int formatVersionMajor;
|
||||||
int formatVersionMinor;
|
unsigned int formatVersionMinor;
|
||||||
|
|
||||||
bool operator ==(const FormatVersion& obj)
|
bool operator ==(const FormatVersion& obj)
|
||||||
{
|
{
|
||||||
|
@ -89,22 +110,22 @@ namespace GameLogic
|
||||||
float inertiaRotation[3];
|
float inertiaRotation[3];
|
||||||
float frictionCoeffStatic;
|
float frictionCoeffStatic;
|
||||||
float frictionCoeffDynamic;
|
float frictionCoeffDynamic;
|
||||||
|
CollisionGeometryType geometryType;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LevelMetaData : ObjectTypeHeader
|
struct LevelMetaData : public ObjectTypeHeader
|
||||||
{
|
{
|
||||||
std::string levelName;
|
std::string levelName;
|
||||||
int levelVersion;
|
unsigned int levelVersion;
|
||||||
std::string levelDescription;
|
std::string levelDescription;
|
||||||
std::string levelAuthor;
|
std::string levelAuthor;
|
||||||
int maxNumberOfPlayer;
|
unsigned int maxNumberOfPlayer;
|
||||||
int worldSize;
|
WorldSize worldSize;
|
||||||
std::string overviewPicturePath;
|
std::string overviewPicturePath;
|
||||||
std::vector<GameMode> gameModesSupported;
|
std::vector<GameMode> gameModesSupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObjectHeader : public ObjectTypeHeader
|
struct ObjectHeader : public ObjectTypeHeader, public PhysicsObject
|
||||||
{
|
{
|
||||||
//Model,
|
//Model,
|
||||||
std::string ModelFile;
|
std::string ModelFile;
|
||||||
|
@ -112,6 +133,7 @@ namespace GameLogic
|
||||||
float position[3];
|
float position[3];
|
||||||
//Rotation
|
//Rotation
|
||||||
float rotation[3];
|
float rotation[3];
|
||||||
|
float angle;
|
||||||
//Scale
|
//Scale
|
||||||
float scale[3];
|
float scale[3];
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace GameLogic
|
||||||
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
||||||
{
|
{
|
||||||
char tempName[128];
|
char tempName[128];
|
||||||
int tempSize = 0;
|
unsigned int tempSize = 0;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
|
|
||||||
memcpy(&header.typeID, &buffer[start], 4);
|
memcpy(&header.typeID, &buffer[start], 4);
|
||||||
|
@ -36,8 +36,13 @@ namespace GameLogic
|
||||||
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
||||||
start += tempSize;
|
start += tempSize;
|
||||||
|
|
||||||
memcpy(&header.position, &buffer[start], 36);
|
//3 float[3], 1 float
|
||||||
start += 36;
|
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;
|
size += start;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +50,7 @@ namespace GameLogic
|
||||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
||||||
{
|
{
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int tempSize;
|
unsigned int tempSize;
|
||||||
char tempName[128];
|
char tempName[128];
|
||||||
|
|
||||||
memcpy(&header.typeID, &buffer[start], 4);
|
memcpy(&header.typeID, &buffer[start], 4);
|
||||||
|
|
Loading…
Reference in New Issue