Danbias/Code/Game/LevelLoader/ObjectDefines.h

308 lines
5.8 KiB
C
Raw Normal View History

#ifndef OBJECT_DEFINES_H
#define OBJECT_DEFINES_H
#include <string>
#include <vector>
namespace GameLogic
{
/************************************
Enums
*************************************/
2014-02-12 14:48:58 +01:00
enum ObjectType
{
ObjectType_LevelMetaData,
ObjectType_Static,
ObjectType_Dynamic,
ObjectType_Light,
ObjectType_SpawnPoint,
//Etc
ObjectType_NUM_OF_TYPES,
ObjectType_Unknown = -1
};
2014-02-12 14:48:58 +01:00
enum ObjectSpecialType
{
2014-02-12 14:48:58 +01:00
ObjectSpecialType_None,
ObjectSpecialType_Sky,
ObjectSpecialType_World, //Always the main celestial body
ObjectSpecialType_Building,
ObjectSpecialType_Stone,
ObjectSpecialType_StandardBox,
2014-02-12 14:48:58 +01:00
ObjectSpecialType_RedExplosiveBox,
ObjectSpecialType_SpikeBox,
ObjectSpecialType_Spike,
ObjectSpecialType_CrystalFormation,
ObjectSpecialType_CrystalShard,
ObjectSpecialType_JumpPad,
ObjectSpecialType_Portal,
ObjectSpecialType_Player,
ObjectSpecialType_Generic,
2014-02-12 14:48:58 +01:00
2014-02-25 14:36:54 +01:00
ObjectSpecialType_PickupHealth,
2014-02-12 14:48:58 +01:00
ObjectSpecialType_Count,
ObjectSpecialType_Unknown = -1
};
enum CollisionGeometryType
{
CollisionGeometryType_Box,
CollisionGeometryType_Sphere,
2014-02-12 14:48:58 +01:00
CollisionGeometryType_Cylinder,
CollisionGeometryType_CG_MESH,
CollisionGeometryType_Count,
CollisionGeometryType_Unknown = -1
};
2014-02-12 14:48:58 +01:00
//Only supports Pointlight right now.
enum LightType
{
LightType_PointLight,
2014-02-12 14:48:58 +01:00
//LightType_DirectionalLight,
//LightType_SpotLight,
LightType_Count,
LightType_Unknown = -1
};
//Should this be moved somewhere else?
enum GameMode
{
GameMode_FreeForAll,
GameMode_TeamDeathMatch,
//Etc
GameMode_Count,
GameMode_Unknown = -1
};
enum WorldSize
{
WorldSize_Tiny,
WorldSize_Small,
WorldSize_Medium,
WorldSize_Big,
WorldSize_Humongous,
WorldSize_Count,
WorldSize_Unknown = -1
};
enum PlayerAction
{
PlayerAction_Jump,
PlayerAction_Walk,
PlayerAction_Idle,
};
2014-02-26 08:51:56 +01:00
enum WeaponAction
{
WeaponAtcion_PrimaryShoot,
WeaponAction_SecondaryShoot
};
enum PickupType
{
PickupType_Health,
PickupType_SpeedBoost
};
/************************************
Structs
*************************************/
2014-02-12 14:48:58 +01:00
namespace LevelLoaderInternal
{
2014-02-12 14:48:58 +01:00
struct FormatVersion
{
2014-02-12 14:48:58 +01:00
unsigned int formatVersionMajor;
unsigned int formatVersionMinor;
FormatVersion()
: formatVersionMajor(0), formatVersionMinor(0)
{}
2014-02-12 14:48:58 +01:00
FormatVersion(unsigned int major, unsigned int minor)
: formatVersionMajor(major), formatVersionMinor(minor)
{}
bool operator ==(const FormatVersion& obj)
{
return (this->formatVersionMajor == obj.formatVersionMajor && this->formatVersionMinor == obj.formatVersionMinor);
}
bool operator !=(const FormatVersion& obj)
{
return !(*this == obj);
}
};
}
struct ObjectTypeHeader
{
ObjectType typeID;
2014-02-12 14:48:58 +01:00
//Unless this is here the object destructor wont be called.
virtual ~ObjectTypeHeader(){}
};
2014-02-12 14:48:58 +01:00
namespace LevelLoaderInternal
{
2014-02-12 14:48:58 +01:00
const FormatVersion boundingVolumeVersion(2, 0);
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];
};
struct BoundingVolumeSphere : public BoundingVolumeBase
{
float radius;
};
struct BoundingVolumeCylinder : public BoundingVolumeBase
{
float length;
float radius;
};
struct BoundingVolumeCGMesh : public BoundingVolumeBase
{
wchar_t filename[128];
};
2014-02-12 14:48:58 +01:00
struct BoundingVolume
{
CollisionGeometryType geoType;
union
{
LevelLoaderInternal::BoundingVolumeBox box;
LevelLoaderInternal::BoundingVolumeSphere sphere;
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
LevelLoaderInternal::BoundingVolumeCGMesh cgMesh;
2014-02-12 14:48:58 +01:00
};
};
}
struct LevelMetaData : public ObjectTypeHeader
{
std::string levelName;
unsigned int levelVersion;
std::string levelDescription;
std::string levelAuthor;
unsigned int maxNumberOfPlayer;
WorldSize worldSize;
std::string overviewPicturePath;
std::vector<GameMode> gameModesSupported;
2014-02-12 14:48:58 +01:00
virtual ~LevelMetaData(){}
};
2014-02-12 14:48:58 +01:00
struct ObjectHeader : public ObjectTypeHeader
{
2014-02-12 14:48:58 +01:00
//Special type id for special objects: portal, jumppad, exploding objects, etc.
ObjectSpecialType specialTypeID;
//Model,
std::string ModelFile;
//Position
float position[3];
2014-02-12 14:48:58 +01:00
//Rotation Quaternion
float rotation[4];
//Scale
float scale[3];
2014-02-12 14:48:58 +01:00
::GameLogic::LevelLoaderInternal::BoundingVolume boundingVolume;
virtual ~ObjectHeader(){}
};
//inheritance from the base class because there is no use for ModelFile, Rotation and Scale
//so this is a special struct for just spawnpoints
struct SpawnPointAttributes : public ObjectTypeHeader
{
float position[3];
};
2014-02-12 14:48:58 +01:00
/************************************
Special objects
*************************************/
struct JumpPadAttributes : public ObjectHeader
{
float direction[3];
float power;
};
struct PortalAttributes : public ObjectHeader
{
float destination[3];
};
struct WorldAttributes : public ObjectHeader
{
float worldSize;
float atmoSphereSize;
};
struct SkyAttributes : public ObjectHeader
{
float skySize;
};
struct PickupHealthAttributes : public ObjectHeader
{
float spawnTime;
float healthValue;
};
/************************************
Lights
*************************************/
struct BasicLight : public ObjectTypeHeader
{
2014-02-12 14:48:58 +01:00
LightType lightType; //Is not used right now
float color[3];
float position[3];
float radius;
2014-02-12 14:48:58 +01:00
float intensity;
virtual ~BasicLight(){}
};
2014-02-12 14:48:58 +01:00
/* We only support pointlight right now.
struct PointLight : public BasicLight
{
float position[3];
};
struct DirectionalLight : public BasicLight
{
float direction[3];
};
struct SpotLight : public BasicLight
{
float direction[3];
float range;
float attenuation[3];
2014-02-12 14:48:58 +01:00
};*/
}
#endif