Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
a12146215d
|
@ -123,6 +123,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
//Couldn't find specialType
|
||||
break;
|
||||
|
|
|
@ -138,14 +138,18 @@ namespace GameLogic
|
|||
|
||||
struct BoundingVolumeBase
|
||||
{
|
||||
CollisionGeometryType geoType;
|
||||
float position[3];
|
||||
float rotation[4];
|
||||
float frictionCoeffStatic;
|
||||
float frictionCoeffDynamic;
|
||||
float restitutionCoeff;
|
||||
float mass;
|
||||
};
|
||||
|
||||
struct BoundingVolumeBox : public BoundingVolumeBase
|
||||
{
|
||||
float size[3];
|
||||
float angularAxis[3];
|
||||
float angle;
|
||||
};
|
||||
|
||||
struct BoundingVolumeSphere : public BoundingVolumeBase
|
||||
|
@ -156,8 +160,6 @@ namespace GameLogic
|
|||
struct BoundingVolumeCylinder : public BoundingVolumeBase
|
||||
{
|
||||
float length;
|
||||
float angularAxis[3];
|
||||
float angle;
|
||||
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
|
||||
|
@ -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.
|
||||
ObjectSpecialType specialTypeID;
|
||||
|
@ -208,12 +199,13 @@ namespace GameLogic
|
|||
std::string ModelFile;
|
||||
//Position
|
||||
float position[3];
|
||||
//Rotation
|
||||
float rotation[3];
|
||||
float angle;
|
||||
//Rotation Quaternion
|
||||
float rotation[4];
|
||||
//Scale
|
||||
float scale[3];
|
||||
|
||||
::GameLogic::LevelLoaderInternal::BoundingVolume boundingVolume;
|
||||
|
||||
virtual ~ObjectHeader(){}
|
||||
};
|
||||
|
||||
|
|
|
@ -44,11 +44,6 @@ namespace GameLogic
|
|||
//3 float[3], 1 float
|
||||
memcpy(&header.position, &buffer[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
|
||||
ParseBoundingVolume(&buffer[start], header.boundingVolume, start);
|
||||
|
@ -122,7 +117,7 @@ namespace GameLogic
|
|||
int start = 0;
|
||||
int tempSize = 0;
|
||||
char tempName[128];
|
||||
|
||||
|
||||
memcpy(&tempSize, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
|
@ -132,39 +127,41 @@ namespace GameLogic
|
|||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
||||
start += tempSize;
|
||||
|
||||
size += start;
|
||||
|
||||
//Läs in filen.
|
||||
int fileLength = 0;
|
||||
Loader loader;
|
||||
char* buf = loader.LoadFile("E:\\Dropbox\\Programming\\Github\\Danbias\\Bin\\Content\\Worlds\\cgf\\"+ fileName, fileLength);
|
||||
|
||||
LevelLoaderInternal::FormatVersion version;
|
||||
memcpy(&version, &buffer[0], sizeof(version));
|
||||
|
||||
memcpy(&volume.geoType, &buf[8], sizeof(volume.geoType));
|
||||
//start += sizeof(volume.geoType);
|
||||
start = 0;
|
||||
LevelLoaderInternal::FormatVersion version;
|
||||
memcpy(&version, &buf[0], sizeof(version));
|
||||
start += 4;
|
||||
|
||||
memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
|
||||
start += sizeof(volume.geoType);
|
||||
|
||||
switch(volume.geoType)
|
||||
{
|
||||
case CollisionGeometryType_Box:
|
||||
memcpy(&volume.box, &buf[12], sizeof(volume.box));
|
||||
//start += sizeof(volume.box);
|
||||
memcpy(&volume.box, &buf[start], sizeof(volume.box));
|
||||
start += sizeof(volume.box);
|
||||
break;
|
||||
|
||||
case CollisionGeometryType_Sphere:
|
||||
memcpy(&volume.sphere, &buf[12], sizeof(volume.sphere));
|
||||
//start += sizeof(volume.sphere);
|
||||
memcpy(&volume.sphere, &buf[start], sizeof(volume.sphere));
|
||||
start += sizeof(volume.sphere);
|
||||
break;
|
||||
|
||||
case CollisionGeometryType_Cylinder:
|
||||
memcpy(&volume.cylinder, &buf[12], sizeof(volume.cylinder));
|
||||
//start += sizeof(volume.cylinder);
|
||||
memcpy(&volume.cylinder, &buf[start], sizeof(volume.cylinder));
|
||||
start += sizeof(volume.cylinder);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
size += start;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue