GL - Updated loadLevelHeader() .Added Cylinder bounding volume.

This commit is contained in:
Pontus Fransson 2014-02-07 15:20:34 +01:00
parent fef40f58f9
commit 0c4f70e400
3 changed files with 43 additions and 5 deletions

View File

@ -1,3 +1,7 @@
/////////////////////////////////////
// Created by Pontus Fransson 2013 //
/////////////////////////////////////
#include "LevelParser.h"
#include "Loader.h"
@ -208,10 +212,10 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
//Find the header in the returned string.
while(counter < bufferSize)
{
ObjectTypeHeader typeID;
ObjectType typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch(typeID.typeID)
switch(typeID)
{
case ObjectType_LevelMetaData:
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
@ -223,6 +227,24 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
{
ObjectHeader header;
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;
}

View File

@ -25,7 +25,7 @@ namespace GameLogic
enum ObjectSpecialType
{
ObjectSpecialType_World,
ObjectSpecialType_World, //Always the main celestial body
ObjectSpecialType_Building,
ObjectSpecialType_Damaging,
ObjectSpecialType_Explosive,
@ -53,6 +53,7 @@ namespace GameLogic
{
CollisionGeometryType_Box,
CollisionGeometryType_Sphere,
CollisionGeometryType_Cylinder,
CollisionGeometryType_Count,
CollisionGeometryType_Unknown = -1
@ -152,6 +153,14 @@ namespace GameLogic
float radius;
};
struct BoundingVolumeCylinder : public BoundingVolumeBase
{
float length;
float angularAxis[3];
float angle;
float radius;
};
struct BoundingVolume
{
CollisionGeometryType geoType;
@ -159,6 +168,7 @@ namespace GameLogic
{
LevelLoaderInternal::BoundingVolumeBox box;
LevelLoaderInternal::BoundingVolumeSphere sphere;
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
};
};

View File

@ -152,10 +152,16 @@ namespace GameLogic
case CollisionGeometryType_Sphere:
memcpy(&volume.sphere, &buf[12], sizeof(volume.sphere));
int a = sizeof(volume.sphere);
a = 5;
//start += sizeof(volume.sphere);
break;
case CollisionGeometryType_Cylinder:
memcpy(&volume.cylinder, &buf[12], sizeof(volume.cylinder));
//start += sizeof(volume.cylinder);
break;
default:
break;
}
size += start;