Merge remote-tracking branch 'origin/GameLogic' into Camera-Merge-buffer
Conflicts: Code/Game/DanBiasGame/GameClientState/C_Object.h Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h Code/Game/DanBiasGame/GameClientState/GameState.cpp
This commit is contained in:
commit
ba7f9aaa38
|
@ -1,14 +1,31 @@
|
||||||
#include "C_Object.h"
|
#include "C_Object.h"
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
void C_Object::Init(ModelInitData modelInit)
|
C_Object::C_Object()
|
||||||
|
{
|
||||||
|
world = Oyster::Math::Float4x4::identity;
|
||||||
|
position = Oyster::Math::Float3::null;
|
||||||
|
rotation = Oyster::Math::Quaternion::identity;
|
||||||
|
scale = Oyster::Math::Float3::null;
|
||||||
|
|
||||||
|
id = 0;
|
||||||
|
model = NULL;
|
||||||
|
}
|
||||||
|
C_Object::~C_Object()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
bool C_Object::Init(ModelInitData modelInit)
|
||||||
{
|
{
|
||||||
position = modelInit.position;
|
position = modelInit.position;
|
||||||
rotation = modelInit.rotation;
|
rotation = modelInit.rotation;
|
||||||
scale = modelInit.scale;
|
scale = modelInit.scale;
|
||||||
id = modelInit.id;
|
id = modelInit.id;
|
||||||
model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||||
|
if(model == NULL)
|
||||||
|
return false;
|
||||||
model->Visible = modelInit.visible;
|
model->Visible = modelInit.visible;
|
||||||
updateWorld();
|
updateWorld();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
void C_Object::updateWorld()
|
void C_Object::updateWorld()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ModelInitData
|
struct ModelInitData
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
|
@ -15,11 +16,9 @@ namespace DanBias
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
class C_Object
|
class C_Object
|
||||||
{
|
{
|
||||||
protected:
|
private:
|
||||||
Oyster::Graphics::Model::Model *model;
|
|
||||||
private:
|
|
||||||
Oyster::Math::Float4x4 world;
|
Oyster::Math::Float4x4 world;
|
||||||
Oyster::Math::Float3 position;
|
Oyster::Math::Float3 position;
|
||||||
Oyster::Math::Quaternion rotation;
|
Oyster::Math::Quaternion rotation;
|
||||||
|
@ -27,9 +26,12 @@ namespace DanBias
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
void updateWorld();
|
void updateWorld();
|
||||||
public:
|
protected:
|
||||||
|
Oyster::Graphics::Model::Model *model;
|
||||||
virtual void Init(ModelInitData modelInit);
|
public:
|
||||||
|
C_Object();
|
||||||
|
virtual ~C_Object();
|
||||||
|
virtual bool Init(ModelInitData modelInit);
|
||||||
|
|
||||||
void setWorld(Oyster::Math::Float4x4 world);
|
void setWorld(Oyster::Math::Float4x4 world);
|
||||||
Oyster::Math::Float4x4 getWorld() const;
|
Oyster::Math::Float4x4 getWorld() const;
|
||||||
|
@ -46,21 +48,5 @@ namespace DanBias
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void Release();
|
virtual void Release();
|
||||||
virtual int GetId() const;
|
virtual int GetId() const;
|
||||||
};
|
};};};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Utility { namespace DynamicMemory
|
|
||||||
{ // template specializationto allowuse of dynamicmemory tools
|
|
||||||
template<>
|
|
||||||
inline void SafeDeleteInstance( ::DanBias::Client::C_Object *dynamicInstance )
|
|
||||||
{
|
|
||||||
if( dynamicInstance )
|
|
||||||
{
|
|
||||||
dynamicInstance->Release();
|
|
||||||
delete dynamicInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,7 +11,7 @@ C_DynamicObj::~C_DynamicObj(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void C_DynamicObj::Init(ModelInitData modelInit)
|
bool C_DynamicObj::Init(ModelInitData modelInit)
|
||||||
{
|
{
|
||||||
C_Object::Init(modelInit);
|
return C_Object::Init(modelInit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ private:
|
||||||
public:
|
public:
|
||||||
C_DynamicObj(void);
|
C_DynamicObj(void);
|
||||||
virtual ~C_DynamicObj(void);
|
virtual ~C_DynamicObj(void);
|
||||||
void Init(ModelInitData modelInit);
|
bool Init(ModelInitData modelInit);
|
||||||
|
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
|
@ -3,14 +3,22 @@
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
|
|
||||||
C_Player::C_Player(void)
|
C_Player::C_Player(void)
|
||||||
:C_DynamicObj() {}
|
:C_DynamicObj()
|
||||||
|
|
||||||
C_Player::~C_Player(void) {}
|
|
||||||
|
|
||||||
void C_Player::Init(ModelInitData modelInit)
|
|
||||||
{
|
{
|
||||||
C_Object::Init(modelInit);
|
|
||||||
|
|
||||||
Oyster::Graphics::API::PlayAnimation( this->model, L"movement" );
|
}
|
||||||
//Oyster::Graphics::API::Update(0.002f);
|
|
||||||
|
C_Player::~C_Player(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_Player::Init(ModelInitData modelInit)
|
||||||
|
{
|
||||||
|
return C_Object::Init(modelInit);
|
||||||
|
}
|
||||||
|
void C_Player::playAnimation(std::wstring animation, bool loop)
|
||||||
|
{
|
||||||
|
if(model)
|
||||||
|
Oyster::Graphics::API::PlayAnimation(model, L"movement", loop);
|
||||||
}
|
}
|
|
@ -5,15 +5,14 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
{
|
{
|
||||||
class C_Player : public C_DynamicObj
|
class C_Player : public C_DynamicObj
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
public:
|
public:
|
||||||
C_Player(void);
|
C_Player(void);
|
||||||
virtual ~C_Player(void);
|
virtual ~C_Player(void);
|
||||||
void Init(ModelInitData modelInit);
|
bool Init(ModelInitData modelInit);
|
||||||
|
void playAnimation(std::wstring animation, bool loop);
|
||||||
|
|
||||||
};
|
};};};
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,7 +10,7 @@ C_StaticObj::~C_StaticObj(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void C_StaticObj::Init(ModelInitData modelInit)
|
bool C_StaticObj::Init(ModelInitData modelInit)
|
||||||
{
|
{
|
||||||
C_Object::Init(modelInit);
|
return C_Object::Init(modelInit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ private:
|
||||||
public:
|
public:
|
||||||
C_StaticObj(void);
|
C_StaticObj(void);
|
||||||
virtual ~C_StaticObj(void);
|
virtual ~C_StaticObj(void);
|
||||||
void Init(ModelInitData modelInit);
|
bool Init(ModelInitData modelInit);
|
||||||
|
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
|
@ -10,7 +10,7 @@ C_UIobject::C_UIobject(void)
|
||||||
C_UIobject::~C_UIobject(void)
|
C_UIobject::~C_UIobject(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void C_UIobject::Init(ModelInitData modelInit)
|
bool C_UIobject::Init(ModelInitData modelInit)
|
||||||
{
|
{
|
||||||
C_Object::Init(modelInit);
|
return C_Object::Init(modelInit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace DanBias
|
||||||
public:
|
public:
|
||||||
C_UIobject(void);
|
C_UIobject(void);
|
||||||
virtual ~C_UIobject(void);
|
virtual ~C_UIobject(void);
|
||||||
void Init(ModelInitData modelInit);
|
bool Init(ModelInitData modelInit);
|
||||||
void setPos(Oyster::Math::Float4x4 world);
|
void setPos(Oyster::Math::Float4x4 world);
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
|
@ -59,6 +59,27 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ObjectType_SpawnPoint:
|
||||||
|
{
|
||||||
|
loadCgf = false;
|
||||||
|
ObjectHeader* header = new ObjectHeader;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
SpawnPointAttributes* spawn = new SpawnPointAttributes;
|
||||||
|
|
||||||
|
spawn->typeID = header->typeID;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
spawn->position[i] = header->position[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete header;
|
||||||
|
//objects.push_back(header);
|
||||||
|
objects.push_back(spawn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
//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.
|
//Unless they are changed to not be the same.
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
|
@ -133,13 +154,8 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
objects.push_back(header);
|
objects.push_back(header);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//this is a hotfix, fix so you only load the relevant data when the file is updated
|
||||||
|
|
||||||
case ObjectSpecialType_SpawnPoint:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Couldn't find specialType
|
//Couldn't find specialType
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace GameLogic
|
||||||
ObjectType_Static,
|
ObjectType_Static,
|
||||||
ObjectType_Dynamic,
|
ObjectType_Dynamic,
|
||||||
ObjectType_Light,
|
ObjectType_Light,
|
||||||
|
ObjectType_SpawnPoint,
|
||||||
//Etc
|
//Etc
|
||||||
|
|
||||||
ObjectType_NUM_OF_TYPES,
|
ObjectType_NUM_OF_TYPES,
|
||||||
|
@ -38,7 +39,6 @@ namespace GameLogic
|
||||||
ObjectSpecialType_CrystalShard,
|
ObjectSpecialType_CrystalShard,
|
||||||
ObjectSpecialType_JumpPad,
|
ObjectSpecialType_JumpPad,
|
||||||
ObjectSpecialType_Portal,
|
ObjectSpecialType_Portal,
|
||||||
ObjectSpecialType_SpawnPoint,
|
|
||||||
ObjectSpecialType_Player,
|
ObjectSpecialType_Player,
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,6 +206,13 @@ namespace GameLogic
|
||||||
virtual ~ObjectHeader(){}
|
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];
|
||||||
|
};
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
Special objects
|
Special objects
|
||||||
*************************************/
|
*************************************/
|
||||||
|
@ -234,6 +241,8 @@ namespace GameLogic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************
|
/************************************
|
||||||
Lights
|
Lights
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
|
@ -95,8 +95,28 @@ using namespace GameLogic;
|
||||||
{
|
{
|
||||||
int forceThreashHold = 200000; //how much force for the box to explode of the impact
|
int forceThreashHold = 200000; //how much force for the box to explode of the impact
|
||||||
|
|
||||||
|
Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed?
|
||||||
|
|
||||||
if(kineticEnergyLoss > forceThreashHold)
|
switch (realObj->GetObjectType())
|
||||||
|
{
|
||||||
|
case ObjectSpecialType::ObjectSpecialType_Generic:
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType::ObjectSpecialType_StandardBox:
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ObjectSpecialType::ObjectSpecialType_Player:
|
||||||
|
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
||||||
|
|
||||||
|
|
||||||
|
Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos;
|
||||||
|
Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius);
|
||||||
|
|
||||||
|
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
||||||
|
|
||||||
|
delete hitSphere;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*if(kineticEnergyLoss > forceThreashHold)
|
||||||
{
|
{
|
||||||
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag());
|
||||||
|
|
||||||
|
@ -107,7 +127,7 @@ using namespace GameLogic;
|
||||||
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode);
|
||||||
|
|
||||||
delete hitSphere;
|
delete hitSphere;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
|
void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args)
|
||||||
|
@ -123,7 +143,7 @@ using namespace GameLogic;
|
||||||
{
|
{
|
||||||
Player *hitPlayer = (Player*)realObj;
|
Player *hitPlayer = (Player*)realObj;
|
||||||
|
|
||||||
hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
//hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision());
|
||||||
//do shredding damage
|
//do shredding damage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ Game::PlayerData::PlayerData()
|
||||||
//create player with this rigid body
|
//create player with this rigid body
|
||||||
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
||||||
|
|
||||||
this->player->GetRigidBody()->SetCustomTag(this);
|
//this->player->GetRigidBody()->SetCustomTag(this);
|
||||||
player->EndFrame();
|
player->EndFrame();
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
|
|
|
@ -33,7 +33,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
case ObjectSpecialType_Sky:
|
case ObjectSpecialType_Sky:
|
||||||
{
|
{
|
||||||
float skySize = ((SkyAttributes*)obj)->skySize;
|
float skySize = ((SkyAttributes*)obj)->skySize;
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
//gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_World:
|
case ObjectSpecialType_World:
|
||||||
|
@ -96,7 +96,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_JumpPad:
|
case ObjectSpecialType_JumpPad:
|
||||||
{
|
{
|
||||||
float power = ((JumpPadAttributes*)obj)->power;
|
float power = 500; //((JumpPadAttributes*)obj)->power;
|
||||||
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction;
|
||||||
Oyster::Math::Float3 pushForce = dir * power;
|
Oyster::Math::Float3 pushForce = dir * power;
|
||||||
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++ , pushForce);
|
gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++ , pushForce);
|
||||||
|
@ -111,13 +111,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
case ObjectSpecialType_SpawnPoint:
|
case ObjectSpecialType_SpawnPoint:
|
||||||
{
|
{
|
||||||
// save
|
// save
|
||||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Player:
|
case ObjectSpecialType_Player:
|
||||||
{
|
{
|
||||||
// should not be read from the lvl format
|
// should not be read from the lvl format
|
||||||
//gameObj = new Player(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,objID++);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_Generic:
|
case ObjectSpecialType_Generic:
|
||||||
|
@ -206,12 +205,10 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
API::Instance().SetGravity(200);
|
API::Instance().SetGravity(200);
|
||||||
int objCount = objects.size();
|
int objCount = objects.size();
|
||||||
int modelCount = 100;
|
|
||||||
|
|
||||||
for (int i = 0; i < objCount; i++)
|
for (int i = 0; i < objCount; i++)
|
||||||
{
|
{
|
||||||
ObjectTypeHeader* obj = objects.at(i);
|
ObjectTypeHeader* obj = objects.at(i);
|
||||||
int id = obj->typeID;
|
|
||||||
switch (obj->typeID)
|
switch (obj->typeID)
|
||||||
{
|
{
|
||||||
case ObjectType::ObjectType_LevelMetaData:
|
case ObjectType::ObjectType_LevelMetaData:
|
||||||
|
@ -223,7 +220,6 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
break;
|
break;
|
||||||
case ObjectType::ObjectType_Static:
|
case ObjectType::ObjectType_Static:
|
||||||
{
|
{
|
||||||
|
|
||||||
ObjectHeader* staticObjData = ((ObjectHeader*)obj);
|
ObjectHeader* staticObjData = ((ObjectHeader*)obj);
|
||||||
staticObjData->ModelFile;
|
staticObjData->ModelFile;
|
||||||
|
|
||||||
|
@ -237,7 +233,6 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
|
|
||||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||||
{
|
{
|
||||||
|
|
||||||
rigidBody_Static = InitRigidBodyCube(staticObjData);
|
rigidBody_Static = InitRigidBodyCube(staticObjData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,22 +243,13 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
|
|
||||||
if(rigidBody_Static != NULL)
|
if(rigidBody_Static != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
// create game object
|
// create game object
|
||||||
Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static);
|
Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static);
|
||||||
//Object* staticGameObj = new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID);
|
|
||||||
if(staticGameObj != NULL)
|
if(staticGameObj != NULL)
|
||||||
{
|
{
|
||||||
this->staticObjects.Push((StaticObject*)staticGameObj);
|
this->staticObjects.Push((StaticObject*)staticGameObj);
|
||||||
//this->staticObjects[this->staticObjects.Size()-1]->objectID = modelCount++;
|
|
||||||
//rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID, 0));
|
|
||||||
//this->staticObjects[staticObjCount]->objectID = modelCount++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ObjectType::ObjectType_Dynamic:
|
case ObjectType::ObjectType_Dynamic:
|
||||||
|
@ -293,12 +279,9 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
{
|
{
|
||||||
// create game object
|
// create game object
|
||||||
Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic);
|
Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic);
|
||||||
//Object* dynamicGameObj =new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID);
|
|
||||||
if (dynamicGameObj != NULL)
|
if (dynamicGameObj != NULL)
|
||||||
{
|
{
|
||||||
this->dynamicObjects.Push((DynamicObject*)dynamicGameObj);
|
this->dynamicObjects.Push((DynamicObject*)dynamicGameObj);
|
||||||
//this->dynamicObjects[this->dynamicObjects.Size()-1]->objectID = modelCount++;
|
|
||||||
//rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,9 +317,6 @@ 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);
|
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, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||||
|
|
||||||
//this->dynamicObjects[i]->objectID = idCount++;
|
|
||||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
|
||||||
}
|
}
|
||||||
/*offset += nrOfBoxex;
|
/*offset += nrOfBoxex;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
for(int i =0; i< nrOfBoxex; i ++)
|
||||||
|
@ -365,31 +345,18 @@ void Level::InitiateLevel(float radius)
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add crystal
|
// 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);
|
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, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||||
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
|
|
||||||
//this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// add house
|
// 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);
|
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, ObjectSpecialType_Generic, idCount++));
|
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
|
||||||
rigidBody_House->SetCustomTag(this->staticObjects[0]);
|
|
||||||
//this->staticObjects[0]->objectID = idCount++;
|
|
||||||
|
|
||||||
// add jumppad
|
// add jumppad
|
||||||
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), 0, 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, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
||||||
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
|
|
||||||
//this->staticObjects[1]->objectID = idCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::AddPlayerToTeam(Player *player, int teamID)
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||||
|
|
|
@ -77,6 +77,7 @@ namespace GameLogic
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
||||||
StaticObject *levelObj;
|
StaticObject *levelObj;
|
||||||
int objID;
|
int objID;
|
||||||
|
Utility::DynamicMemory::DynamicArray<Oyster::Math::Float3> spawnPoints;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
#include "LevelParser.h"
|
#include "LevelParser.h"
|
||||||
|
|
||||||
#include "Loader.h"
|
#include "Loader.h"
|
||||||
#include "ParseFunctions.h"
|
#include "ParseFunctions.h"
|
||||||
|
|
||||||
|
@ -59,6 +58,27 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ObjectType_SpawnPoint:
|
||||||
|
{
|
||||||
|
loadCgf = false;
|
||||||
|
ObjectHeader* header = new ObjectHeader;
|
||||||
|
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
||||||
|
|
||||||
|
SpawnPointAttributes* spawn = new SpawnPointAttributes;
|
||||||
|
|
||||||
|
spawn->typeID = header->typeID;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
spawn->position[i] = header->position[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete header;
|
||||||
|
//objects.push_back(header);
|
||||||
|
objects.push_back(spawn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//This is by design, static and dynamic is using the same converter. Do not add anything inbetween them.
|
//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.
|
//Unless they are changed to not be the same.
|
||||||
case ObjectType_Static: case ObjectType_Dynamic:
|
case ObjectType_Static: case ObjectType_Dynamic:
|
||||||
|
@ -134,13 +154,6 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ObjectSpecialType_SpawnPoint:
|
|
||||||
{
|
|
||||||
loadCgf = false;
|
|
||||||
ObjectHeader* header = new ObjectHeader;
|
|
||||||
ParseObject(&buffer[counter], *header, counter, loadCgf);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//Couldn't find specialType
|
//Couldn't find specialType
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace GameLogic
|
||||||
ObjectType_Static,
|
ObjectType_Static,
|
||||||
ObjectType_Dynamic,
|
ObjectType_Dynamic,
|
||||||
ObjectType_Light,
|
ObjectType_Light,
|
||||||
|
ObjectType_SpawnPoint,
|
||||||
//Etc
|
//Etc
|
||||||
|
|
||||||
ObjectType_NUM_OF_TYPES,
|
ObjectType_NUM_OF_TYPES,
|
||||||
|
@ -38,7 +39,6 @@ namespace GameLogic
|
||||||
ObjectSpecialType_CrystalShard,
|
ObjectSpecialType_CrystalShard,
|
||||||
ObjectSpecialType_JumpPad,
|
ObjectSpecialType_JumpPad,
|
||||||
ObjectSpecialType_Portal,
|
ObjectSpecialType_Portal,
|
||||||
ObjectSpecialType_SpawnPoint,
|
|
||||||
ObjectSpecialType_Player,
|
ObjectSpecialType_Player,
|
||||||
ObjectSpecialType_Generic,
|
ObjectSpecialType_Generic,
|
||||||
|
|
||||||
|
@ -207,6 +207,11 @@ namespace GameLogic
|
||||||
virtual ~ObjectHeader(){}
|
virtual ~ObjectHeader(){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SpawnPointAttributes : public ObjectTypeHeader
|
||||||
|
{
|
||||||
|
ObjectSpecialType specialTypeID;
|
||||||
|
float position[3];
|
||||||
|
};
|
||||||
/************************************
|
/************************************
|
||||||
Special objects
|
Special objects
|
||||||
*************************************/
|
*************************************/
|
||||||
|
|
|
@ -20,33 +20,24 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
|
||||||
weapon = new Weapon(2,this);
|
weapon = new Weapon(2,this);
|
||||||
|
|
||||||
this->life = 100;
|
this->life = 100;
|
||||||
this->teamID = -1;
|
this->teamID = teamID;
|
||||||
this->playerState = PLAYER_STATE_IDLE;
|
this->playerState = PLAYER_STATE_IDLE;
|
||||||
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
this->lookDir = Oyster::Math::Float3(0,0,-1);
|
||||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
|
||||||
key_forward = 0;
|
key_forward = 0;
|
||||||
key_backward = 0;
|
key_backward = 0;
|
||||||
key_strafeRight = 0;
|
key_strafeRight = 0;
|
||||||
key_strafeLeft = 0;
|
key_strafeLeft = 0;
|
||||||
|
|
||||||
|
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
||||||
|
|
||||||
|
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||||
|
this->moveSpeed = 100;
|
||||||
|
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
||||||
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
:DynamicObject(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
this->rigidBody = rigidBody;
|
|
||||||
|
|
||||||
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;
|
|
||||||
Oyster::Math::Float frictionCoeff_Static = 0.4;
|
|
||||||
Oyster::Math::Float frictionCoeff_Dynamic = 0.3;
|
|
||||||
|
|
||||||
|
|
||||||
this->rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
|
|
||||||
this->rigidBody->SetAngularFactor(0.0f);
|
|
||||||
|
|
||||||
weapon = new Weapon(2,this);
|
weapon = new Weapon(2,this);
|
||||||
|
|
||||||
this->life = 100;
|
this->life = 100;
|
||||||
|
@ -58,10 +49,10 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
||||||
key_strafeRight = 0;
|
key_strafeRight = 0;
|
||||||
key_strafeLeft = 0;
|
key_strafeLeft = 0;
|
||||||
|
|
||||||
|
this->previousPosition = Oyster::Math::Float3(0,0,0);
|
||||||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||||
this->moveSpeed = 100;
|
this->moveSpeed = 100;
|
||||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
|
@ -78,12 +69,29 @@ void Player::BeginFrame()
|
||||||
//weapon->Update(0.002f);
|
//weapon->Update(0.002f);
|
||||||
Object::BeginFrame();
|
Object::BeginFrame();
|
||||||
|
|
||||||
if(this->moveDir != Oyster::Math::Float3::null)
|
//Oyster::Math::Float3 previousFall = this->previousMoveSpeed*-this->rigidBody->GetState().centerPos.GetNormalized();
|
||||||
|
//Oyster::Math::Float3 currentFall = this->rigidBody->GetLinearVelocity()*-this->rigidBody->GetState().centerPos.GetNormalized();
|
||||||
|
|
||||||
|
if(this->moveDir != Oyster::Math::Float3::null && this->playerState != PLAYER_STATE_JUMPING)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 velocity = this->rigidBody->GetLinearVelocity();
|
Oyster::Math::Float3 velocity = this->rigidBody->GetLinearVelocity();
|
||||||
Oyster::Math::Float3 lostVelocity = (this->previousMoveSpeed - velocity).GetMagnitude()*this->moveDir;
|
Oyster::Math::Float3 lostVelocity = (this->previousMoveSpeed - velocity).GetMagnitude()*this->moveDir;
|
||||||
this->rigidBody->SetLinearVelocity(velocity + lostVelocity - this->moveDir*this->moveSpeed );
|
this->rigidBody->SetLinearVelocity(velocity + lostVelocity - this->moveDir*this->moveSpeed );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
if(this->rigidBody->GetLamda() == 1.0f)
|
||||||
|
{
|
||||||
|
this->playerState = PLAYER_STATE_WALKING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this->moveDir != Oyster::Math::Float3::null)
|
||||||
|
{
|
||||||
|
Oyster::Math::Float3 velocity = this->rigidBody->GetLinearVelocity();
|
||||||
|
this->rigidBody->SetLinearVelocity(velocity - this->moveDir*this->moveSpeed );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->moveDir = Oyster::Math::Float3::null;
|
this->moveDir = Oyster::Math::Float3::null;
|
||||||
|
|
||||||
|
@ -116,9 +124,11 @@ void Player::BeginFrame()
|
||||||
{
|
{
|
||||||
this->moveDir.Normalize();
|
this->moveDir.Normalize();
|
||||||
this->rigidBody->SetLinearVelocity(this->moveDir*this->moveSpeed + this->rigidBody->GetLinearVelocity());
|
this->rigidBody->SetLinearVelocity(this->moveDir*this->moveSpeed + this->rigidBody->GetLinearVelocity());
|
||||||
this->previousMoveSpeed = this->rigidBody->GetLinearVelocity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->previousMoveSpeed = this->rigidBody->GetLinearVelocity();
|
||||||
|
this->previousPosition = this->rigidBody->GetState().centerPos;
|
||||||
|
|
||||||
|
|
||||||
this->weapon->Update(0.01f);
|
this->weapon->Update(0.01f);
|
||||||
}
|
}
|
||||||
|
@ -195,15 +205,18 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::
|
||||||
// this is the camera right vector
|
// this is the camera right vector
|
||||||
this->lookDir = lookDir;
|
this->lookDir = lookDir;
|
||||||
|
|
||||||
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
|
//Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
|
||||||
this->rigidBody->SetUpAndRight(up, right);
|
//this->rigidBody->SetUpAndRight(up, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Jump()
|
void Player::Jump()
|
||||||
{
|
{
|
||||||
|
if(this->rigidBody->GetLamda() < 1.0f)
|
||||||
|
{
|
||||||
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized();
|
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized();
|
||||||
this->rigidBody->ApplyImpulse(up *1500);
|
this->rigidBody->ApplyImpulse(up *1500);
|
||||||
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::IsWalking()
|
bool Player::IsWalking()
|
||||||
|
|
|
@ -89,6 +89,7 @@ namespace GameLogic
|
||||||
float key_jump;
|
float key_jump;
|
||||||
|
|
||||||
|
|
||||||
|
Oyster::Math::Float3 previousPosition;
|
||||||
Oyster::Math::Float3 moveDir;
|
Oyster::Math::Float3 moveDir;
|
||||||
Oyster::Math::Float moveSpeed;
|
Oyster::Math::Float moveSpeed;
|
||||||
Oyster::Math::Float3 previousMoveSpeed;
|
Oyster::Math::Float3 previousMoveSpeed;
|
||||||
|
|
|
@ -14,25 +14,25 @@ StaticObject::StaticObject()
|
||||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||||
:Object(rigidBody, EventOnCollision, type, objectID)
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
rigidBody->SetMass(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||||
:Object(rigidBody, EventOnCollision, type, objectID)
|
:Object(rigidBody, EventOnCollision, type, objectID)
|
||||||
{
|
{
|
||||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
rigidBody->SetMass(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||||
{
|
{
|
||||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
rigidBody->SetMass(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision)
|
||||||
{
|
{
|
||||||
this->extraDamageOnCollision = extraDamageOnCollision;
|
this->extraDamageOnCollision = extraDamageOnCollision;
|
||||||
//use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static
|
rigidBody->SetMass(0);
|
||||||
}
|
}
|
||||||
StaticObject::~StaticObject(void)
|
StaticObject::~StaticObject(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ ICustomBody* API_Impl::AddCharacter(::Oyster::Math::Float height, ::Oyster::Math
|
||||||
this->customBodies.push_back(body);
|
this->customBodies.push_back(body);
|
||||||
|
|
||||||
state.centerPos = position;
|
state.centerPos = position;
|
||||||
state.reach = Float3(radius, height*0.5f, radius);
|
state.reach = Float3(radius, height, radius);
|
||||||
state.dynamicFrictionCoeff = 0.5f;
|
state.dynamicFrictionCoeff = 0.5f;
|
||||||
state.staticFrictionCoeff = 0.5f;
|
state.staticFrictionCoeff = 0.5f;
|
||||||
state.quaternion = Quaternion(Float3(rotation.xyz), rotation.w);
|
state.quaternion = Quaternion(Float3(rotation.xyz), rotation.w);
|
||||||
|
@ -230,7 +230,9 @@ void API_Impl::UpdateWorld()
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < this->customBodies.size(); i++ )
|
for(unsigned int i = 0; i < this->customBodies.size(); i++ )
|
||||||
{
|
{
|
||||||
|
SimpleRigidBody* simpleBody = dynamic_cast<SimpleRigidBody*>(this->customBodies[i]);
|
||||||
this->customBodies[i]->SetGravity(-(this->customBodies[i]->GetState().centerPos - this->gravityPoint).GetNormalized()*this->gravity);
|
this->customBodies[i]->SetGravity(-(this->customBodies[i]->GetState().centerPos - this->gravityPoint).GetNormalized()*this->gravity);
|
||||||
|
simpleBody->PreStep(this->dynamicsWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep);
|
||||||
|
|
|
@ -345,3 +345,60 @@ void SimpleRigidBody::SetCustomTag( void *ref )
|
||||||
{
|
{
|
||||||
this->customTag = ref;
|
this->customTag = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
|
||||||
|
{
|
||||||
|
btTransform xform;
|
||||||
|
this->rigidBody->getMotionState()->getWorldTransform (xform);
|
||||||
|
btVector3 down = -xform.getBasis()[1];
|
||||||
|
btVector3 forward = xform.getBasis()[2];
|
||||||
|
down.normalize ();
|
||||||
|
forward.normalize();
|
||||||
|
|
||||||
|
this->raySource[0] = xform.getOrigin();
|
||||||
|
this->raySource[1] = xform.getOrigin();
|
||||||
|
|
||||||
|
this->rayTarget[0] = this->raySource[0] + down * this->state.reach.y * btScalar(1.1);
|
||||||
|
this->rayTarget[1] = this->raySource[1] + forward * this->state.reach.y * btScalar(1.1);
|
||||||
|
|
||||||
|
class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClosestNotMe (btRigidBody* me) : btCollisionWorld::ClosestRayResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0))
|
||||||
|
{
|
||||||
|
m_me = me;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
|
||||||
|
{
|
||||||
|
if (rayResult.m_collisionObject == m_me)
|
||||||
|
return 1.0;
|
||||||
|
|
||||||
|
return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace);
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
btRigidBody* m_me;
|
||||||
|
};
|
||||||
|
|
||||||
|
ClosestNotMe rayCallback(this->rigidBody);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
rayCallback.m_closestHitFraction = 1.0;
|
||||||
|
if((this->raySource[i] - this->rayTarget[i]).length() != 0)
|
||||||
|
collisionWorld->rayTest (this->raySource[i], this->rayTarget[i], rayCallback);
|
||||||
|
if (rayCallback.hasHit())
|
||||||
|
{
|
||||||
|
this->rayLambda[i] = rayCallback.m_closestHitFraction;
|
||||||
|
} else {
|
||||||
|
this->rayLambda[i] = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float SimpleRigidBody::GetLamda() const
|
||||||
|
{
|
||||||
|
return this->rayLambda[0];
|
||||||
|
}
|
|
@ -58,11 +58,17 @@ namespace Oyster
|
||||||
void SetCustomTag( void *ref );
|
void SetCustomTag( void *ref );
|
||||||
void* GetCustomTag() const;
|
void* GetCustomTag() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Class specific
|
// Class specific
|
||||||
void SetCollisionShape(btCollisionShape* shape);
|
void SetCollisionShape(btCollisionShape* shape);
|
||||||
void SetMotionState(btDefaultMotionState* motionState);
|
void SetMotionState(btDefaultMotionState* motionState);
|
||||||
void SetRigidBody(btRigidBody* rigidBody);
|
void SetRigidBody(btRigidBody* rigidBody);
|
||||||
|
|
||||||
|
void PreStep(const btCollisionWorld* collisionWorld);
|
||||||
|
|
||||||
|
float GetLamda() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
btCollisionShape* collisionShape;
|
btCollisionShape* collisionShape;
|
||||||
|
@ -76,7 +82,11 @@ namespace Oyster
|
||||||
|
|
||||||
void *customTag;
|
void *customTag;
|
||||||
|
|
||||||
::Oyster::Math::Float3 gravity;
|
Math::Float3 gravity;
|
||||||
|
|
||||||
|
btVector3 raySource[2];
|
||||||
|
btVector3 rayTarget[2];
|
||||||
|
btScalar rayLambda[2];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,8 @@ namespace Oyster
|
||||||
* @param ref: Anything castable to a void pointer, the engine won't care.
|
* @param ref: Anything castable to a void pointer, the engine won't care.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void SetCustomTag( void *ref ) = 0;
|
virtual void SetCustomTag( void *ref ) = 0;
|
||||||
|
|
||||||
|
virtual float GetLamda() const = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Struct
|
namespace Struct
|
||||||
{
|
{
|
||||||
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float dynamicFrictionCoeff, const ::Oyster::Math::Float3 ¢erPos, const ::Oyster::Math::Quaternion& quaternion)
|
inline CustomBodyState::CustomBodyState( ::Oyster::Math::Float mass, ::Oyster::Math::Float3 reach, ::Oyster::Math::Float restitutionCoeff, ::Oyster::Math::Float staticFrictionCoeff, ::Oyster::Math::Float dynamicFrictionCoeff, const ::Oyster::Math::Float3 ¢erPos, const ::Oyster::Math::Quaternion& quaternion)
|
||||||
{
|
{
|
||||||
this->mass = mass;
|
this->mass = mass;
|
||||||
|
this->reach = reach;
|
||||||
this->restitutionCoeff = restitutionCoeff;
|
this->restitutionCoeff = restitutionCoeff;
|
||||||
this->staticFrictionCoeff = staticFrictionCoeff;
|
this->staticFrictionCoeff = staticFrictionCoeff;
|
||||||
this->dynamicFrictionCoeff = dynamicFrictionCoeff;
|
this->dynamicFrictionCoeff = dynamicFrictionCoeff;
|
||||||
|
@ -24,6 +25,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
this->mass = state.mass;
|
this->mass = state.mass;
|
||||||
this->restitutionCoeff = state.restitutionCoeff;
|
this->restitutionCoeff = state.restitutionCoeff;
|
||||||
|
this->reach = state.reach;
|
||||||
this->staticFrictionCoeff = state.staticFrictionCoeff;
|
this->staticFrictionCoeff = state.staticFrictionCoeff;
|
||||||
this->dynamicFrictionCoeff = state.dynamicFrictionCoeff;
|
this->dynamicFrictionCoeff = state.dynamicFrictionCoeff;
|
||||||
this->centerPos = state.centerPos;
|
this->centerPos = state.centerPos;
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
// Default constructor
|
// Default constructor
|
||||||
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
|
CustomBodyState( ::Oyster::Math::Float mass = 1.0f,
|
||||||
|
::Oyster::Math::Float3 reach = ::Oyster::Math::Float3(0,0,0),
|
||||||
::Oyster::Math::Float restitutionCoeff = 0.5f,
|
::Oyster::Math::Float restitutionCoeff = 0.5f,
|
||||||
::Oyster::Math::Float staticFrictionCoeff = 1.0f,
|
::Oyster::Math::Float staticFrictionCoeff = 1.0f,
|
||||||
::Oyster::Math::Float dynamicFrictionCoeff = 1.0f,
|
::Oyster::Math::Float dynamicFrictionCoeff = 1.0f,
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace Utility
|
||||||
|
|
||||||
template <typename T> void DynamicArray<T>::Remove(unsigned int index)
|
template <typename T> void DynamicArray<T>::Remove(unsigned int index)
|
||||||
{
|
{
|
||||||
assert(index > (unsigned int) this->size);
|
assert(index < (unsigned int) this->size);
|
||||||
|
|
||||||
T* temp = new T[this->capacity - 1];
|
T* temp = new T[this->capacity - 1];
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace Oyster
|
||||||
Oyster::Math::Float3 pos;
|
Oyster::Math::Float3 pos;
|
||||||
Oyster::Math::Float2 uv;
|
Oyster::Math::Float2 uv;
|
||||||
Oyster::Math::Float3 normal;
|
Oyster::Math::Float3 normal;
|
||||||
Oyster::Math::Float3 tangent;
|
|
||||||
Oyster::Math::Float3 biTangent;
|
|
||||||
Oyster::Math::Float4 boneIndex;
|
Oyster::Math::Float4 boneIndex;
|
||||||
Oyster::Math::Float4 boneWeights;
|
Oyster::Math::Float4 boneWeights;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,12 +5,11 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define DANFILEVERSIONMAJOR 1
|
#define DANFILEVERSIONMAJOR 2
|
||||||
#define DANFILEVERSIONMINOR 1
|
#define DANFILEVERSIONMINOR 1
|
||||||
|
|
||||||
#define FILEHEADERSIZE 8
|
#define FILEHEADERSIZE 8
|
||||||
#define VERTEXHEADERSIZE 4
|
#define VERTEXHEADERSIZE 4
|
||||||
#define VERTEXSIZE 88
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,7 +219,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[])
|
||||||
delete[] buffer; // ( note: may crash here.)
|
delete[] buffer; // ( note: may crash here.)
|
||||||
|
|
||||||
// Fetch all vertices
|
// Fetch all vertices
|
||||||
unsigned int bufferSize = VERTEXSIZE * vertexHeader.numVertices;
|
unsigned int bufferSize = sizeof(Vertex) * vertexHeader.numVertices;
|
||||||
buffer = new char[bufferSize];
|
buffer = new char[bufferSize];
|
||||||
danFile.read(buffer, bufferSize);
|
danFile.read(buffer, bufferSize);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
|
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
|
||||||
tmpInst.offset=text[i]-32;
|
tmpInst.offset=text[i]-32;
|
||||||
tmpInst.pos=i*(FontSize * 0.8f * TEXT_SPACING);
|
tmpInst.pos=i*(FontSize * 0.7f * TEXT_SPACING);
|
||||||
if(tmpInst.pos > size.x)
|
if(tmpInst.pos > size.x)
|
||||||
{
|
{
|
||||||
text = text.substr(0,i-1);
|
text = text.substr(0,i-1);
|
||||||
|
|
|
@ -340,13 +340,11 @@ namespace Oyster
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
||||||
{ "BITANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 44, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
|
||||||
{ "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 56, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 56, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
{ "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout);
|
Shader::CreateInputLayout(indesc,5,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout);
|
||||||
Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData);
|
Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData);
|
||||||
Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData);
|
Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData);
|
||||||
|
|
|
@ -3,8 +3,6 @@ struct VertexIn
|
||||||
float3 pos : POSITION;
|
float3 pos : POSITION;
|
||||||
float2 UV : TEXCOORD;
|
float2 UV : TEXCOORD;
|
||||||
float3 normal : NORMAL;
|
float3 normal : NORMAL;
|
||||||
float3 tangent : TANGENT;
|
|
||||||
float3 biTangent : BITANGENT;
|
|
||||||
float4 boneIndex : BONEINDEX;
|
float4 boneIndex : BONEINDEX;
|
||||||
float4 boneWeight : BONEWEIGHT;
|
float4 boneWeight : BONEWEIGHT;
|
||||||
};
|
};
|
||||||
|
|
|
@ -170,10 +170,10 @@ HRESULT InitDirect3D()
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan");
|
m = Oyster::Graphics::API::CreateModel(L"building_corporation.dan");
|
||||||
//m->WorldMatrix.m[0][0] = 50;
|
m->WorldMatrix.m[0][0] = 0.0002f;
|
||||||
//m->WorldMatrix.m[1][1] = 50;
|
m->WorldMatrix.m[1][1] = 0.0002f;
|
||||||
//m->WorldMatrix.m[2][2] = 0.00000005f;
|
m->WorldMatrix.m[2][2] = 0.0002f;
|
||||||
m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
||||||
m2->Tint = Oyster::Math::Float3(0.1f,0.1f,1);
|
m2->Tint = Oyster::Math::Float3(0.1f,0.1f,1);
|
||||||
m3 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
m3 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan");
|
||||||
|
@ -223,7 +223,11 @@ HRESULT Update(float deltaTime)
|
||||||
m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
|
m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null);
|
||||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
|
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null);
|
||||||
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * -angle,Oyster::Math::Float3(-4,0,0),Oyster::Math::Float3::null);
|
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * -angle,Oyster::Math::Float3(-4,0,0),Oyster::Math::Float3::null);
|
||||||
//Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;
|
Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity;
|
||||||
|
ma.m[0][0] = 0.2f;
|
||||||
|
ma.m[1][1] = 0.2f;
|
||||||
|
ma.m[2][2] = 0.2f;
|
||||||
|
m->WorldMatrix = m->WorldMatrix * ma;
|
||||||
Oyster::Graphics::API::Update(deltaTime);
|
Oyster::Graphics::API::Update(deltaTime);
|
||||||
//m2->Animation.data.AnimationTime += deltaTime;// * 0.5f;
|
//m2->Animation.data.AnimationTime += deltaTime;// * 0.5f;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue