GL - Updated loadLevelHeader() .Added Cylinder bounding volume.
This commit is contained in:
parent
fef40f58f9
commit
0c4f70e400
|
@ -1,3 +1,7 @@
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Created by Pontus Fransson 2013 //
|
||||||
|
/////////////////////////////////////
|
||||||
|
|
||||||
#include "LevelParser.h"
|
#include "LevelParser.h"
|
||||||
|
|
||||||
#include "Loader.h"
|
#include "Loader.h"
|
||||||
|
@ -208,10 +212,10 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
||||||
//Find the header in the returned string.
|
//Find the header in the returned string.
|
||||||
while(counter < bufferSize)
|
while(counter < bufferSize)
|
||||||
{
|
{
|
||||||
ObjectTypeHeader typeID;
|
ObjectType typeID;
|
||||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||||
|
|
||||||
switch(typeID.typeID)
|
switch(typeID)
|
||||||
{
|
{
|
||||||
case ObjectType_LevelMetaData:
|
case ObjectType_LevelMetaData:
|
||||||
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
|
||||||
|
@ -223,6 +227,24 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
||||||
{
|
{
|
||||||
ObjectHeader header;
|
ObjectHeader header;
|
||||||
ParseObject(&buffer[counter], header, counter);
|
ParseObject(&buffer[counter], header, counter);
|
||||||
|
|
||||||
|
switch(header.specialTypeID)
|
||||||
|
{
|
||||||
|
case ObjectSpecialType_JumpPad:
|
||||||
|
counter += sizeof(16);
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_BoostPad:
|
||||||
|
counter += sizeof(16);
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_Portal:
|
||||||
|
counter += sizeof(12);
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType_SpawnPoint:
|
||||||
|
counter += sizeof(12);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace GameLogic
|
||||||
|
|
||||||
enum ObjectSpecialType
|
enum ObjectSpecialType
|
||||||
{
|
{
|
||||||
ObjectSpecialType_World,
|
ObjectSpecialType_World, //Always the main celestial body
|
||||||
ObjectSpecialType_Building,
|
ObjectSpecialType_Building,
|
||||||
ObjectSpecialType_Damaging,
|
ObjectSpecialType_Damaging,
|
||||||
ObjectSpecialType_Explosive,
|
ObjectSpecialType_Explosive,
|
||||||
|
@ -53,6 +53,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
CollisionGeometryType_Box,
|
CollisionGeometryType_Box,
|
||||||
CollisionGeometryType_Sphere,
|
CollisionGeometryType_Sphere,
|
||||||
|
CollisionGeometryType_Cylinder,
|
||||||
|
|
||||||
CollisionGeometryType_Count,
|
CollisionGeometryType_Count,
|
||||||
CollisionGeometryType_Unknown = -1
|
CollisionGeometryType_Unknown = -1
|
||||||
|
@ -152,6 +153,14 @@ namespace GameLogic
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BoundingVolumeCylinder : public BoundingVolumeBase
|
||||||
|
{
|
||||||
|
float length;
|
||||||
|
float angularAxis[3];
|
||||||
|
float angle;
|
||||||
|
float radius;
|
||||||
|
};
|
||||||
|
|
||||||
struct BoundingVolume
|
struct BoundingVolume
|
||||||
{
|
{
|
||||||
CollisionGeometryType geoType;
|
CollisionGeometryType geoType;
|
||||||
|
@ -159,6 +168,7 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
LevelLoaderInternal::BoundingVolumeBox box;
|
LevelLoaderInternal::BoundingVolumeBox box;
|
||||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
||||||
|
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,10 +152,16 @@ namespace GameLogic
|
||||||
|
|
||||||
case CollisionGeometryType_Sphere:
|
case CollisionGeometryType_Sphere:
|
||||||
memcpy(&volume.sphere, &buf[12], sizeof(volume.sphere));
|
memcpy(&volume.sphere, &buf[12], sizeof(volume.sphere));
|
||||||
int a = sizeof(volume.sphere);
|
|
||||||
a = 5;
|
|
||||||
//start += sizeof(volume.sphere);
|
//start += sizeof(volume.sphere);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CollisionGeometryType_Cylinder:
|
||||||
|
memcpy(&volume.cylinder, &buf[12], sizeof(volume.cylinder));
|
||||||
|
//start += sizeof(volume.cylinder);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
size += start;
|
size += start;
|
||||||
|
|
Loading…
Reference in New Issue