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

This commit is contained in:
dean11 2014-02-19 10:48:04 +01:00
commit aa19904fa0
7 changed files with 85 additions and 111 deletions

View File

@ -46,7 +46,7 @@ using namespace GameLogic;
break; break;
case ObjectSpecialType::ObjectSpecialType_CrystalFormation: case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision()); PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->GetExtraDamageOnCollision());
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break; break;
} }
@ -181,7 +181,7 @@ using namespace GameLogic;
} }
} }
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{ {
return Physics::ICustomBody::SubscriptMessage_none; return Physics::ICustomBody::SubscriptMessage_none;
} }

View File

@ -68,12 +68,33 @@ void Game::GetAllPlayerPositions() const
Game::PlayerData* Game::CreatePlayer() Game::PlayerData* Game::CreatePlayer()
{ {
// Find a free space in array or insert at end // Find a free space in array or insert at end
int i = InsertObject(this->players, (PlayerData*)0); int insert = InsertObject(this->players, (PlayerData*)0);
int freeID = 0;
bool found = false;
this->players[i] = new PlayerData(); for(int i = 0; i < 100; i++)
this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove); {
found = true;
freeID = i;
return this->players[i]; for(int j = 0; j < players.Size(); j++)
{
if(this->players[j] && this->players[j]->GetID() == freeID)
{
found = false;
}
if(!found) break;
}
if(found) break;
}
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
return this->players[insert];
} }
Game::LevelData* Game::CreateLevel(const wchar_t mapName[255]) Game::LevelData* Game::CreateLevel(const wchar_t mapName[255])
@ -95,21 +116,15 @@ bool Game::NewFrame()
{ {
for (unsigned int i = 0; i < this->players.Size(); i++) for (unsigned int i = 0; i < this->players.Size(); i++)
{ {
if(this->players[i]->player) this->players[i]->player->BeginFrame(); if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
} }
API::Instance().UpdateWorld(); API::Instance().UpdateWorld();
for (unsigned int i = 0; i < this->players.Size(); i++) for (unsigned int i = 0; i < this->players.Size(); i++)
{ {
if(this->players[i]->player) this->players[i]->player->EndFrame(); if(this->players[i] && this->players[i]->player) this->players[i]->player->EndFrame();
gameInstance.onMoveFnc(this->players[i]);
} }
for (unsigned int i = 0; i < this->level->level->dynamicObjects.Size(); i++)
{
gameInstance.onMoveFnc(this->level->level->dynamicObjects[i]);
}
return true; return true;
} }

View File

@ -21,13 +21,23 @@ Game::PlayerData::PlayerData()
rigidBody->SetAngularFactor(0.0f); rigidBody->SetAngularFactor(0.0f);
//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);
player->EndFrame();
} }
Game::PlayerData::PlayerData(int playerID,int teamID) Game::PlayerData::PlayerData(int playerID,int teamID)
{ {
this->player = new Player(); Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0);
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
Oyster::Math::Float mass = 60;
Oyster::Math::Float restitutionCoeff = 0.5f;
Oyster::Math::Float frictionCoeff_Static = 0.4f;
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
//create rigid body
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, ObjectSpecialType_Player,playerID,teamID);
} }
Game::PlayerData::~PlayerData() Game::PlayerData::~PlayerData()
{ {

View File

@ -26,14 +26,14 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
{ {
case ObjectSpecialType_None: case ObjectSpecialType_None:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
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::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_World: case ObjectSpecialType_World:
@ -44,21 +44,21 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
float worldSize = ((WorldAttributes*)obj)->worldSize; float worldSize = ((WorldAttributes*)obj)->worldSize;
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize; float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_Building: case ObjectSpecialType_Building:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
case ObjectSpecialType_Stone: case ObjectSpecialType_Stone:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_StandardBox: case ObjectSpecialType_StandardBox:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_RedExplosiveBox: case ObjectSpecialType_RedExplosiveBox:
@ -75,24 +75,24 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
// break; // break;
case ObjectSpecialType_SpikeBox: case ObjectSpecialType_SpikeBox:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_Spike: case ObjectSpecialType_Spike:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_CrystalFormation: case ObjectSpecialType_CrystalFormation:
{ {
int dmg = 50; int dmg = 50;
//gameObj = new Crystal(rigidBody); //gameObj = new Crystal(rigidBody);
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_CrystalShard: case ObjectSpecialType_CrystalShard:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
case ObjectSpecialType_JumpPad: case ObjectSpecialType_JumpPad:
@ -122,12 +122,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
break; break;
case ObjectSpecialType_Generic: case ObjectSpecialType_Generic:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
default: default:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID++);
} }
break; break;
} }
@ -360,14 +360,14 @@ bool Level::InitiateLevel(float radius)
{ {
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f); rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 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::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
} }
/*offset += nrOfBoxex; /*offset += nrOfBoxex;
for(int i =0; i< nrOfBoxex; i ++) for(int i =0; i< nrOfBoxex; i ++)
{ {
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,5, -605 -( i*5)), 5); 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,5, -605 -( i*5)), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
} }
@ -376,7 +376,7 @@ bool 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(200, 620 + ( i*7), 0), 5); rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(200, 620 + ( i*7), 0), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
} }
offset += nrOfBoxex; offset += nrOfBoxex;
@ -384,18 +384,18 @@ bool 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(5, 605 + i*5, 0), 5); rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(5, 605 + i*5, 0), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
}*/ }*/
// add crystal // add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 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.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 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::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
// add house // add house
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f); ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 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::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
// add jumppad // add jumppad

View File

@ -15,11 +15,11 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
Object::Object() 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->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 = ObjectSpecialType_Unknown; this->type = ObjectSpecialType_Unknown;
this->objectID = -1; this->objectID = -1;
this->scale = Float3(1.0f, 1.0f, 1.0f);
} }
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID) Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
@ -48,39 +48,12 @@ Object::~Object(void)
} }
ObjectSpecialType Object::GetObjectType() const
void Object::SetOnCollision(OnCollisionCallback func)
{ {
return this->type; this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
}
int Object::GetID() const
{
return this->objectID;
} }
Oyster::Physics::ICustomBody* Object::GetRigidBody()
{
return this->rigidBody;
}
void Object::BeginFrame()
{
}
// update physic
void Object::EndFrame()
{
}
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
{
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
}
void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss))
{
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
}
Oyster::Math::Float3 Object::GetPosition() Oyster::Math::Float3 Object::GetPosition()
{ {
@ -94,21 +67,9 @@ Oyster::Math::Quaternion Object::GetRotation()
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.quaternion; return state.quaternion;
} }
Oyster::Math::Float3 Object::GetScale()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return Float3();
}
Oyster::Math::Float4x4 Object::GetOrientation() Oyster::Math::Float4x4 Object::GetOrientation()
{ {
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.GetOrientation(); return state.GetOrientation();
} }
Oyster::Math::Float Object::getExtraDamageOnCollision()
{
return this->extraDamageOnCollision;
}

View File

@ -16,47 +16,39 @@ namespace GameLogic
class Object :public IObjectData class Object :public IObjectData
{ {
public:
typedef Oyster::Physics::ICustomBody::SubscriptMessage (*OnCollisionCallback)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss);
public: public:
Object(); Object();
Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID); Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID); Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
~Object(void); ~Object(void);
ObjectSpecialType GetObjectType() const override; inline ObjectSpecialType GetObjectType() const override { return this->type; }
int GetID() const override; inline int GetID() const override { return this->objectID; }
void setID(int id); inline Oyster::Math::Float3 GetScale() override { return this->scale; }
Oyster::Math::Float3 GetPosition() override; inline Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override; inline Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override; inline Oyster::Math::Float4x4 GetOrientation() override;
Oyster::Math::Float4x4 GetOrientation() override; inline Oyster::Physics::ICustomBody* GetRigidBody() { return this->rigidBody; }
inline Oyster::Math::Float GetExtraDamageOnCollision() { return this->extraDamageOnCollision; }
Oyster::Math::Float getExtraDamageOnCollision(); virtual void BeginFrame() { };
virtual void EndFrame() { };
// API overrides void SetOnCollision(OnCollisionCallback func);
Oyster::Physics::ICustomBody* GetRigidBody();
virtual void BeginFrame();
virtual void EndFrame();
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
public: //TODO: Hax This should be private when level is dynamic
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
protected: protected:
Oyster::Physics::ICustomBody *rigidBody; Oyster::Physics::ICustomBody *rigidBody;
static const Game* gameInstance; static const Game* gameInstance;
Oyster::Math::Float3 currLook;
Oyster::Math::Float3 newLook; Oyster::Math::Float3 lookDirection; //The look direction for the camera
Oyster::Math::Float3 forwardDirection; //The forward direction of the rigid body
Oyster::Math::Float3 scale; //The scale of both rigid body and the mesh
ObjectSpecialType type; ObjectSpecialType type;
int objectID; int objectID;

View File

@ -337,11 +337,7 @@ namespace Utility
template<typename ValueType> template<typename ValueType>
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max ) inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
{ { return value < min ? Max( value, max ) : min; }
if( value < min ) return min;
if( value > max ) return max;
return value;
}
template<typename ValueType> template<typename ValueType>
inline ValueType Average( const ValueType &valueA, const ValueType &valueB ) inline ValueType Average( const ValueType &valueA, const ValueType &valueB )