Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-10 15:54:46 +01:00
commit a12146215d
3 changed files with 28 additions and 38 deletions

View File

@ -123,6 +123,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
break; break;
} }
default: default:
//Couldn't find specialType //Couldn't find specialType
break; break;

View File

@ -138,14 +138,18 @@ namespace GameLogic
struct BoundingVolumeBase struct BoundingVolumeBase
{ {
CollisionGeometryType geoType;
float position[3]; float position[3];
float rotation[4];
float frictionCoeffStatic;
float frictionCoeffDynamic;
float restitutionCoeff;
float mass;
}; };
struct BoundingVolumeBox : public BoundingVolumeBase struct BoundingVolumeBox : public BoundingVolumeBase
{ {
float size[3]; float size[3];
float angularAxis[3];
float angle;
}; };
struct BoundingVolumeSphere : public BoundingVolumeBase struct BoundingVolumeSphere : public BoundingVolumeBase
@ -156,8 +160,6 @@ namespace GameLogic
struct BoundingVolumeCylinder : public BoundingVolumeBase struct BoundingVolumeCylinder : public BoundingVolumeBase
{ {
float length; float length;
float angularAxis[3];
float angle;
float radius; float radius;
}; };
@ -172,17 +174,6 @@ namespace GameLogic
}; };
}; };
struct PhysicsObject
{
UsePhysics usePhysics;
float mass;
float inertiaMagnitude[3];
float inertiaRotation[3];
float frictionCoeffStatic;
float frictionCoeffDynamic;
float restitutionCoeff;
BoundingVolume boundingVolume;
};
} }
struct LevelMetaData : public ObjectTypeHeader struct LevelMetaData : public ObjectTypeHeader
@ -200,7 +191,7 @@ namespace GameLogic
}; };
struct ObjectHeader : public ObjectTypeHeader, public LevelLoaderInternal::PhysicsObject struct ObjectHeader : public ObjectTypeHeader
{ {
//Special type id for special objects: portal, jumppad, exploding objects, etc. //Special type id for special objects: portal, jumppad, exploding objects, etc.
ObjectSpecialType specialTypeID; ObjectSpecialType specialTypeID;
@ -208,12 +199,13 @@ namespace GameLogic
std::string ModelFile; std::string ModelFile;
//Position //Position
float position[3]; float position[3];
//Rotation //Rotation Quaternion
float rotation[3]; float rotation[4];
float angle;
//Scale //Scale
float scale[3]; float scale[3];
::GameLogic::LevelLoaderInternal::BoundingVolume boundingVolume;
virtual ~ObjectHeader(){} virtual ~ObjectHeader(){}
}; };

View File

@ -45,11 +45,6 @@ namespace GameLogic
memcpy(&header.position, &buffer[start], 40); memcpy(&header.position, &buffer[start], 40);
start += 40; start += 40;
//Physics struct
//2 float[3], 4 float, 1 uint
memcpy(&header.usePhysics, &buffer[start], 44);
start += 44;
//Read path for bounding volume //Read path for bounding volume
ParseBoundingVolume(&buffer[start], header.boundingVolume, start); ParseBoundingVolume(&buffer[start], header.boundingVolume, start);
@ -132,39 +127,41 @@ namespace GameLogic
fileName.assign(&tempName[0], &tempName[tempSize]); fileName.assign(&tempName[0], &tempName[tempSize]);
start += tempSize; start += tempSize;
size += start;
//Läs in filen. //Läs in filen.
int fileLength = 0; int fileLength = 0;
Loader loader; Loader loader;
char* buf = loader.LoadFile("E:\\Dropbox\\Programming\\Github\\Danbias\\Bin\\Content\\Worlds\\cgf\\"+ fileName, fileLength); char* buf = loader.LoadFile("E:\\Dropbox\\Programming\\Github\\Danbias\\Bin\\Content\\Worlds\\cgf\\"+ fileName, fileLength);
start = 0;
LevelLoaderInternal::FormatVersion version; LevelLoaderInternal::FormatVersion version;
memcpy(&version, &buffer[0], sizeof(version)); memcpy(&version, &buf[0], sizeof(version));
start += 4;
memcpy(&volume.geoType, &buf[8], sizeof(volume.geoType)); memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
//start += sizeof(volume.geoType); start += sizeof(volume.geoType);
switch(volume.geoType) switch(volume.geoType)
{ {
case CollisionGeometryType_Box: case CollisionGeometryType_Box:
memcpy(&volume.box, &buf[12], sizeof(volume.box)); memcpy(&volume.box, &buf[start], sizeof(volume.box));
//start += sizeof(volume.box); start += sizeof(volume.box);
break; break;
case CollisionGeometryType_Sphere: case CollisionGeometryType_Sphere:
memcpy(&volume.sphere, &buf[12], sizeof(volume.sphere)); memcpy(&volume.sphere, &buf[start], sizeof(volume.sphere));
//start += sizeof(volume.sphere); start += sizeof(volume.sphere);
break; break;
case CollisionGeometryType_Cylinder: case CollisionGeometryType_Cylinder:
memcpy(&volume.cylinder, &buf[12], sizeof(volume.cylinder)); memcpy(&volume.cylinder, &buf[start], sizeof(volume.cylinder));
//start += sizeof(volume.cylinder); start += sizeof(volume.cylinder);
break; break;
default: default:
break; break;
} }
size += start;
} }
} }
} }