Updated creation of objects
This commit is contained in:
parent
fb2cf714c6
commit
74ac5e2d31
|
@ -50,7 +50,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
|
|||
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);
|
||||
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,ForcePushAction);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace GameLogic
|
|||
********************************************************/
|
||||
void ForceSuck(const WEAPON_FIRE &usage, float dt);
|
||||
|
||||
void ForcePushAction(Oyster::Physics::ICustomBody *obj);
|
||||
static void ForcePushAction(Oyster::Physics::ICustomBody *obj);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ using namespace GameLogic;
|
|||
void PlayerVObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
//Physics::ICustomBody::SubscriptMessage
|
||||
void Player::PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag()));
|
||||
Object *realObj = (Object*)obj->GetCustomTag();
|
||||
|
||||
switch (realObj->GetType())
|
||||
{
|
||||
case OBJECT_H::OBJECT_TYPE_GENERIC:
|
||||
case OBJECT_TYPE::OBJECT_TYPE_GENERIC:
|
||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||
//return Physics::ICustomBody::SubscriptMessage_none;
|
||||
break;
|
||||
|
@ -52,9 +52,16 @@ using namespace GameLogic;
|
|||
//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);
|
||||
int damageDone = 0;
|
||||
int forceThreashHold = 200;
|
||||
|
||||
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
||||
{
|
||||
damageDone = kineticEnergyLoss * 0.10f;
|
||||
player.DamageLife(damageDone);
|
||||
}
|
||||
|
||||
}
|
||||
//Oyster::Physics::ICustomBody::SubscriptMessage
|
||||
void Level::LevelCollision(const Oyster::Physics::ICustomBody *rigidBodyLevel, const Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
|
@ -63,6 +70,6 @@ using namespace GameLogic;
|
|||
|
||||
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500);
|
||||
Oyster::Math::Float4 pushForce = Oyster::Math::Float4(owner->GetLookDir()) * (500);
|
||||
((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type)
|
|||
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFunc, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
DynamicObject::~DynamicObject(void)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace GameLogic
|
|||
public:
|
||||
DynamicObject();
|
||||
DynamicObject(void* collisionFunc, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
~DynamicObject(void);
|
||||
|
||||
private:
|
||||
|
|
|
@ -5,7 +5,16 @@ using namespace GameLogic;
|
|||
|
||||
Game::PlayerData::PlayerData()
|
||||
{
|
||||
this->player = new Player();
|
||||
Oyster::Physics::API::SimpleBodyDescription sbDesc;
|
||||
|
||||
//create rigidbody
|
||||
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
||||
|
||||
//create player with this rigidbody
|
||||
|
||||
|
||||
this->player = new Player(rigidBody,Player::PlayerCollision,OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player->GetRigidBody()->SetCustomTag(this);
|
||||
}
|
||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||
|
|
|
@ -54,12 +54,17 @@ Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type)
|
|||
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
||||
|
||||
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
|
||||
rigidBody->SetCustomTag(this);
|
||||
|
||||
this->objectID = GID();
|
||||
|
||||
this->type = type;
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Object::ApplyLinearImpulse(Oyster::Math::Float4 force)
|
||||
{
|
||||
setState.ApplyLinearImpulse(force);
|
||||
|
@ -98,11 +103,9 @@ void Object::EndFrame()
|
|||
|
||||
//Oyster::Math::Float rot = (setState.GetGravityNormal().xyz).Dot(getState.GetGravityNormal().xyz);
|
||||
//Oyster::Math::Float3 axis = (setState.GetGravityNormal().xyz).Cross(getState.GetGravityNormal().xyz);
|
||||
|
||||
// align with gravity normal
|
||||
//Oyster::Math::Float4x4 rotMatrix = setState.GetOrientation(); //Oyster::Math3D::RotationMatrix(rot, axis);
|
||||
//Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal());
|
||||
//setState.SetOrientation(rotMatrix);
|
||||
Oyster::Math::Float4x4 rotMatrix = setState.GetOrientation(); //Oyster::Math3D::RotationMatrix(rot, axis);
|
||||
Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal());
|
||||
setState.SetOrientation(rotMatrix);
|
||||
|
||||
|
||||
this->getState = this->rigidBody->GetState();
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace GameLogic
|
|||
Object();
|
||||
Object(void* collisionFunc, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
~Object(void);
|
||||
|
||||
OBJECT_TYPE GetType() const;
|
||||
|
|
|
@ -18,7 +18,12 @@ Player::Player()
|
|||
lookDir = Oyster::Math::Float4(0,0,-1,0);
|
||||
setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1));
|
||||
setState.SetReach(Oyster::Math::Float4(2,3.5,2,0));
|
||||
//setState.SetRotation(Oyster::Math::Float4(0,0,0,0).Normalize());
|
||||
}
|
||||
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:DynamicObject(rigidBody, collisionFunc, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -65,7 +70,6 @@ void Player::MoveBackwards()
|
|||
void Player::MoveRight()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
// temp up vector
|
||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
||||
setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime());
|
||||
|
@ -74,7 +78,6 @@ void Player::MoveRight()
|
|||
void Player::MoveLeft()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
// temp up vector
|
||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||
//Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
|
||||
setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime());
|
||||
|
@ -93,17 +96,10 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
|||
this->lookDir = Oyster::Math::Float4(1,0,0);
|
||||
}
|
||||
|
||||
void Player::Rotate(const Oyster::Math3D::Float3 lookDir)
|
||||
void Player::Rotate(float dx, float dy)
|
||||
{
|
||||
|
||||
this->lookDir = lookDir;
|
||||
|
||||
Oyster::Math::Float4 up(0,1,0,0);//-setState.GetGravityNormal();
|
||||
Oyster::Math::Float4 pos = setState.GetCenterPosition();
|
||||
Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz);
|
||||
// cant set rotation
|
||||
//setState.SetOrientation(world);
|
||||
//this->lookDir = lookDir - up.xyz;
|
||||
//this->lookDir = lookDir;
|
||||
|
||||
//this->setState.AddRotation(Oyster::Math::Float4(x, y));
|
||||
//this->setState.SetRotation();
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace GameLogic
|
|||
{
|
||||
public:
|
||||
Player(void);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
~Player(void);
|
||||
|
||||
/********************************************************
|
||||
|
@ -42,7 +43,7 @@ namespace GameLogic
|
|||
void Respawn(Oyster::Math::Float3 spawnPoint);
|
||||
|
||||
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir);
|
||||
void Rotate(float x, float y);
|
||||
|
||||
/********************************************************
|
||||
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||
|
@ -50,7 +51,7 @@ namespace GameLogic
|
|||
* @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);
|
||||
static void PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
||||
bool IsWalking();
|
||||
|
|
|
@ -24,6 +24,11 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisi
|
|||
:Object(rigidBody,collisionFunc,type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFunc, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace GameLogic
|
|||
StaticObject();
|
||||
StaticObject(void* collisionFunc, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
StaticObject(OBJECT_TYPE type);
|
||||
~StaticObject(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue