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

This commit is contained in:
Pontus Fransson 2014-02-04 14:31:00 +01:00
commit b810fa1586
6 changed files with 30 additions and 23 deletions

View File

@ -132,7 +132,7 @@ bool GameState::LoadModels(std::wstring mapFile)
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(50, 300, 0));
//Oyster::Math3D::RotationMatrix_AxisZ()
modelData.world = modelData.world * translate;
modelData.visible = true;
modelData.visible = false;
modelData.modelPath = L"building_corporation.dan";
modelData.id = 4;
// load models

View File

@ -93,11 +93,14 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
heldObject = NULL;
return;
}
Oyster::Math::Float3 up = owner->GetOrientation().v[1];
Oyster::Math::Float3 look = owner->GetLookDir();
Oyster::Math::Float3 pos = owner->GetPosition();
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (50000 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(look, up, pos);
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20);
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/8,1,1,5);
Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
forcePushData args;
args.pushForce = pushForce;
@ -142,14 +145,14 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
{
//Oyster::Math::Float4 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized();
//Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,2000);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*5;
Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos,20);
/*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,this,AttemptPickUp);
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
}

View File

@ -49,7 +49,7 @@ using namespace GameLogic;
//use kinetic energyloss of the collision in order too determin how much damage to take
//use as part of the damage algorithm
int damageDone = 0;
int forceThreashHold = 200;
int forceThreashHold = 200000;
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
{

View File

@ -61,7 +61,7 @@ Player::~Player(void)
void Player::BeginFrame()
{
weapon->Update(0.002f);
if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0));
//if(playerState == PLAYER_STATE_DEAD) Respawn(Oyster::Math::Float3(0,308,0));
Object::BeginFrame();
}

View File

@ -15,37 +15,37 @@ namespace PrivateStatic
Float4x4 m = vp.GetTranspose();
// left
lp.normal = m.v[3].xyz + m.v[0].xyz;
lp.normal = Float4(m.v[3].xyz + m.v[0].xyz,0);
lp.phasing = lp.normal.GetMagnitude();
lp.normal /= lp.phasing;
lp.phasing = (m.v[3].w + m.v[0].w) / lp.phasing;
// right
rp.normal = m.v[3].xyz - m.v[0].xyz;
rp.normal = Float4(m.v[3].xyz - m.v[0].xyz,0);
rp.phasing = rp.normal.GetMagnitude();
rp.normal /= rp.phasing;
rp.phasing = (m.v[3].w - m.v[0].w) / rp.phasing;
// bottom
bp.normal = m.v[3].xyz + m.v[1].xyz;
bp.normal = Float4(m.v[3].xyz + m.v[1].xyz,0);
bp.phasing = bp.normal.GetMagnitude();
bp.normal /= bp.phasing;
bp.phasing = (m.v[3].w + m.v[1].w) / bp.phasing;
// top
tp.normal = m.v[3].xyz - m.v[1].xyz;
tp.normal = Float4(m.v[3].xyz - m.v[1].xyz,0);
tp.phasing = tp.normal.GetMagnitude();
tp.normal /= tp.phasing;
tp.phasing = (m.v[3].w - m.v[1].w) / tp.phasing;
// near leftHanded DirectX
np.normal = m.v[2].xyz;
np.normal = Float4(m.v[2].xyz,0);
np.phasing = np.normal.GetMagnitude();
np.normal /= np.phasing;
np.phasing = m.v[2].w / np.phasing;
// far lefthanded
fp.normal = m.v[3].xyz - m.v[2].xyz;
fp.normal = Float4(m.v[3].xyz - m.v[2].xyz,0);
fp.phasing = fp.normal.GetMagnitude();
fp.normal /= fp.phasing;
fp.phasing = (m.v[3].w - m.v[2].w) / fp.phasing;

View File

@ -1064,38 +1064,42 @@ namespace Oyster { namespace Collision3D { namespace Utility
Float TimeOfContact( const Sphere &protoStart, const Sphere &protoEnd, const Point &deuter )
{ // Bisection with 5 levels of detail
Float t = 0.5f;
Float t = 0.5f,
d = 0.25f;
Sphere s;
for( int i = 0; i < 5; ++i )
{
Nlerp( protoStart, protoEnd, t, s );
if( Intersect(s, deuter) )
{
t *= 0.5f;
t -= d;
}
else
{
t *= 1.5f;
t += d;
}
d *= 0.5f;
}
return t;
}
Float TimeOfContact( const Box &protoStart, const Box &protoEnd, const Point &deuter )
{ // Bisection with 5 levels of detail
Float t = 0.5f;
Float t = 0.5f,
d = 0.25f;
Box b;
for( int i = 0; i < 5; ++i )
{
Nlerp( protoStart, protoEnd, t, b );
if( Intersect(b, deuter) )
{
t *= 0.5f;
t -= d;
}
else
{
t *= 1.5f;
t += d;
}
d *= 0.5f;
}
return t;
}