From 0c4f70e400a88023513505e59f25debc25a9ad6e Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Fri, 7 Feb 2014 15:20:34 +0100 Subject: [PATCH] GL - Updated loadLevelHeader() .Added Cylinder bounding volume. --- .../GameLogic/LevelLoader/LevelParser.cpp | 26 +++++++++++++++++-- .../GameLogic/LevelLoader/ObjectDefines.h | 12 ++++++++- .../GameLogic/LevelLoader/ParseFunctions.cpp | 10 +++++-- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index 667633f9..33567cc9 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -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; } diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index ff18553d..d87e42b2 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -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; }; }; diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index baae678d..e8c055b3 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -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;