Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
This commit is contained in:
commit
a591903d8f
|
@ -0,0 +1,277 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<diagram program="umlet" version="12.0">
|
||||||
|
<zoom_level>8</zoom_level>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Package</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>552</x>
|
||||||
|
<y>320</y>
|
||||||
|
<w>584</w>
|
||||||
|
<h>368</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>LevelLoader</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>440</x>
|
||||||
|
<y>88</y>
|
||||||
|
<w>128</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>GameLogic
|
||||||
|
<<Erik>></panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>768</x>
|
||||||
|
<y>472</y>
|
||||||
|
<w>136</w>
|
||||||
|
<h>104</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||||
|
<additional_attributes>120;24;120;88;24;88</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>560</x>
|
||||||
|
<y>544</y>
|
||||||
|
<w>232</w>
|
||||||
|
<h>136</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes><<Interface>>
|
||||||
|
Parser
|
||||||
|
--
|
||||||
|
Functions:
|
||||||
|
vector<struct> Parse();
|
||||||
|
-
|
||||||
|
Privates:
|
||||||
|
enum headerType;
|
||||||
|
const int FileHeaderSize;
|
||||||
|
const int FileVersion;
|
||||||
|
</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>624</x>
|
||||||
|
<y>208</y>
|
||||||
|
<w>80</w>
|
||||||
|
<h>24</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>LevelLoader
|
||||||
|
</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>640</x>
|
||||||
|
<y>208</y>
|
||||||
|
<w>40</w>
|
||||||
|
<h>168</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>24;24;24;152</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>384</x>
|
||||||
|
<y>176</y>
|
||||||
|
<w>256</w>
|
||||||
|
<h>56</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=->>>>
|
||||||
|
m1=1..1
|
||||||
|
m2=1..1
|
||||||
|
<Knows about</panel_attributes>
|
||||||
|
<additional_attributes>240;40;24;40</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Package</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>248</x>
|
||||||
|
<y>320</y>
|
||||||
|
<w>248</w>
|
||||||
|
<h>160</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Defines</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>800</x>
|
||||||
|
<y>360</y>
|
||||||
|
<w>208</w>
|
||||||
|
<h>136</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes><<Interface>>
|
||||||
|
Loader
|
||||||
|
--
|
||||||
|
Functions:
|
||||||
|
wchar* LoadFile(string fileName);
|
||||||
|
Model* LoadModel(string modelName);
|
||||||
|
Model* LoadModel(int modelID);
|
||||||
|
-
|
||||||
|
Privates:</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>328</x>
|
||||||
|
<y>208</y>
|
||||||
|
<w>80</w>
|
||||||
|
<h>24</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Defines</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>256</x>
|
||||||
|
<y>360</y>
|
||||||
|
<w>232</w>
|
||||||
|
<h>104</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Defines.h
|
||||||
|
<<Header file>>
|
||||||
|
--
|
||||||
|
Enum ObjectType(static, dynamic, specials);
|
||||||
|
.
|
||||||
|
Struct static;
|
||||||
|
Struct dynamic;
|
||||||
|
Struct specials</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>680</x>
|
||||||
|
<y>176</y>
|
||||||
|
<w>152</w>
|
||||||
|
<h>56</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=-
|
||||||
|
m1=1..1
|
||||||
|
m2=1..1
|
||||||
|
Uses></panel_attributes>
|
||||||
|
<additional_attributes>24;40;136;40</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>816</x>
|
||||||
|
<y>192</y>
|
||||||
|
<w>128</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Resource Loader
|
||||||
|
<<Dennis>><<Singleton></panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>928</x>
|
||||||
|
<y>560</y>
|
||||||
|
<w>200</w>
|
||||||
|
<h>120</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Collection of functions
|
||||||
|
<<lots of functions>>
|
||||||
|
--
|
||||||
|
functions for creating the right structs</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>768</x>
|
||||||
|
<y>576</y>
|
||||||
|
<w>176</w>
|
||||||
|
<h>56</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=-
|
||||||
|
m1=1..1
|
||||||
|
m2=1..1
|
||||||
|
Uses></panel_attributes>
|
||||||
|
<additional_attributes>24;40;160;40</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>560</x>
|
||||||
|
<y>360</y>
|
||||||
|
<w>232</w>
|
||||||
|
<h>136</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>LevelLoader
|
||||||
|
<<API>><Interface>>
|
||||||
|
--
|
||||||
|
Functions:
|
||||||
|
vector<struct> LoadLevel(String fileName);
|
||||||
|
struct LoadLevelHeader(String fileName);
|
||||||
|
-
|
||||||
|
Privates:
|
||||||
|
|
||||||
|
</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>344</x>
|
||||||
|
<y>208</y>
|
||||||
|
<w>40</w>
|
||||||
|
<h>168</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>24;24;24;152</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>840</x>
|
||||||
|
<y>208</y>
|
||||||
|
<w>88</w>
|
||||||
|
<h>168</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=.
|
||||||
|
<Uses</panel_attributes>
|
||||||
|
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>656</x>
|
||||||
|
<y>472</y>
|
||||||
|
<w>40</w>
|
||||||
|
<h>88</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||||
|
<additional_attributes>24;72;24;24</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>544</x>
|
||||||
|
<y>64</y>
|
||||||
|
<w>136</w>
|
||||||
|
<h>160</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=lt=->>>>
|
||||||
|
m1=1..1
|
||||||
|
m2=1..1
|
||||||
|
Uses></panel_attributes>
|
||||||
|
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
|
||||||
|
</element>
|
||||||
|
</diagram>
|
|
@ -3,71 +3,68 @@
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
struct AttatchmentMassDriver::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
|
|
||||||
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
AttatchmentMassDriver::AttatchmentMassDriver(void)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
AttatchmentMassDriver::AttatchmentMassDriver(Player &owner)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
this->owner = &owner;
|
this->owner = &owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AttatchmentMassDriver::~AttatchmentMassDriver(void)
|
AttatchmentMassDriver::~AttatchmentMassDriver(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
|
* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage)
|
void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
//switch case to determin what functionallity to use in the attatchment
|
//switch case to determin what functionallity to use in the attatchment
|
||||||
switch (usage)
|
switch (usage)
|
||||||
{
|
{
|
||||||
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS:
|
||||||
ForcePush(usage);
|
ForcePush(usage,dt);
|
||||||
break;
|
break;
|
||||||
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS:
|
||||||
ForcePull(usage);
|
ForcePull(usage,dt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pushes objects in a cone in front of the weapon when fired
|
* Pushes objects in a cone in front of the weapon when fired
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage)
|
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
//create coneRigidBody that will then collide with object and push them in the aimed direction
|
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
|
||||||
|
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
|
||||||
|
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
|
||||||
|
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
|
||||||
|
|
||||||
|
//Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,ForcePushAction);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack)
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage)
|
void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
//Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100);
|
Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState();
|
||||||
|
|
||||||
|
//do something with state
|
||||||
|
state.ApplyLinearImpulse(Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt));
|
||||||
|
|
||||||
|
this->owner->GetRigidBody()->SetState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,30 +15,31 @@ namespace GameLogic
|
||||||
~AttatchmentMassDriver(void);
|
~AttatchmentMassDriver(void);
|
||||||
|
|
||||||
|
|
||||||
void UseAttatchment(const WEAPON_FIRE &usage);
|
void UseAttatchment(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pushes objects and players in a cone in front of the player
|
* Pushes objects and players in a cone in front of the player
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param fireInput: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForcePush(const WEAPON_FIRE &usage);
|
void ForcePush(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Pulls the player forward, this is a movement tool
|
* Pulls the player forward, this is a movement tool
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param fireInput: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForcePull(const WEAPON_FIRE &usage);
|
void ForcePull(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
* Sucks objects towards the player, the player can then pick up an object and throw it as a projectile
|
||||||
* @param fireInput: allows switching on different functionality in this specific function
|
* @param fireInput: allows switching on different functionality in this specific function
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void ForceSuck(const WEAPON_FIRE &usage);
|
void ForceSuck(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
|
void ForcePushAction(Oyster::Physics::ICustomBody *obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
|
||||||
PrivateData *myData;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,62 +1,65 @@
|
||||||
#include "CollisionManager.h"
|
|
||||||
#include "PhysicsAPI.h"
|
#include "PhysicsAPI.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "Level.h"
|
||||||
|
#include "AttatchmentMassDriver.h"
|
||||||
|
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
void PlayerVBox(Player &player, DynamicObject &box);
|
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
|
//Physics::ICustomBody::SubscriptMessage
|
||||||
Physics::ICustomBody::SubscriptMessage CollisionManager::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj)
|
void Player::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
//Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef));
|
Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag()));
|
||||||
//Object *realObj = (Object*)obj->gameObjectRef;
|
Object *realObj = (Object*)obj->GetCustomTag();
|
||||||
|
|
||||||
//switch (realObj->GetType())
|
switch (realObj->GetType())
|
||||||
//{
|
{
|
||||||
//case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
case OBJECT_H::OBJECT_TYPE_GENERIC:
|
||||||
// PlayerVBox(*player,(*(DynamicObject*) realObj));
|
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||||
// break;
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
//case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
break;
|
||||||
//
|
|
||||||
// break;
|
case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
||||||
//}
|
PlayerVBox(*player,(*(DynamicObject*) realObj), kineticEnergyLoss);
|
||||||
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
|
break;
|
||||||
|
case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
||||||
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerVBox(Player &player, DynamicObject &box)
|
void PlayerVBox(Player &player, DynamicObject &box, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
|
//use kinetic energyloss of the collision in order too determin how much damage to take
|
||||||
|
//use as part of the damage algorithm
|
||||||
|
player.DamageLife(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
|
{
|
||||||
|
//Collision between a player and a general static or dynamic object
|
||||||
|
//use kinetic energyloss of the collision in order too determin how much damage to take
|
||||||
|
//use as part of the damage algorithm
|
||||||
player.DamageLife(20);
|
player.DamageLife(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
Physics::ICustomBody::SubscriptMessage CollisionManager::BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj)
|
//Oyster::Physics::ICustomBody::SubscriptMessage
|
||||||
|
void Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||||
{
|
{
|
||||||
if(rigidBodyBox == 0)
|
//return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||||
{
|
|
||||||
return Physics::ICustomBody::SubscriptMessage::SubscriptMessage_none;
|
|
||||||
}
|
|
||||||
//DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef;
|
|
||||||
//Object *realObj = (Object*)obj->gameObjectRef;
|
|
||||||
|
|
||||||
//switch (realObj->GetType())
|
|
||||||
//{
|
|
||||||
//case OBJECT_TYPE::OBJECT_TYPE_BOX:
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
//case OBJECT_TYPE::OBJECT_TYPE_PLAYER:
|
|
||||||
// //PlayerVBox(*(Player*)realObj,*box);
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return Physics::ICustomBody::SubscriptMessage_none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj)
|
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj)
|
||||||
{
|
{
|
||||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500);
|
||||||
|
((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,7 @@ namespace GameLogic
|
||||||
class CollisionManager
|
class CollisionManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//these are the main collision functions
|
//put general collision functions here that are not part of a specific object
|
||||||
//typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter );
|
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj);
|
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj);
|
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj);
|
|
||||||
//these are the specific collision case functions
|
|
||||||
//void PlayerVBox(Player &player, DynamicObject &box);
|
|
||||||
//void BoxVBox(DynamicObject &box1, DynamicObject &box2);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,8 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
OBJECT_TYPE_PLAYER = 0,
|
OBJECT_TYPE_PLAYER = 0,
|
||||||
OBJECT_TYPE_BOX = 1,
|
OBJECT_TYPE_BOX = 1,
|
||||||
OBJECT_TYPE_WORLD = 2,
|
OBJECT_TYPE_WORLD = 2,
|
||||||
|
OBJECT_TYPE_GENERIC = 4,
|
||||||
OBJECT_TYPE_UNKNOWN = -1,
|
OBJECT_TYPE_UNKNOWN = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace GameLogic
|
||||||
IAttatchment(void);
|
IAttatchment(void);
|
||||||
~IAttatchment(void);
|
~IAttatchment(void);
|
||||||
|
|
||||||
virtual void UseAttatchment(const WEAPON_FIRE &usage) = 0;
|
virtual void UseAttatchment(const WEAPON_FIRE &usage, float dt) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ void Level::InitiateLevel(float radius)
|
||||||
sbDesc.radius = 8; //radius;
|
sbDesc.radius = 8; //radius;
|
||||||
sbDesc.mass = 10e12f;
|
sbDesc.mass = 10e12f;
|
||||||
//sbDesc.mass = 0; //10^16
|
//sbDesc.mass = 0; //10^16
|
||||||
sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
|
sbDesc.subscription_onCollisionResponse = Level::LevelCollision;
|
||||||
|
|
||||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
API::Instance().AddObject(rigidBody);
|
API::Instance().AddObject(rigidBody);
|
||||||
|
|
|
@ -51,6 +51,14 @@ namespace GameLogic
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void RespawnPlayer(Player *player);
|
void RespawnPlayer(Player *player);
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Collision function for level, this is to be sent to physics through the subscribe function with the rigidbody
|
||||||
|
* Will be called when the physics detect a collision
|
||||||
|
* @param rigidBodyLevel: physics object of the level
|
||||||
|
* @param obj: physics object for the object that collided with the level
|
||||||
|
********************************************************/
|
||||||
|
static void LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TeamManager teamManager;
|
TeamManager teamManager;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
||||||
|
|
|
@ -49,6 +49,11 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
||||||
this->type = type;
|
this->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::ApplyLinearImpulse(Oyster::Math::Float4 force)
|
||||||
|
{
|
||||||
|
setState.ApplyLinearImpulse(force);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Object::~Object(void)
|
Object::~Object(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace GameLogic
|
||||||
OBJECT_TYPE GetType() const;
|
OBJECT_TYPE GetType() const;
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||||
|
void ApplyLinearImpulse(Oyster::Math::Float4 force);
|
||||||
|
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
void EndFrame();
|
void EndFrame();
|
||||||
|
|
|
@ -8,7 +8,7 @@ using namespace GameLogic;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
Player::Player()
|
Player::Player()
|
||||||
:DynamicObject(CollisionManager::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
|
:DynamicObject(Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER)
|
||||||
{
|
{
|
||||||
weapon = new Weapon();
|
weapon = new Weapon();
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void Player::MoveLeft()
|
||||||
|
|
||||||
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
||||||
{
|
{
|
||||||
this->weapon->Use(usage);
|
this->weapon->Use(usage,gameInstance->GetFrameTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||||
|
|
|
@ -41,7 +41,17 @@ namespace GameLogic
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void Respawn(Oyster::Math::Float3 spawnPoint);
|
void Respawn(Oyster::Math::Float3 spawnPoint);
|
||||||
|
|
||||||
|
|
||||||
void Rotate(float x, float y);
|
void Rotate(float x, float y);
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||||
|
* Will be called when the physics detect a collision
|
||||||
|
* @param rigidBodyPlayer: physics object of the player
|
||||||
|
* @param obj: physics object for the object that collided with the player
|
||||||
|
********************************************************/
|
||||||
|
static void PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||||
|
|
||||||
|
|
||||||
bool IsWalking();
|
bool IsWalking();
|
||||||
bool IsJumping();
|
bool IsJumping();
|
||||||
|
@ -65,6 +75,9 @@ namespace GameLogic
|
||||||
PLAYER_STATE playerState;
|
PLAYER_STATE playerState;
|
||||||
Oyster::Math::Float4 lookDir;
|
Oyster::Math::Float4 lookDir;
|
||||||
|
|
||||||
|
bool hasTakenDamage;
|
||||||
|
float invincibleCooldown;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -1,60 +1,39 @@
|
||||||
#include "Weapon.h"
|
#include "Weapon.h"
|
||||||
#include "AttatchmentSocket.h"
|
|
||||||
#include "AttatchmentMassDriver.h"
|
#include "AttatchmentMassDriver.h"
|
||||||
#include "DynamicArray.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
|
||||||
struct Weapon::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
weaponState = WEAPON_STATE_IDLE;
|
|
||||||
selectedAttatchment = 0;
|
|
||||||
currentNrOfAttatchments = 0;
|
|
||||||
selectedSocketID = 0;
|
|
||||||
attatchmentSockets = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WEAPON_STATE weaponState;
|
|
||||||
|
|
||||||
DynamicArray<SmartPointer<AttatchmentSocket>> attatchmentSockets;
|
|
||||||
int currentNrOfAttatchments;
|
|
||||||
SmartPointer<IAttatchment> selectedAttatchment;
|
|
||||||
int selectedSocketID;
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
Weapon::Weapon()
|
Weapon::Weapon()
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
weaponState = WEAPON_STATE_IDLE;
|
||||||
|
selectedAttatchment = 0;
|
||||||
|
currentNrOfAttatchments = 0;
|
||||||
|
selectedSocketID = 0;
|
||||||
|
attatchmentSockets = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Weapon::Weapon(int MaxNrOfSockets)
|
Weapon::Weapon(int MaxNrOfSockets)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
attatchmentSockets.Resize(MaxNrOfSockets);
|
||||||
myData->attatchmentSockets.Resize(MaxNrOfSockets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Weapon::~Weapon(void)
|
Weapon::~Weapon(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Uses the weapon based on the input given and the current chosen attatchment
|
* Uses the weapon based on the input given and the current chosen attatchment
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void Weapon::Use(const WEAPON_FIRE &usage)
|
void Weapon::Use(const WEAPON_FIRE &usage, float dt)
|
||||||
{
|
{
|
||||||
if (myData->selectedAttatchment)
|
if (selectedAttatchment)
|
||||||
{
|
{
|
||||||
myData->selectedAttatchment->UseAttatchment(usage);
|
selectedAttatchment->UseAttatchment(usage, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,24 +47,24 @@ void Weapon::Use(const WEAPON_FIRE &usage)
|
||||||
********************************************************/
|
********************************************************/
|
||||||
bool Weapon::IsFireing()
|
bool Weapon::IsFireing()
|
||||||
{
|
{
|
||||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIRING);
|
return (weaponState == WEAPON_STATE::WEAPON_STATE_FIRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Weapon::IsIdle()
|
bool Weapon::IsIdle()
|
||||||
{
|
{
|
||||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
|
return (weaponState == WEAPON_STATE::WEAPON_STATE_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Weapon::IsReloading()
|
bool Weapon::IsReloading()
|
||||||
{
|
{
|
||||||
return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
|
return (weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Weapon::IsValidSocket(int socketID)
|
bool Weapon::IsValidSocket(int socketID)
|
||||||
{
|
{
|
||||||
if(socketID < (int)myData->attatchmentSockets.Size() && socketID >= 0)
|
if(socketID < (int)attatchmentSockets.Size() && socketID >= 0)
|
||||||
{
|
{
|
||||||
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
|
if (attatchmentSockets[socketID]->GetAttatchment() != 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -96,16 +75,16 @@ bool Weapon::IsValidSocket(int socketID)
|
||||||
|
|
||||||
int Weapon::GetCurrentSocketID()
|
int Weapon::GetCurrentSocketID()
|
||||||
{
|
{
|
||||||
return myData->selectedSocketID;
|
return selectedSocketID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
|
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
|
||||||
{
|
{
|
||||||
if(myData->currentNrOfAttatchments < (int)myData->attatchmentSockets.Size())
|
if(currentNrOfAttatchments < (int)attatchmentSockets.Size())
|
||||||
{
|
{
|
||||||
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
|
attatchmentSockets[currentNrOfAttatchments]->SetAttatchment(attatchment);
|
||||||
myData->currentNrOfAttatchments++;
|
currentNrOfAttatchments++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +92,7 @@ void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *
|
||||||
{
|
{
|
||||||
if (IsValidSocket(socketID))
|
if (IsValidSocket(socketID))
|
||||||
{
|
{
|
||||||
myData->attatchmentSockets[socketID]->SetAttatchment(attatchment);
|
attatchmentSockets[socketID]->SetAttatchment(attatchment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +100,7 @@ void Weapon::RemoveAttatchment(int socketID)
|
||||||
{
|
{
|
||||||
if (IsValidSocket(socketID))
|
if (IsValidSocket(socketID))
|
||||||
{
|
{
|
||||||
myData->attatchmentSockets[socketID]->RemoveAttatchment();
|
attatchmentSockets[socketID]->RemoveAttatchment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +108,8 @@ void Weapon::SelectAttatchment(int socketID)
|
||||||
{
|
{
|
||||||
if (IsValidSocket(socketID))
|
if (IsValidSocket(socketID))
|
||||||
{
|
{
|
||||||
myData->selectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment();
|
selectedAttatchment = attatchmentSockets[socketID]->GetAttatchment();
|
||||||
myData->selectedSocketID = socketID;
|
selectedSocketID = socketID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,21 +6,20 @@
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include "IAttatchment.h"
|
#include "IAttatchment.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "AttatchmentSocket.h"
|
||||||
|
#include "DynamicArray.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
|
||||||
class Weapon
|
class Weapon
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
Weapon(void);
|
Weapon(void);
|
||||||
Weapon(int nrOfAttatchmentSockets);
|
Weapon(int nrOfAttatchmentSockets);
|
||||||
~Weapon(void);
|
~Weapon(void);
|
||||||
|
|
||||||
void Use(const WEAPON_FIRE &fireInput);
|
void Use(const WEAPON_FIRE &usage, float dt);
|
||||||
|
|
||||||
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
|
void AddNewAttatchment(IAttatchment *attatchment, Player *owner);
|
||||||
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
|
void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner);
|
||||||
|
@ -35,9 +34,12 @@ namespace GameLogic
|
||||||
|
|
||||||
int GetCurrentSocketID();
|
int GetCurrentSocketID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
WEAPON_STATE weaponState;
|
||||||
PrivateData *myData;
|
Utility::DynamicMemory::DynamicArray<AttatchmentSocket*> attatchmentSockets;
|
||||||
|
int currentNrOfAttatchments;
|
||||||
|
IAttatchment *selectedAttatchment;
|
||||||
|
int selectedSocketID;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, Visitor
|
||||||
{
|
{
|
||||||
if(collideable.Intersects(this->leafData[i].container))
|
if(collideable.Intersects(this->leafData[i].container))
|
||||||
{
|
{
|
||||||
hitAction(*this, i);
|
hitAction( this->GetCustomBody(i) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Oyster
|
||||||
static const unsigned int invalid_ref;
|
static const unsigned int invalid_ref;
|
||||||
|
|
||||||
typedef void(*VisitorAction)(Octree&, unsigned int, unsigned int);
|
typedef void(*VisitorAction)(Octree&, unsigned int, unsigned int);
|
||||||
typedef void(*VisitorActionCollideable)(Octree&, unsigned int);
|
typedef void(*VisitorActionCollideable)(ICustomBody*);
|
||||||
|
|
||||||
struct Data
|
struct Data
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,9 +94,14 @@ namespace
|
||||||
// proto->Predict( forwardedDeltaPos, forwardedDeltaAxis, bounceLinearImpulse, bounceAngularImpulse, API_instance.GetFrameTimeLength() );
|
// proto->Predict( forwardedDeltaPos, forwardedDeltaAxis, bounceLinearImpulse, bounceAngularImpulse, API_instance.GetFrameTimeLength() );
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// protoState.ApplyForwarding( forwardedDeltaPos, forwardedDeltaAxis );
|
// protoState.ApplyForwarding( forwardedDeltaPos, forwardedDeltaAxis );
|
||||||
protoState.ApplyImpulse( bounce, worldPointOfContact, normal );
|
protoState.ApplyImpulse( bounce, worldPointOfContact, normal );
|
||||||
proto->SetState( protoState );
|
proto->SetState( protoState );
|
||||||
|
|
||||||
|
proto->CallSubscription_CollisionResponse( deuter, protoState.GetLinearMomentum().GetMagnitude()/(protoState.GetMass() + protoState.GetLinearMomentum().GetMagnitude()));
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +275,7 @@ void API_Impl::RemoveGravity( const API::Gravity &g )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_Impl::ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) )
|
void API_Impl::ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) )
|
||||||
{
|
{
|
||||||
this->worldScene.Visit(collideable, hitAction);
|
this->worldScene.Visit(collideable, hitAction);
|
||||||
}
|
}
|
||||||
|
@ -383,6 +388,11 @@ namespace Oyster { namespace Physics
|
||||||
return ::Oyster::Physics::ICustomBody::SubscriptMessage_none;
|
return ::Oyster::Physics::ICustomBody::SubscriptMessage_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventAction_CollisionResponse( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss )
|
||||||
|
{ /* Do nothing except returning business as usual. */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void EventAction_Move( const ::Oyster::Physics::ICustomBody *object )
|
void EventAction_Move( const ::Oyster::Physics::ICustomBody *object )
|
||||||
{ /* Do nothing. */ }
|
{ /* Do nothing. */ }
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Oyster
|
||||||
void AddGravity( const API::Gravity &g );
|
void AddGravity( const API::Gravity &g );
|
||||||
void RemoveGravity( const API::Gravity &g );
|
void RemoveGravity( const API::Gravity &g );
|
||||||
|
|
||||||
void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) );
|
void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) );
|
||||||
|
|
||||||
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
//void ApplyForceAt( const ICustomBody* objRef, const ::Oyster::Math::Float3 &worldPos, const ::Oyster::Math::Float3 &worldF );
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto );
|
void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto );
|
||||||
::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_Collision( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter );
|
::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_Collision( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter );
|
||||||
|
void EventAction_CollisionResponse( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss );
|
||||||
void EventAction_Move( const ::Oyster::Physics::ICustomBody *object );
|
void EventAction_Move( const ::Oyster::Physics::ICustomBody *object );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ SimpleRigidBody::SimpleRigidBody()
|
||||||
this->rigid.SetMass_KeepMomentum( 16.0f );
|
this->rigid.SetMass_KeepMomentum( 16.0f );
|
||||||
this->gravityNormal = Float3::null;
|
this->gravityNormal = Float3::null;
|
||||||
this->onCollision = Default::EventAction_Collision;
|
this->onCollision = Default::EventAction_Collision;
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
this->onMovement = Default::EventAction_Move;
|
this->onMovement = Default::EventAction_Move;
|
||||||
this->scene = nullptr;
|
this->scene = nullptr;
|
||||||
this->customTag = nullptr;
|
this->customTag = nullptr;
|
||||||
|
@ -74,6 +75,15 @@ SimpleRigidBody::SimpleRigidBody( const API::SimpleBodyDescription &desc )
|
||||||
this->onCollision = Default::EventAction_Collision;
|
this->onCollision = Default::EventAction_Collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( desc.subscription_onCollisionResponse )
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = desc.subscription_onCollisionResponse;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
|
}
|
||||||
|
|
||||||
if( desc.subscription_onMovement )
|
if( desc.subscription_onMovement )
|
||||||
{
|
{
|
||||||
this->onMovement= desc.subscription_onMovement;
|
this->onMovement= desc.subscription_onMovement;
|
||||||
|
@ -158,6 +168,11 @@ ICustomBody::SubscriptMessage SimpleRigidBody::CallSubscription_Collision( const
|
||||||
return this->onCollision( this, deuter );
|
return this->onCollision( this, deuter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleRigidBody::CallSubscription_CollisionResponse( const ICustomBody *deuter, Float kineticEnergyLoss )
|
||||||
|
{
|
||||||
|
return this->onCollisionResponse( this, deuter, kineticEnergyLoss );
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::CallSubscription_Move()
|
void SimpleRigidBody::CallSubscription_Move()
|
||||||
{
|
{
|
||||||
this->onMovement( this );
|
this->onMovement( this );
|
||||||
|
@ -315,6 +330,18 @@ void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_Collision functi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_CollisionResponse functionPointer )
|
||||||
|
{
|
||||||
|
if( functionPointer )
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = functionPointer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_Move functionPointer )
|
void SimpleRigidBody::SetSubscription( ICustomBody::EventAction_Move functionPointer )
|
||||||
{
|
{
|
||||||
if( functionPointer )
|
if( functionPointer )
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Oyster { namespace Physics
|
||||||
//::Oyster::Math::Float3 GetRigidLinearVelocity() const;
|
//::Oyster::Math::Float3 GetRigidLinearVelocity() const;
|
||||||
|
|
||||||
SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter );
|
SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter );
|
||||||
|
void CallSubscription_CollisionResponse( const ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss );
|
||||||
void CallSubscription_Move();
|
void CallSubscription_Move();
|
||||||
|
|
||||||
bool IsAffectedByGravity() const;
|
bool IsAffectedByGravity() const;
|
||||||
|
@ -44,6 +45,7 @@ namespace Oyster { namespace Physics
|
||||||
void SetScene( void *scene );
|
void SetScene( void *scene );
|
||||||
|
|
||||||
void SetSubscription( EventAction_Collision functionPointer );
|
void SetSubscription( EventAction_Collision functionPointer );
|
||||||
|
void SetSubscription( EventAction_CollisionResponse functionPointer );
|
||||||
void SetSubscription( EventAction_Move functionPointer );
|
void SetSubscription( EventAction_Move functionPointer );
|
||||||
|
|
||||||
void SetGravity( bool ignore);
|
void SetGravity( bool ignore);
|
||||||
|
@ -64,6 +66,7 @@ namespace Oyster { namespace Physics
|
||||||
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
||||||
::Oyster::Math::Float3 gravityNormal;
|
::Oyster::Math::Float3 gravityNormal;
|
||||||
EventAction_Collision onCollision;
|
EventAction_Collision onCollision;
|
||||||
|
EventAction_CollisionResponse onCollisionResponse;
|
||||||
EventAction_Move onMovement;
|
EventAction_Move onMovement;
|
||||||
Octree *scene;
|
Octree *scene;
|
||||||
void *customTag;
|
void *customTag;
|
||||||
|
|
|
@ -14,6 +14,7 @@ SphericalRigidBody::SphericalRigidBody()
|
||||||
this->rigid.SetMass_KeepMomentum( 10.0f );
|
this->rigid.SetMass_KeepMomentum( 10.0f );
|
||||||
this->gravityNormal = Float3::null;
|
this->gravityNormal = Float3::null;
|
||||||
this->onCollision = Default::EventAction_Collision;
|
this->onCollision = Default::EventAction_Collision;
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
this->onMovement = Default::EventAction_Move;
|
this->onMovement = Default::EventAction_Move;
|
||||||
this->scene = nullptr;
|
this->scene = nullptr;
|
||||||
this->customTag = nullptr;
|
this->customTag = nullptr;
|
||||||
|
@ -42,6 +43,15 @@ SphericalRigidBody::SphericalRigidBody( const API::SphericalBodyDescription &des
|
||||||
this->onCollision = Default::EventAction_Collision;
|
this->onCollision = Default::EventAction_Collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( desc.subscription_onCollisionResponse )
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = desc.subscription_onCollisionResponse;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
|
}
|
||||||
|
|
||||||
if( desc.subscription_onMovement )
|
if( desc.subscription_onMovement )
|
||||||
{
|
{
|
||||||
this->onMovement= desc.subscription_onMovement;
|
this->onMovement= desc.subscription_onMovement;
|
||||||
|
@ -123,6 +133,12 @@ ICustomBody::SubscriptMessage SphericalRigidBody::CallSubscription_Collision( co
|
||||||
return this->onCollision( this, deuter );
|
return this->onCollision( this, deuter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SphericalRigidBody::CallSubscription_CollisionResponse( const ICustomBody *deuter, Float kineticEnergyLoss )
|
||||||
|
{
|
||||||
|
this->onCollisionResponse( this, deuter, kineticEnergyLoss);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SphericalRigidBody::CallSubscription_Move()
|
void SphericalRigidBody::CallSubscription_Move()
|
||||||
{
|
{
|
||||||
this->onMovement( this );
|
this->onMovement( this );
|
||||||
|
@ -234,6 +250,18 @@ void SphericalRigidBody::SetSubscription( ICustomBody::EventAction_Collision fun
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SphericalRigidBody::SetSubscription( ICustomBody::EventAction_CollisionResponse functionPointer )
|
||||||
|
{
|
||||||
|
if( functionPointer )
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = functionPointer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->onCollisionResponse = Default::EventAction_CollisionResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SphericalRigidBody::SetSubscription( ICustomBody::EventAction_Move functionPointer )
|
void SphericalRigidBody::SetSubscription( ICustomBody::EventAction_Move functionPointer )
|
||||||
{
|
{
|
||||||
if( functionPointer )
|
if( functionPointer )
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Oyster { namespace Physics
|
||||||
//::Oyster::Math::Float3 GetRigidLinearVelocity() const;
|
//::Oyster::Math::Float3 GetRigidLinearVelocity() const;
|
||||||
|
|
||||||
SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter );
|
SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter );
|
||||||
|
void CallSubscription_CollisionResponse( const ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss );
|
||||||
void CallSubscription_Move();
|
void CallSubscription_Move();
|
||||||
|
|
||||||
bool IsAffectedByGravity() const;
|
bool IsAffectedByGravity() const;
|
||||||
|
@ -45,6 +46,7 @@ namespace Oyster { namespace Physics
|
||||||
void SetScene( void *scene );
|
void SetScene( void *scene );
|
||||||
|
|
||||||
void SetSubscription( EventAction_Collision functionPointer );
|
void SetSubscription( EventAction_Collision functionPointer );
|
||||||
|
void SetSubscription( EventAction_CollisionResponse functionPointer );
|
||||||
void SetSubscription( EventAction_Move functionPointer );
|
void SetSubscription( EventAction_Move functionPointer );
|
||||||
|
|
||||||
void SetGravity( bool ignore);
|
void SetGravity( bool ignore);
|
||||||
|
@ -65,6 +67,7 @@ namespace Oyster { namespace Physics
|
||||||
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
::Oyster::Math::Float4 deltaPos, deltaAxis;
|
||||||
::Oyster::Math::Float3 gravityNormal;
|
::Oyster::Math::Float3 gravityNormal;
|
||||||
EventAction_Collision onCollision;
|
EventAction_Collision onCollision;
|
||||||
|
EventAction_CollisionResponse onCollisionResponse;
|
||||||
EventAction_Move onMovement;
|
EventAction_Move onMovement;
|
||||||
Octree *scene;
|
Octree *scene;
|
||||||
void *customTag;
|
void *customTag;
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
class API;
|
class API;
|
||||||
class ICustomBody;
|
class ICustomBody;
|
||||||
class Octree;
|
|
||||||
|
|
||||||
namespace Struct
|
namespace Struct
|
||||||
{
|
{
|
||||||
|
@ -137,7 +136,12 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void RemoveGravity( const API::Gravity &g ) = 0;
|
virtual void RemoveGravity( const API::Gravity &g ) = 0;
|
||||||
|
|
||||||
virtual void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(Octree&, unsigned int) ) = 0;
|
/********************************************************
|
||||||
|
* Applies an effect to objects that collide with the set volume.
|
||||||
|
* @param collideable: An ICollideable that defines the volume of the effect.
|
||||||
|
* @param hitAction: A function that contains the effect.
|
||||||
|
********************************************************/
|
||||||
|
virtual void ApplyEffect( const Oyster::Collision3D::ICollideable& collideable, void(hitAction)(ICustomBody*) ) = 0;
|
||||||
|
|
||||||
///********************************************************
|
///********************************************************
|
||||||
// * Apply force on an object.
|
// * Apply force on an object.
|
||||||
|
@ -234,6 +238,7 @@ namespace Oyster
|
||||||
enum SubscriptMessage
|
enum SubscriptMessage
|
||||||
{
|
{
|
||||||
SubscriptMessage_none,
|
SubscriptMessage_none,
|
||||||
|
SubscriptMessage_kineticLoss,
|
||||||
SubscriptMessage_ignore_collision_response
|
SubscriptMessage_ignore_collision_response
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -257,6 +262,11 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter ) = 0;
|
virtual SubscriptMessage CallSubscription_Collision( const ICustomBody *deuter ) = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* @todo TODO: need doc
|
||||||
|
********************************************************/
|
||||||
|
virtual void CallSubscription_CollisionResponse( const ICustomBody *deuter, ::Oyster::Math::Float kineticEnergyLoss ) = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* @todo TODO: need doc
|
* @todo TODO: need doc
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
@ -387,6 +397,13 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual void SetSubscription( EventAction_Collision functionPointer ) = 0;
|
virtual void SetSubscription( EventAction_Collision functionPointer ) = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Sets the function that will be called by the engine
|
||||||
|
* whenever a collision has finished.
|
||||||
|
* @param functionPointer: If NULL, an empty default function will be set.
|
||||||
|
********************************************************/
|
||||||
|
virtual void SetSubscription( EventAction_CollisionResponse functionPointer ) = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Sets the function that will be called by the engine
|
* Sets the function that will be called by the engine
|
||||||
* whenever an object have moved.
|
* whenever an object have moved.
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Oyster
|
||||||
this->frictionCoeff_Static = 0.5f;
|
this->frictionCoeff_Static = 0.5f;
|
||||||
this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
|
this->inertiaTensor = ::Oyster::Math::Float4x4::identity;
|
||||||
this->subscription_onCollision = NULL;
|
this->subscription_onCollision = NULL;
|
||||||
|
this->subscription_onCollisionResponse = NULL;
|
||||||
this->subscription_onMovement = NULL;
|
this->subscription_onMovement = NULL;
|
||||||
this->ignoreGravity = false;
|
this->ignoreGravity = false;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,7 @@ namespace Oyster
|
||||||
this->frictionCoeff_Dynamic = 0.5f;
|
this->frictionCoeff_Dynamic = 0.5f;
|
||||||
this->frictionCoeff_Static = 0.5f;
|
this->frictionCoeff_Static = 0.5f;
|
||||||
this->subscription_onCollision = NULL;
|
this->subscription_onCollision = NULL;
|
||||||
|
this->subscription_onCollisionResponse = NULL;
|
||||||
this->subscription_onMovement = NULL;
|
this->subscription_onMovement = NULL;
|
||||||
this->ignoreGravity = false;
|
this->ignoreGravity = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Oyster { namespace Physics
|
||||||
::Oyster::Math::Float frictionCoeff_Dynamic;
|
::Oyster::Math::Float frictionCoeff_Dynamic;
|
||||||
::Oyster::Math::Float4x4 inertiaTensor;
|
::Oyster::Math::Float4x4 inertiaTensor;
|
||||||
::Oyster::Physics::ICustomBody::EventAction_Collision subscription_onCollision;
|
::Oyster::Physics::ICustomBody::EventAction_Collision subscription_onCollision;
|
||||||
|
::Oyster::Physics::ICustomBody::EventAction_CollisionResponse subscription_onCollisionResponse;
|
||||||
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
||||||
bool ignoreGravity;
|
bool ignoreGravity;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ namespace Oyster { namespace Physics
|
||||||
::Oyster::Math::Float frictionCoeff_Static;
|
::Oyster::Math::Float frictionCoeff_Static;
|
||||||
::Oyster::Math::Float frictionCoeff_Dynamic;
|
::Oyster::Math::Float frictionCoeff_Dynamic;
|
||||||
::Oyster::Physics::ICustomBody::EventAction_Collision subscription_onCollision;
|
::Oyster::Physics::ICustomBody::EventAction_Collision subscription_onCollision;
|
||||||
|
::Oyster::Physics::ICustomBody::EventAction_CollisionResponse subscription_onCollisionResponse;
|
||||||
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
::Oyster::Physics::ICustomBody::EventAction_Move subscription_onMovement;
|
||||||
bool ignoreGravity;
|
bool ignoreGravity;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue