Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
7a218c61d8
|
@ -4,7 +4,9 @@
|
|||
#include "NetworkClient.h"
|
||||
#include "Camera.h"
|
||||
#include <GameServerAPI.h>
|
||||
#include "LevelLoader\ObjectDefines.h"
|
||||
|
||||
using namespace GameLogic;
|
||||
using namespace DanBias::Client;
|
||||
using namespace Oyster::Math;
|
||||
struct GameState::myData
|
||||
|
@ -78,7 +80,7 @@ GameState::gameStateState GameState::LoadGame()
|
|||
//LoadModels("3bana.bias");
|
||||
|
||||
// hardcoded objects
|
||||
LoadModels();
|
||||
LoadModels("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias");
|
||||
Float3 startPos = Float3(0,0,20.0f);
|
||||
InitCamera(startPos);
|
||||
return gameStateState_playing;
|
||||
|
@ -200,9 +202,9 @@ bool GameState::LoadModels(std::string mapFile)
|
|||
|
||||
modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end());
|
||||
modelData.visible = true;
|
||||
//modelData.position = ;
|
||||
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
||||
//modelData.scale = Oyster::Math::Float3(2,2,2);
|
||||
modelData.position = staticObjData->position;
|
||||
modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(staticObjData->rotation), staticObjData->rotation[3]);
|
||||
modelData.scale = staticObjData->scale;
|
||||
modelData.id = modelId++;
|
||||
|
||||
this->staticObjects.Push(new C_StaticObj());
|
||||
|
@ -212,11 +214,11 @@ bool GameState::LoadModels(std::string mapFile)
|
|||
case GameLogic::ObjectType::ObjectType_Dynamic:
|
||||
{
|
||||
GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj);
|
||||
//modelData.position = ;
|
||||
//modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
|
||||
//modelData.scale = Oyster::Math::Float3(2,2,2);
|
||||
modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end());
|
||||
modelData.visible = true;
|
||||
modelData.position = dynamicObjData->position;
|
||||
modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(dynamicObjData->rotation), dynamicObjData->rotation[3]);
|
||||
modelData.scale = dynamicObjData->scale;
|
||||
modelData.id = modelId++;
|
||||
|
||||
this->dynamicObjects.Push(new C_DynamicObj());
|
||||
|
@ -230,8 +232,8 @@ bool GameState::LoadModels(std::string mapFile)
|
|||
if(lightData->lightType == GameLogic::LightType_PointLight)
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = ((GameLogic::PointLight*)lightData)->position;
|
||||
plight.Color = lightData->diffuseColor;
|
||||
plight.Pos = ((GameLogic::BasicLight*)lightData)->position;
|
||||
plight.Color = lightData->color;
|
||||
plight.Radius = 100;
|
||||
plight.Bright = 0.9f;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
|
@ -561,6 +563,7 @@ void GameState::Protocol( ObjPos* pos )
|
|||
if(dynamicObjects[i]->GetId() == myId) // playerobj
|
||||
{
|
||||
|
||||
|
||||
Float3 pos = dynamicObjects[i]->getPos();
|
||||
Float3 up = dynamicObjects[i]->getWorld().v[1];
|
||||
Float3 objForward = dynamicObjects[i]->getWorld().v[2];
|
||||
|
|
|
@ -17,7 +17,14 @@ struct LevelLoader::PrivData
|
|||
LevelLoader::LevelLoader()
|
||||
: pData(new PrivData)
|
||||
{
|
||||
pData->folderPath = "Standard path";
|
||||
//standard path
|
||||
pData->folderPath = "";
|
||||
}
|
||||
|
||||
LevelLoader::LevelLoader(std::string folderPath)
|
||||
: pData(new PrivData)
|
||||
{
|
||||
pData->folderPath = folderPath;
|
||||
}
|
||||
|
||||
LevelLoader::~LevelLoader()
|
||||
|
@ -26,10 +33,20 @@ LevelLoader::~LevelLoader()
|
|||
|
||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
|
||||
{
|
||||
return pData->parser.Parse(fileName);
|
||||
return pData->parser.Parse(pData->folderPath + fileName);
|
||||
}
|
||||
|
||||
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
|
||||
{
|
||||
return pData->parser.ParseHeader(fileName);
|
||||
return pData->parser.ParseHeader(pData->folderPath + fileName);
|
||||
}
|
||||
|
||||
std::string LevelLoader::GetFolderPath()
|
||||
{
|
||||
return this->pData->folderPath;
|
||||
}
|
||||
|
||||
void LevelLoader::SetFolderPath(std::string folderPath)
|
||||
{
|
||||
|
||||
}
|
|
@ -17,11 +17,15 @@ namespace GameLogic
|
|||
|
||||
public:
|
||||
LevelLoader();
|
||||
/***********************************************************
|
||||
* Lets you set the standard folderpath for the levels
|
||||
********************************************************/
|
||||
LevelLoader(std::string folderPath);
|
||||
~LevelLoader();
|
||||
|
||||
/********************************************************
|
||||
* Loads the level and objects from file.
|
||||
* @param fileName: Path to the level-file that you want to load.
|
||||
* @param fileName: Path/name to the level-file that you want to load.
|
||||
* @return: Returns all structs with objects and information about the level.
|
||||
********************************************************/
|
||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
|
||||
|
@ -33,6 +37,16 @@ namespace GameLogic
|
|||
********************************************************/
|
||||
LevelMetaData LoadLevelHeader(std::string fileName); //.
|
||||
|
||||
/***********************************************************
|
||||
* @return: Returns the current standard folder path
|
||||
********************************************************/
|
||||
std::string GetFolderPath();
|
||||
|
||||
/***********************************************************
|
||||
* Sets the standard folder path
|
||||
********************************************************/
|
||||
void SetFolderPath(std::string folderPath);
|
||||
|
||||
private:
|
||||
struct PrivData;
|
||||
Utility::DynamicMemory::SmartPointer<PrivData> pData;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
/////////////////////////////////////
|
||||
// Created by Pontus Fransson 2013 //
|
||||
/////////////////////////////////////
|
||||
|
||||
#include "LevelParser.h"
|
||||
|
||||
#include "Loader.h"
|
||||
|
@ -9,7 +13,7 @@ using namespace Utility::DynamicMemory;
|
|||
|
||||
LevelParser::LevelParser()
|
||||
{
|
||||
formatVersion.formatVersionMajor = 1;
|
||||
formatVersion.formatVersionMajor = 3;
|
||||
formatVersion.formatVersionMinor = 0;
|
||||
}
|
||||
|
||||
|
@ -21,6 +25,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
{
|
||||
int bufferSize = 0;
|
||||
int counter = 0;
|
||||
bool loadCgf;
|
||||
|
||||
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
||||
|
||||
|
@ -29,35 +34,117 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
||||
|
||||
//Read format version
|
||||
FormatVersion levelFormatVersion;
|
||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
||||
counter += sizeof(levelFormatVersion);
|
||||
if(this->formatVersion != levelFormatVersion)
|
||||
{
|
||||
//Do something if it's not the same version
|
||||
//Returns an empty vector, because it will most likely fail to read the level format.
|
||||
return objects;
|
||||
}
|
||||
|
||||
while(counter < bufferSize)
|
||||
{
|
||||
loadCgf = true;
|
||||
//Get typeID
|
||||
ObjectTypeHeader typeID;
|
||||
ObjectType typeID;
|
||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||
switch((int)typeID.typeID)
|
||||
switch((int)typeID)
|
||||
{
|
||||
case ObjectType_LevelMetaData:
|
||||
{
|
||||
LevelMetaData* header = new LevelMetaData;
|
||||
ParseLevelMetaData(&buffer[counter], *header, counter);
|
||||
SmartPointer<ObjectTypeHeader> header = new LevelMetaData;
|
||||
ParseLevelMetaData(&buffer[counter], *(LevelMetaData*)header.Get(), counter);
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
||||
//Unless they are changed to not be the same.
|
||||
case ObjectType_Static: case ObjectType_Dynamic:
|
||||
{
|
||||
//Get specialType.
|
||||
ObjectSpecialType specialType;
|
||||
ParseObject(&buffer[counter+4], &specialType, sizeof(typeID));
|
||||
|
||||
switch(specialType)
|
||||
{
|
||||
//there is no difference when parsing these specialTypes.
|
||||
case ObjectSpecialType_CrystalShard:
|
||||
case ObjectSpecialType_CrystalFormation:
|
||||
case ObjectSpecialType_Spike:
|
||||
case ObjectSpecialType_SpikeBox:
|
||||
case ObjectSpecialType_RedExplosiveBox:
|
||||
case ObjectSpecialType_StandarsBox:
|
||||
case ObjectSpecialType_Stone:
|
||||
case ObjectSpecialType_Building:
|
||||
{
|
||||
ObjectHeader* header = new ObjectHeader;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_JumpPad:
|
||||
{
|
||||
JumpPadAttributes* header = new JumpPadAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
//Read the spec
|
||||
ParseObject(&buffer[counter], header->direction, 16);
|
||||
counter += 16;
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_Portal:
|
||||
{
|
||||
PortalAttributes* header = new PortalAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], header->destination, 12);
|
||||
counter += 12;
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_World:
|
||||
{
|
||||
WorldAttributes* header = new WorldAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], &header->worldSize, 8);
|
||||
counter += 8;
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_Sky:
|
||||
{
|
||||
loadCgf = false;
|
||||
SkyAttributes* header = new SkyAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], &header->skySize, 4);
|
||||
counter += 4;
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_SpawnPoint:
|
||||
{
|
||||
loadCgf = false;
|
||||
ObjectHeader* header = new ObjectHeader;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
}
|
||||
|
||||
default:
|
||||
//Couldn't find specialType
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -68,7 +155,12 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
//Get Light type
|
||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||
|
||||
switch(lightType)
|
||||
//We only support PointLight for now.
|
||||
BasicLight* header = new BasicLight;
|
||||
ParseObject(&buffer[counter], header, sizeof(*header));
|
||||
counter += sizeof(*header);
|
||||
objects.push_back(header);
|
||||
/*switch(lightType)
|
||||
{
|
||||
case LightType_PointLight:
|
||||
{
|
||||
|
@ -98,7 +190,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
//Undefined LightType.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
break;*/
|
||||
}
|
||||
default:
|
||||
//Couldn't find typeID. FAIL!!!!!!
|
||||
|
@ -123,21 +215,25 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
||||
|
||||
//Read format version
|
||||
FormatVersion levelFormatVersion;
|
||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
|
||||
counter += sizeof(levelFormatVersion);
|
||||
if(this->formatVersion != levelFormatVersion)
|
||||
{
|
||||
//Do something if it's not the same version
|
||||
|
||||
//Returns an empty levelHeader with ObjectType_Unknown.
|
||||
//Because it will not be able to read another version of the level format.
|
||||
return levelHeader;
|
||||
}
|
||||
|
||||
//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);
|
||||
|
@ -148,7 +244,19 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|||
case ObjectType_Static: case ObjectType_Dynamic:
|
||||
{
|
||||
ObjectHeader header;
|
||||
ParseObject(&buffer[counter], header, counter);
|
||||
ParseObject(&buffer[counter], &header, counter);
|
||||
|
||||
switch(header.specialTypeID)
|
||||
{
|
||||
case ObjectSpecialType_JumpPad:
|
||||
counter += sizeof(16);
|
||||
break;
|
||||
case ObjectSpecialType_Portal:
|
||||
counter += sizeof(12);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -157,6 +265,9 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|||
LightType lightType;
|
||||
ParseObject(&buffer[counter+4], &lightType, sizeof(lightType));
|
||||
|
||||
//We only support pointlight for now.
|
||||
counter += sizeof(BasicLight);
|
||||
/*
|
||||
switch(lightType)
|
||||
{
|
||||
case LightType_PointLight:
|
||||
|
@ -177,7 +288,7 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|||
default:
|
||||
//Undefined LightType.
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace GameLogic
|
|||
LevelMetaData ParseHeader(std::string filename);
|
||||
|
||||
private:
|
||||
FormatVersion formatVersion;
|
||||
LevelLoaderInternal::FormatVersion formatVersion;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -23,31 +23,45 @@ namespace GameLogic
|
|||
ObjectType_Unknown = -1
|
||||
};
|
||||
|
||||
enum UsePhysics
|
||||
enum ObjectSpecialType
|
||||
{
|
||||
UsePhysics_UseFullPhysics,
|
||||
UsePhysics_IgnoreGravity,
|
||||
UsePhysics_IgnorePhysics,
|
||||
UsePhysics_IgnoreCollision,
|
||||
ObjectSpecialType_None,
|
||||
ObjectSpecialType_Sky,
|
||||
ObjectSpecialType_World, //Always the main celestial body
|
||||
ObjectSpecialType_Building,
|
||||
ObjectSpecialType_Stone,
|
||||
ObjectSpecialType_StandarsBox,
|
||||
ObjectSpecialType_RedExplosiveBox,
|
||||
ObjectSpecialType_SpikeBox,
|
||||
ObjectSpecialType_Spike,
|
||||
ObjectSpecialType_CrystalFormation,
|
||||
ObjectSpecialType_CrystalShard,
|
||||
ObjectSpecialType_JumpPad,
|
||||
ObjectSpecialType_Portal,
|
||||
ObjectSpecialType_SpawnPoint,
|
||||
ObjectSpecialType_Player,
|
||||
|
||||
UsePhysics_Count,
|
||||
UsePhysics_Unknown = -1
|
||||
|
||||
ObjectSpecialType_Count,
|
||||
ObjectSpecialType_Unknown = -1
|
||||
};
|
||||
|
||||
enum CollisionGeometryType
|
||||
{
|
||||
CollisionGeometryType_Box,
|
||||
CollisionGeometryType_Sphere,
|
||||
CollisionGeometryType_Cylinder,
|
||||
|
||||
CollisionGeometryType_Count,
|
||||
CollisionGeometryType_Unknown = -1
|
||||
};
|
||||
|
||||
//Only supports Pointlight right now.
|
||||
enum LightType
|
||||
{
|
||||
LightType_PointLight,
|
||||
LightType_DirectionalLight,
|
||||
LightType_SpotLight,
|
||||
//LightType_DirectionalLight,
|
||||
//LightType_SpotLight,
|
||||
|
||||
LightType_Count,
|
||||
LightType_Unknown = -1
|
||||
|
@ -80,15 +94,24 @@ namespace GameLogic
|
|||
/************************************
|
||||
Structs
|
||||
*************************************/
|
||||
|
||||
namespace LevelLoaderInternal
|
||||
{
|
||||
struct FormatVersion
|
||||
{
|
||||
unsigned int formatVersionMajor;
|
||||
unsigned int formatVersionMinor;
|
||||
|
||||
FormatVersion()
|
||||
: formatVersionMajor(0), formatVersionMinor(0)
|
||||
{}
|
||||
|
||||
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);
|
||||
return (this->formatVersionMajor == obj.formatVersionMajor && this->formatVersionMinor == obj.formatVersionMinor);
|
||||
}
|
||||
|
||||
bool operator !=(const FormatVersion& obj)
|
||||
|
@ -96,23 +119,60 @@ namespace GameLogic
|
|||
return !(*this == obj);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct ObjectTypeHeader
|
||||
{
|
||||
ObjectType typeID;
|
||||
|
||||
//Unless this is here the object destructor wont be called.
|
||||
virtual ~ObjectTypeHeader(){}
|
||||
};
|
||||
|
||||
struct PhysicsObject
|
||||
namespace LevelLoaderInternal
|
||||
{
|
||||
UsePhysics usePhysics;
|
||||
float mass;
|
||||
float inertiaMagnitude[3];
|
||||
float inertiaRotation[3];
|
||||
const FormatVersion boundingVolumeVersion(2, 0);
|
||||
|
||||
struct BoundingVolumeBase
|
||||
{
|
||||
CollisionGeometryType geoType;
|
||||
float position[3];
|
||||
float rotation[4];
|
||||
float frictionCoeffStatic;
|
||||
float frictionCoeffDynamic;
|
||||
CollisionGeometryType geometryType;
|
||||
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 BoundingVolume
|
||||
{
|
||||
CollisionGeometryType geoType;
|
||||
union
|
||||
{
|
||||
LevelLoaderInternal::BoundingVolumeBox box;
|
||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
||||
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
struct LevelMetaData : public ObjectTypeHeader
|
||||
{
|
||||
std::string levelName;
|
||||
|
@ -123,21 +183,56 @@ namespace GameLogic
|
|||
WorldSize worldSize;
|
||||
std::string overviewPicturePath;
|
||||
std::vector<GameMode> gameModesSupported;
|
||||
|
||||
virtual ~LevelMetaData(){}
|
||||
|
||||
};
|
||||
|
||||
struct ObjectHeader : public ObjectTypeHeader, public PhysicsObject
|
||||
struct ObjectHeader : public ObjectTypeHeader
|
||||
{
|
||||
//Special type id for special objects: portal, jumppad, exploding objects, etc.
|
||||
ObjectSpecialType specialTypeID;
|
||||
//Model,
|
||||
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(){}
|
||||
};
|
||||
|
||||
/************************************
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************
|
||||
Lights
|
||||
|
@ -145,12 +240,13 @@ namespace GameLogic
|
|||
|
||||
struct BasicLight : public ObjectTypeHeader
|
||||
{
|
||||
LightType lightType;
|
||||
float ambientColor[3];
|
||||
float diffuseColor[3];
|
||||
float specularColor[3];
|
||||
LightType lightType; //Is not used right now
|
||||
float color[3];
|
||||
float position[3];
|
||||
float raduis;
|
||||
float intensity;
|
||||
};
|
||||
|
||||
/* We only support pointlight right now.
|
||||
struct PointLight : public BasicLight
|
||||
{
|
||||
float position[3];
|
||||
|
@ -166,7 +262,7 @@ namespace GameLogic
|
|||
float direction[3];
|
||||
float range;
|
||||
float attenuation[3];
|
||||
};
|
||||
};*/
|
||||
}
|
||||
|
||||
#endif
|
|
@ -3,10 +3,9 @@
|
|||
//////////////////////////////////
|
||||
|
||||
#include "ParseFunctions.h"
|
||||
#include "../../../../Misc/Packing/Packing.h"
|
||||
#include "Loader.h"
|
||||
#include <string>
|
||||
|
||||
using namespace Oyster::Packing;
|
||||
using namespace GameLogic::LevelFileLoader;
|
||||
using namespace GameLogic;
|
||||
using namespace std;
|
||||
|
@ -15,12 +14,13 @@ namespace GameLogic
|
|||
{
|
||||
namespace LevelFileLoader
|
||||
{
|
||||
//can parse any struct if the struct doesnt contain strings or char[]
|
||||
void ParseObject(char* buffer, void *header, int size)
|
||||
{
|
||||
memcpy(header, buffer, size);
|
||||
}
|
||||
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size, bool loadCgf)
|
||||
{
|
||||
char tempName[128];
|
||||
unsigned int tempSize = 0;
|
||||
|
@ -29,6 +29,9 @@ namespace GameLogic
|
|||
memcpy(&header.typeID, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
memcpy(&header.specialTypeID, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
memcpy(&tempSize, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
|
@ -36,13 +39,29 @@ namespace GameLogic
|
|||
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
||||
start += tempSize;
|
||||
|
||||
//The reset of the object struct
|
||||
//3 float[3], 1 float
|
||||
memcpy(&header.position, &buffer[start], 40);
|
||||
start += 40;
|
||||
|
||||
//2 float[3], 3 float, 2 uint
|
||||
memcpy(&header.usePhysics, &buffer[start], 44);
|
||||
start += 44;
|
||||
//if loadCgf : Read path for bounding volume
|
||||
if(loadCgf)
|
||||
{
|
||||
ParseBoundingVolume(&buffer[start], header.boundingVolume, start);
|
||||
}
|
||||
|
||||
//else make sure the counter counts the name so we can jump over the string in the buffer.
|
||||
else
|
||||
{
|
||||
memcpy(&tempSize, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
memcpy(&tempName, &buffer[start], tempSize);
|
||||
|
||||
string fileName;
|
||||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
||||
start += tempSize;
|
||||
}
|
||||
|
||||
size += start;
|
||||
}
|
||||
|
@ -107,5 +126,57 @@ namespace GameLogic
|
|||
|
||||
size += start;
|
||||
}
|
||||
|
||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size)
|
||||
{
|
||||
int start = 0;
|
||||
int tempSize = 0;
|
||||
char tempName[128];
|
||||
|
||||
memcpy(&tempSize, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
memcpy(&tempName, &buffer[start], tempSize);
|
||||
|
||||
string fileName;
|
||||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
||||
start += tempSize;
|
||||
|
||||
size += start;
|
||||
|
||||
//Läs in filen.
|
||||
int fileLength = 0;
|
||||
Loader loader;
|
||||
char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength);
|
||||
|
||||
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[start], sizeof(volume.box));
|
||||
start += sizeof(volume.box);
|
||||
break;
|
||||
|
||||
case CollisionGeometryType_Sphere:
|
||||
memcpy(&volume.sphere, &buf[start], sizeof(volume.sphere));
|
||||
start += sizeof(volume.sphere);
|
||||
break;
|
||||
|
||||
case CollisionGeometryType_Cylinder:
|
||||
memcpy(&volume.cylinder, &buf[start], sizeof(volume.cylinder));
|
||||
start += sizeof(volume.cylinder);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,10 +17,10 @@ namespace GameLogic
|
|||
Or the current index that is being used to parse the entire file (if it is sent by reference) this means you have to increase size with the appropiate size after you have copied.
|
||||
|
||||
*/
|
||||
|
||||
void ParseObject(char* buffer, void *header, int size);
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size);
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size , bool loadCgf);
|
||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
|||
if(hasObject)
|
||||
{
|
||||
Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject);
|
||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100);
|
||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400);
|
||||
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
|
||||
|
||||
hasObject = false;
|
||||
|
@ -100,7 +100,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
|||
Oyster::Math::Float lenght = 10;
|
||||
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
|
||||
|
||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100);
|
||||
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400);
|
||||
|
||||
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);
|
||||
|
||||
|
|
|
@ -24,19 +24,14 @@ using namespace GameLogic;
|
|||
|
||||
switch (realObj->GetObjectType())
|
||||
{
|
||||
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
||||
case ObjectSpecialType_StandarsBox:
|
||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||
break;
|
||||
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||
case ObjectSpecialType_Player:
|
||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
||||
case ObjectSpecialType_World:
|
||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||
break;
|
||||
|
@ -52,25 +47,21 @@ using namespace GameLogic;
|
|||
|
||||
switch (realObj->GetObjectType())
|
||||
{
|
||||
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
||||
case ObjectSpecialType_Generic:
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
case ObjectSpecialType_StandarsBox:
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||
case ObjectSpecialType_Player:
|
||||
SendObjectFlying(*obj, jumpPad->pushForce);
|
||||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
||||
case ObjectSpecialType_World:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force)
|
||||
{
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
|
||||
state = obj.GetState();
|
||||
//state.ApplyLinearImpulse(force);
|
||||
obj.SetState(state);
|
||||
obj.ApplyImpulse(force);
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,7 +106,7 @@ using namespace GameLogic;
|
|||
|
||||
Object *realObj = (Object*)obj->GetCustomTag();
|
||||
|
||||
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
|
||||
if(realObj->GetObjectType() == ObjectSpecialType_Player || realObj->GetObjectType() == ObjectSpecialType_World)
|
||||
return;
|
||||
|
||||
obj->ApplyImpulse(((forcePushData*)(args))->pushForce);
|
||||
|
@ -138,7 +129,7 @@ using namespace GameLogic;
|
|||
|
||||
switch(realObj->GetObjectType())
|
||||
{
|
||||
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||
case ObjectSpecialType_StandarsBox:
|
||||
//move obj to limbo in physics to make sure it wont collide with anything
|
||||
// Oyster::Physics::API::Instance().MoveToLimbo(obj);
|
||||
weapon->heldObject = obj; //weapon now holds the object
|
||||
|
|
|
@ -9,28 +9,28 @@ DynamicObject::DynamicObject()
|
|||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(OBJECT_TYPE type)
|
||||
DynamicObject::DynamicObject(ObjectSpecialType type)
|
||||
:Object(type)
|
||||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
|
||||
:Object(rigidBody,type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
DynamicObject::DynamicObject( void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:Object(collisionFuncAfter,type)
|
||||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ namespace GameLogic
|
|||
|
||||
public:
|
||||
DynamicObject();
|
||||
DynamicObject(OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
|
||||
DynamicObject(ObjectSpecialType type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
|
||||
DynamicObject( void* collisionFuncAfter, ObjectSpecialType type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
|
||||
|
||||
|
||||
~DynamicObject(void);
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ Game::LevelData* Game::CreateLevel()
|
|||
if(this->level) return this->level;
|
||||
|
||||
this->level = new LevelData();
|
||||
this->level->level->InitiateLevel(1000);
|
||||
//this->level->level->InitiateLevel("3bana.bias");
|
||||
//this->level->level->InitiateLevel(1000);
|
||||
this->level->level->InitiateLevel("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/ccc.bias");
|
||||
|
||||
return this->level;
|
||||
}
|
||||
|
|
|
@ -40,8 +40,10 @@ namespace GameLogic
|
|||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
int GetID() const override;
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override;
|
||||
ObjectSpecialType GetObjectType() const override;
|
||||
|
||||
|
||||
|
||||
Player *player;
|
||||
};
|
||||
|
@ -56,7 +58,7 @@ namespace GameLogic
|
|||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
int GetID() const override;
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
ObjectSpecialType GetObjectType() const override;
|
||||
int getNrOfDynamicObj()const override;
|
||||
IObjectData* GetObjectAt(int ID) const override;
|
||||
Level *level;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "GameLogicDef.h"
|
||||
#include "GameLogicStates.h"
|
||||
#include <OysterMath.h>
|
||||
#include "LevelLoader\ObjectDefines.h"
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
|
@ -66,7 +67,7 @@ namespace GameLogic
|
|||
/** Get the type of the object
|
||||
* @return The OBJECT_TYPE of the object is returned
|
||||
*/
|
||||
virtual OBJECT_TYPE GetObjectType() const = 0;
|
||||
virtual ObjectSpecialType GetObjectType() const = 0;
|
||||
};
|
||||
|
||||
class IPlayerData :public IObjectData
|
||||
|
|
|
@ -21,16 +21,6 @@ namespace GameLogic
|
|||
PLAYER_STATE_INVALID = 8,
|
||||
};
|
||||
|
||||
enum OBJECT_TYPE
|
||||
{
|
||||
OBJECT_TYPE_PLAYER = 0,
|
||||
OBJECT_TYPE_BOX = 1,
|
||||
OBJECT_TYPE_WORLD = 2,
|
||||
OBJECT_TYPE_GENERIC = 4,
|
||||
OBJECT_TYPE_JUMPPAD = 8,
|
||||
OBJECT_TYPE_UNKNOWN = -1,
|
||||
};
|
||||
|
||||
enum WEAPON_FIRE
|
||||
{
|
||||
WEAPON_USE_PRIMARY_PRESS = 0,
|
||||
|
|
|
@ -38,7 +38,7 @@ int Game::LevelData::GetID() const
|
|||
{
|
||||
return ((IObjectData*)this->level)->GetID();
|
||||
}
|
||||
OBJECT_TYPE Game::LevelData::GetObjectType() const
|
||||
ObjectSpecialType Game::LevelData::GetObjectType() const
|
||||
{
|
||||
return ((IObjectData*)this->level)->GetObjectType();
|
||||
//return OBJECT_TYPE_UNKNOWN;
|
||||
|
|
|
@ -6,7 +6,9 @@ using namespace GameLogic;
|
|||
Game::PlayerData::PlayerData()
|
||||
{
|
||||
//set some stats that are appropriate to a player
|
||||
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,603,0);
|
||||
|
||||
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0);
|
||||
|
||||
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f);
|
||||
Oyster::Math::Float mass = 60;
|
||||
Oyster::Math::Float restitutionCoeff = 0.5;
|
||||
|
@ -18,7 +20,8 @@ Game::PlayerData::PlayerData()
|
|||
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
|
||||
rigidBody->SetAngularFactor(0.0f);
|
||||
//create player with this rigid body
|
||||
this->player = new Player(rigidBody, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player);
|
||||
|
||||
this->player->GetRigidBody()->SetCustomTag(this);
|
||||
player->EndFrame();
|
||||
}
|
||||
|
@ -68,7 +71,7 @@ int Game::PlayerData::GetTeamID() const
|
|||
return this->player->GetTeamID();
|
||||
}
|
||||
|
||||
OBJECT_TYPE Game::PlayerData::GetObjectType() const
|
||||
ObjectSpecialType Game::PlayerData::GetObjectType() const
|
||||
{
|
||||
return this->player->GetObjectType();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ JumpPad::JumpPad(void)
|
|||
{
|
||||
}
|
||||
|
||||
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce)
|
||||
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 pushForce)
|
||||
:StaticObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
this->pushForce = pushForce;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ namespace GameLogic
|
|||
JumpPad(void);
|
||||
|
||||
JumpPad(Oyster::Physics::ICustomBody *rigidBody
|
||||
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||
,OBJECT_TYPE type, Oyster::Math::Float3 pushForce);
|
||||
,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||
,ObjectSpecialType type, Oyster::Math::Float3 pushForce);
|
||||
|
||||
|
||||
~JumpPad(void);
|
||||
|
||||
|
|
|
@ -53,6 +53,11 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
int modelCount = 0;
|
||||
int staticObjCount = 0;
|
||||
int dynamicObjCount = 0;
|
||||
Oyster::Math::Float3 rigidWorldPos;
|
||||
Oyster::Math::Float4 rigidWorldRotation;
|
||||
float rigidBodyMass;
|
||||
float rigidBodyRadius;
|
||||
Oyster::Math::Float3 rigidBodySize;
|
||||
for (int i = 0; i < objCount; i++)
|
||||
{
|
||||
ObjectTypeHeader* obj = objects.at(i);
|
||||
|
@ -73,34 +78,136 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
//LevelLoaderInternal::BoundingVolumeBase* staticObjPhysicData = ((ObjectHeader*)obj);
|
||||
staticObjData->ModelFile;
|
||||
|
||||
ICustomBody* rigidBody_Static;
|
||||
ICustomBody* rigidBody_Static = NULL;
|
||||
|
||||
|
||||
// collision shape
|
||||
// radius, rotation in world, position in world, mass, restitution, static and dynamic friction
|
||||
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
{
|
||||
//offset the rigidPosition from modelspace to worldspace;
|
||||
rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.sphere.position;
|
||||
//scales the position so the collision geomentry is in the right place
|
||||
rigidWorldPos = rigidWorldPos * staticObjData->scale;
|
||||
|
||||
//offset the rigidRotation from modelspace to worldspace;
|
||||
rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.sphere.rotation;
|
||||
|
||||
//mass scaled
|
||||
rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.sphere.mass;
|
||||
|
||||
//Radius scaled
|
||||
rigidBodyRadius = (staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius;
|
||||
|
||||
//create the rigid body
|
||||
rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.sphere.restitutionCoeff , staticObjData->boundingVolume.sphere.frictionCoeffStatic , staticObjData->boundingVolume.sphere.frictionCoeffDynamic);
|
||||
}
|
||||
|
||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||
{
|
||||
//offset the rigidPosition from modelspace to worldspace;
|
||||
rigidWorldPos = (Oyster::Math::Float3)staticObjData->position + (Oyster::Math::Float3)staticObjData->boundingVolume.box.position;
|
||||
//scales the position so the collision geomentry is in the right place
|
||||
rigidWorldPos = rigidWorldPos * staticObjData->scale;
|
||||
|
||||
//offset the rigidRotation from modelspace to worldspace;
|
||||
rigidWorldRotation = (Oyster::Math::Float4)staticObjData->rotation + (Oyster::Math::Float4)staticObjData->boundingVolume.box.rotation;
|
||||
|
||||
//mass scaled
|
||||
rigidBodyMass = staticObjData->scale[0] * staticObjData->scale[1] * staticObjData->scale[2] * staticObjData->boundingVolume.box.mass;
|
||||
|
||||
//size scaled
|
||||
rigidBodySize = (Oyster::Math::Float3)staticObjData->boundingVolume.box.size * (Oyster::Math::Float3)staticObjData->scale;
|
||||
|
||||
//create the rigid body
|
||||
rigidBody_Static = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, staticObjData->boundingVolume.box.restitutionCoeff , staticObjData->boundingVolume.box.frictionCoeffStatic , staticObjData->boundingVolume.box.frictionCoeffDynamic);
|
||||
}
|
||||
|
||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add rigidbody to the logical obj
|
||||
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
|
||||
// set object_type to objID
|
||||
this->staticObjects.Push(new StaticObject(rigidBody, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
|
||||
if(rigidBody_Static != NULL)
|
||||
{
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID));
|
||||
this->staticObjects[staticObjCount]->objectID = modelCount++;
|
||||
rigidBody->SetCustomTag(this->staticObjects[staticObjCount]);
|
||||
rigidBody_Static->SetCustomTag(this->staticObjects[staticObjCount]);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ObjectType::ObjectType_Dynamic:
|
||||
{
|
||||
ObjectHeader* staticObjData = ((ObjectHeader*)obj);
|
||||
staticObjData->ModelFile;
|
||||
ObjectHeader* dynamicObjData = ((ObjectHeader*)obj);
|
||||
dynamicObjData->ModelFile;
|
||||
|
||||
ICustomBody* rigidBody_Dynamic;
|
||||
ICustomBody* rigidBody_Dynamic = NULL;
|
||||
|
||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
||||
// collision shape
|
||||
// radius, rotation in world, position in world, mass, restitution, static and dynamic friction
|
||||
if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
{
|
||||
//offset the rigidPosition from modelspace to worldspace;
|
||||
rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.sphere.position;
|
||||
//scales the position so the collision geomentry is in the right place
|
||||
rigidWorldPos = rigidWorldPos * dynamicObjData->scale;
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
//offset the rigidRotation from modelspace to worldspace;
|
||||
rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.sphere.rotation;
|
||||
|
||||
//mass scaled
|
||||
rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.sphere.mass;
|
||||
|
||||
//size scaled
|
||||
rigidBodyRadius = (dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] / 3) * dynamicObjData->boundingVolume.sphere.radius;
|
||||
|
||||
//create the rigid body
|
||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.sphere.restitutionCoeff , dynamicObjData->boundingVolume.sphere.frictionCoeffStatic , dynamicObjData->boundingVolume.sphere.frictionCoeffDynamic);
|
||||
}
|
||||
|
||||
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||
{
|
||||
//offset the rigidPosition from modelspace to worldspace;
|
||||
rigidWorldPos = (Oyster::Math::Float3)dynamicObjData->position + (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.position;
|
||||
//scales the position so the collision geomentry is in the right place
|
||||
rigidWorldPos = rigidWorldPos * dynamicObjData->scale;
|
||||
|
||||
//offset the rigidRotation from modelspace to worldspace;
|
||||
rigidWorldRotation = (Oyster::Math::Float4)dynamicObjData->rotation + (Oyster::Math::Float4)dynamicObjData->boundingVolume.box.rotation;
|
||||
|
||||
//mass scaled
|
||||
rigidBodyMass = dynamicObjData->scale[0] * dynamicObjData->scale[1] * dynamicObjData->scale[2] * dynamicObjData->boundingVolume.box.mass;
|
||||
|
||||
//size scaled
|
||||
rigidBodySize = (Oyster::Math::Float3)dynamicObjData->boundingVolume.box.size * (Oyster::Math::Float3)dynamicObjData->scale;
|
||||
|
||||
//create the rigid body
|
||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(rigidBodySize , rigidWorldRotation , rigidWorldPos , rigidBodyMass, dynamicObjData->boundingVolume.box.restitutionCoeff , dynamicObjData->boundingVolume.box.frictionCoeffStatic , dynamicObjData->boundingVolume.box.frictionCoeffDynamic);
|
||||
}
|
||||
|
||||
else if(dynamicObjData->boundingVolume.geoType == CollisionGeometryType_Cylinder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// add rigidbody to the logical obj
|
||||
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
|
||||
// set object_type to objID
|
||||
if(rigidBody_Dynamic != NULL)
|
||||
{
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic , Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID));
|
||||
this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
|
||||
rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case ObjectType::ObjectType_Light:
|
||||
// read on client
|
||||
|
@ -117,7 +224,9 @@ void Level::InitiateLevel(float radius)
|
|||
int idCount = 100;
|
||||
// add level sphere
|
||||
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
levelObj = new StaticObject(rigidBody, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
||||
|
||||
levelObj = new StaticObject(rigidBody, LevelCollisionAfter, ObjectSpecialType_World);
|
||||
|
||||
this->levelObj->objectID = idCount++;
|
||||
rigidBody->SetCustomTag(levelObj);
|
||||
|
||||
|
@ -130,7 +239,8 @@ void Level::InitiateLevel(float radius)
|
|||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandarsBox));
|
||||
|
||||
this->dynamicObjects[i]->objectID = idCount++;
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
||||
}
|
||||
|
@ -168,7 +278,7 @@ void Level::InitiateLevel(float radius)
|
|||
// add crystal
|
||||
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandarsBox));
|
||||
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
|
||||
this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
|
||||
|
||||
|
@ -176,14 +286,14 @@ void Level::InitiateLevel(float radius)
|
|||
|
||||
// add house
|
||||
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic));
|
||||
rigidBody_House->SetCustomTag(this->staticObjects[0]);
|
||||
this->staticObjects[0]->objectID = idCount++;
|
||||
|
||||
// add jumppad
|
||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_JUMPPAD, Oyster::Math::Float3(0,1,0)));
|
||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, JumpPad::JumpPadActivated, ObjectSpecialType_JumpPad, Oyster::Math::Float3(0,2000,0)));
|
||||
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
|
||||
this->staticObjects[1]->objectID = idCount++;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
{
|
||||
int bufferSize = 0;
|
||||
int counter = 0;
|
||||
bool loadCgf;
|
||||
|
||||
std::vector<SmartPointer<ObjectTypeHeader>> objects;
|
||||
|
||||
|
@ -38,14 +39,13 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
counter += sizeof(levelFormatVersion);
|
||||
if(this->formatVersion != levelFormatVersion)
|
||||
{
|
||||
//Do something if it's not the same version
|
||||
|
||||
//Returns an empty vector, because it will most likely fail to read the level format.
|
||||
return objects;
|
||||
}
|
||||
|
||||
while(counter < bufferSize)
|
||||
{
|
||||
loadCgf = true;
|
||||
//Get typeID
|
||||
ObjectType typeID;
|
||||
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
|
||||
|
@ -69,45 +69,43 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
|
||||
switch(specialType)
|
||||
{
|
||||
//These three does not have any specail variables at this time.
|
||||
//There for they are using the same 'parser'.
|
||||
//there is no difference when parsing these specialTypes.
|
||||
case ObjectSpecialType_CrystalShard:
|
||||
case ObjectSpecialType_CrystalFormation:
|
||||
case ObjectSpecialType_Spike:
|
||||
case ObjectSpecialType_SpikeBox:
|
||||
case ObjectSpecialType_RedExplosiveBox:
|
||||
case ObjectSpecialType_StandarsBox:
|
||||
case ObjectSpecialType_Stone:
|
||||
case ObjectSpecialType_Building:
|
||||
case ObjectSpecialType_Damaging:
|
||||
case ObjectSpecialType_Explosive:
|
||||
{
|
||||
ObjectHeader* header = new ObjectHeader;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_JumpPad:
|
||||
{
|
||||
JumpPadAttributes* header = new JumpPadAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
//Read the spec
|
||||
ParseObject(&buffer[counter], header->direction, 16);
|
||||
counter += 16;
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
case ObjectSpecialType_BoostPad:
|
||||
{
|
||||
JumpPadAttributes* header = new JumpPadAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
|
||||
ParseObject(&buffer[counter], header->direction, 16);
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
}
|
||||
case ObjectSpecialType_Portal:
|
||||
{
|
||||
PortalAttributes* header = new PortalAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], header->destination, 12);
|
||||
counter += 12;
|
||||
objects.push_back(header);
|
||||
|
||||
break;
|
||||
|
@ -116,22 +114,33 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
|||
case ObjectSpecialType_World:
|
||||
{
|
||||
WorldAttributes* header = new WorldAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], &header->worldSize, 8);
|
||||
counter += 8;
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_Sky:
|
||||
{
|
||||
loadCgf = false;
|
||||
SkyAttributes* header = new SkyAttributes;
|
||||
ParseObject(&buffer[counter], *header, counter);
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
|
||||
ParseObject(&buffer[counter], &header->skySize, 4);
|
||||
counter += 4;
|
||||
objects.push_back(header);
|
||||
break;
|
||||
}
|
||||
|
||||
case ObjectSpecialType_SpawnPoint:
|
||||
{
|
||||
loadCgf = false;
|
||||
ObjectHeader* header = new ObjectHeader;
|
||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||
}
|
||||
|
||||
default:
|
||||
//Couldn't find specialType
|
||||
break;
|
||||
|
@ -235,16 +244,13 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
|
|||
case ObjectType_Static: case ObjectType_Dynamic:
|
||||
{
|
||||
ObjectHeader header;
|
||||
ParseObject(&buffer[counter], header, counter);
|
||||
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;
|
||||
|
|
|
@ -25,30 +25,28 @@ namespace GameLogic
|
|||
|
||||
enum ObjectSpecialType
|
||||
{
|
||||
ObjectSpecialType_None,
|
||||
ObjectSpecialType_Sky,
|
||||
ObjectSpecialType_World, //Always the main celestial body
|
||||
ObjectSpecialType_Building,
|
||||
ObjectSpecialType_Damaging,
|
||||
ObjectSpecialType_Explosive,
|
||||
ObjectSpecialType_Stone,
|
||||
ObjectSpecialType_StandarsBox,
|
||||
ObjectSpecialType_RedExplosiveBox,
|
||||
ObjectSpecialType_SpikeBox,
|
||||
ObjectSpecialType_Spike,
|
||||
ObjectSpecialType_CrystalFormation,
|
||||
ObjectSpecialType_CrystalShard,
|
||||
ObjectSpecialType_JumpPad,
|
||||
ObjectSpecialType_BoostPad,
|
||||
ObjectSpecialType_Portal,
|
||||
ObjectSpecialType_Sky,
|
||||
ObjectSpecialType_SpawnPoint,
|
||||
ObjectSpecialType_Player,
|
||||
ObjectSpecialType_Generic,
|
||||
|
||||
|
||||
ObjectSpecialType_Count,
|
||||
ObjectSpecialType_Unknown = -1
|
||||
};
|
||||
|
||||
enum UsePhysics
|
||||
{
|
||||
UsePhysics_UseFullPhysics,
|
||||
UsePhysics_IgnoreGravity,
|
||||
UsePhysics_IgnorePhysics,
|
||||
UsePhysics_IgnoreCollision,
|
||||
|
||||
UsePhysics_Count,
|
||||
UsePhysics_Unknown = -1
|
||||
};
|
||||
|
||||
enum CollisionGeometryType
|
||||
{
|
||||
CollisionGeometryType_Box,
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace GameLogic
|
|||
{
|
||||
namespace LevelFileLoader
|
||||
{
|
||||
//can parse any struct without strings or char[]
|
||||
//can parse any struct if the struct doesnt contain strings or char[]
|
||||
void ParseObject(char* buffer, void *header, int size)
|
||||
{
|
||||
memcpy(header, buffer, size);
|
||||
}
|
||||
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size, bool loadCgf)
|
||||
{
|
||||
char tempName[128];
|
||||
unsigned int tempSize = 0;
|
||||
|
@ -46,8 +46,24 @@ namespace GameLogic
|
|||
memcpy(&header.position, &buffer[start], 40);
|
||||
start += 40;
|
||||
|
||||
//Read path for bounding volume
|
||||
//if loadCgf : Read path for bounding volume
|
||||
if(loadCgf)
|
||||
{
|
||||
ParseBoundingVolume(&buffer[start], header.boundingVolume, start);
|
||||
}
|
||||
|
||||
//else make sure the counter counts the name so we can jump over the string in the buffer.
|
||||
else
|
||||
{
|
||||
memcpy(&tempSize, &buffer[start], 4);
|
||||
start += 4;
|
||||
|
||||
memcpy(&tempName, &buffer[start], tempSize);
|
||||
|
||||
string fileName;
|
||||
fileName.assign(&tempName[0], &tempName[tempSize]);
|
||||
start += tempSize;
|
||||
}
|
||||
|
||||
size += start;
|
||||
}
|
||||
|
@ -133,15 +149,14 @@ namespace GameLogic
|
|||
//Läs in filen.
|
||||
int fileLength = 0;
|
||||
Loader loader;
|
||||
char* buf = loader.LoadFile("E:\\Dropbox\\Programming\\Github\\Danbias\\Bin\\Content\\Worlds\\cgf\\"+ fileName, fileLength);
|
||||
char* buf = loader.LoadFile("C:/Users/Sam/Documents/GitHub/Danbias/Bin/Content/worlds/cgf/"+ fileName, fileLength);
|
||||
|
||||
start = 0;
|
||||
LevelLoaderInternal::FormatVersion version;
|
||||
memcpy(&version, &buf[0], sizeof(version));
|
||||
start += 4;
|
||||
start += 8;
|
||||
|
||||
memcpy(&volume.geoType, &buf[start], sizeof(volume.geoType));
|
||||
start += sizeof(volume.geoType);
|
||||
|
||||
switch(volume.geoType)
|
||||
{
|
||||
|
|
|
@ -17,9 +17,8 @@ namespace GameLogic
|
|||
Or the current index that is being used to parse the entire file (if it is sent by reference) this means you have to increase size with the appropiate size after you have copied.
|
||||
|
||||
*/
|
||||
|
||||
void ParseObject(char* buffer, void *header, int size);
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size);
|
||||
void ParseObject(char* buffer, ObjectHeader& header, int& size , bool loadCgf);
|
||||
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
|
||||
void ParseBoundingVolume(char* buffer, LevelLoaderInternal::BoundingVolume& volume, int &size);
|
||||
}
|
||||
|
|
|
@ -18,25 +18,26 @@ Object::Object()
|
|||
|
||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
|
||||
this->type = ObjectSpecialType_Unknown;
|
||||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(OBJECT_TYPE type)
|
||||
Object::Object(ObjectSpecialType type)
|
||||
{
|
||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
this->type = type;
|
||||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
this->type = type;
|
||||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
Object::Object( void* collisionFuncAfter, ObjectSpecialType type)
|
||||
|
||||
{
|
||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
|
@ -44,7 +45,7 @@ Object::Object( void* collisionFuncAfter, OBJECT_TYPE type)
|
|||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
|
@ -52,7 +53,8 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter
|
|||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
|
@ -71,7 +73,7 @@ Object::~Object(void)
|
|||
|
||||
}
|
||||
|
||||
OBJECT_TYPE Object::GetObjectType() const
|
||||
ObjectSpecialType Object::GetObjectType() const
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
|
|
|
@ -18,21 +18,24 @@ namespace GameLogic
|
|||
{
|
||||
public:
|
||||
Object();
|
||||
Object(OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
Object(void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
Object(ObjectSpecialType type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
|
||||
Object(void* collisionFuncAfter, ObjectSpecialType type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
|
||||
~Object(void);
|
||||
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
ObjectSpecialType GetObjectType() const override;
|
||||
int GetID() const override;
|
||||
void setID(int id);
|
||||
Oyster::Math::Float3 GetPosition() override;
|
||||
Oyster::Math::Quaternion GetRotation() override;
|
||||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
|
||||
void setID(int id);
|
||||
// API overrides
|
||||
|
||||
|
||||
|
||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||
void ApplyLinearImpulse(Oyster::Math::Float3 force);
|
||||
|
@ -45,8 +48,9 @@ namespace GameLogic
|
|||
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
public: //HACK: This should be private when level is dynamic
|
||||
OBJECT_TYPE type;
|
||||
|
||||
public: //TODO: Hax This should be private when level is dynamic
|
||||
ObjectSpecialType type;
|
||||
int objectID;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -13,27 +13,28 @@ Player::Player()
|
|||
{
|
||||
|
||||
}
|
||||
Player::Player(OBJECT_TYPE type)
|
||||
Player::Player(ObjectSpecialType type)
|
||||
:DynamicObject(type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
|
||||
:DynamicObject(rigidBody,type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
|
||||
Player::Player( void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:DynamicObject(collisionFuncAfter,type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:DynamicObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
|
||||
:DynamicObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
InitPlayer();
|
||||
|
|
|
@ -16,11 +16,12 @@ namespace GameLogic
|
|||
{
|
||||
public:
|
||||
Player(void);
|
||||
Player(OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
Player( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
Player(ObjectSpecialType type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
|
||||
Player( void* collisionFuncAfter, ObjectSpecialType type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, ObjectSpecialType type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
|
||||
|
||||
~Player(void);
|
||||
void InitPlayer();
|
||||
|
||||
|
|
|
@ -10,29 +10,29 @@ StaticObject::StaticObject()
|
|||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(OBJECT_TYPE type)
|
||||
StaticObject::StaticObject(ObjectSpecialType type)
|
||||
:Object(type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type)
|
||||
:Object(rigidBody,type)
|
||||
{
|
||||
//this->rigidBody->SetGravity(true);
|
||||
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision));
|
||||
}
|
||||
|
||||
StaticObject::StaticObject( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
StaticObject::StaticObject( void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:Object(collisionFuncAfter,type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "Object.h"
|
||||
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
|
||||
|
@ -16,11 +17,12 @@ namespace GameLogic
|
|||
|
||||
public:
|
||||
StaticObject();
|
||||
StaticObject(OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
StaticObject( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
|
||||
StaticObject(ObjectSpecialType type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody, ObjectSpecialType type);
|
||||
StaticObject( void* collisionFuncAfter, ObjectSpecialType type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, ObjectSpecialType type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type);
|
||||
|
||||
~StaticObject(void);
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ void API_Impl::UpdateWorld()
|
|||
{
|
||||
SimpleRigidBody* simpleBody = dynamic_cast<SimpleRigidBody*>(this->customBodies[i]);
|
||||
btTransform trans;
|
||||
simpleBody->GetMotionState()->getWorldTransform(trans);
|
||||
trans = simpleBody->GetRigidBody()->getWorldTransform();
|
||||
this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z()));
|
||||
this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w()));
|
||||
|
||||
|
|
Loading…
Reference in New Issue