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

Conflicts:
	Code/Game/GameLogic/GameLogicStates.h
	Code/Game/GameLogic/JumpPad.cpp
	Code/Game/GameLogic/JumpPad.h
This commit is contained in:
Sam Mario Svensson 2014-02-12 15:03:40 +01:00
commit 573a0109e3
19 changed files with 44 additions and 37 deletions

View File

@ -142,6 +142,13 @@ bool GameState::LoadModels()
this->staticObjects.Push(new C_StaticObj());
this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
// add jumppad
modelData.position = Oyster::Math::Float3(4, 600.3, 0);
modelData.modelPath = L"jumppad_round.dan";
modelData.id = id++;
// load models
this->staticObjects.Push(new C_StaticObj());
this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
// add player model
modelData.position = Oyster::Math::Float3(0, 602, 0);
@ -159,13 +166,7 @@ bool GameState::LoadModels()
this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add jumppad
modelData.position = Oyster::Math::Float3(4, 600.3, 0);
modelData.modelPath = L"jumppad_round.dan";
modelData.id = id++;
// load models
this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add sky sphere
modelData.position = Oyster::Math::Float3(0,0,0);

View File

@ -60,17 +60,18 @@ void AttatchmentMassDriver::Update(float dt)
//update position of heldObject if there is an object being held
if(hasObject)
{
Oyster::Physics::ICustomBody::State state;
state = heldObject->GetState();
//Oyster::Physics::ICustomBody::State state;
//state = heldObject->GetState();
Oyster::Math::Float3 ownerPos = owner->GetPosition();
Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState();
Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2];
up *= -0.3;
Oyster::Math::Float3 pos = ownerPos + up + (owner->GetLookDir().GetNormalized()*10);
Oyster::Math::Float3 pos = ownerPos + (owner->GetLookDir().GetNormalized()*5);
state.centerPos = pos;
//state.centerPos = pos;
heldObject->SetPosition(pos);
heldObject->SetState(state);
//heldObject->SetState(state);
}
}
@ -86,10 +87,8 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
if(hasObject)
{
Oyster::Physics::API::Instance().ReleaseFromLimbo(heldObject);
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (700);
Oyster::Physics::ICustomBody::State state = heldObject->GetState();
//state.ApplyLinearImpulse((Oyster::Math::Float3)pushForce);
heldObject->SetState(state);
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400);
heldObject->ApplyImpulse((Oyster::Math::Float3)pushForce);
hasObject = false;
heldObject = NULL;
@ -101,7 +100,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
Oyster::Math::Float lenght = 10;
Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos;
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100);
pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (400);
Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius);

View File

@ -61,11 +61,7 @@ using namespace GameLogic;
void SendObjectFlying(Oyster::Physics::ICustomBody &obj, Oyster::Math::Float3 force)
{
Oyster::Physics::ICustomBody::State state;
state = obj.GetState();
//state.ApplyLinearImpulse(force);
obj.SetState(state);
obj.ApplyImpulse(force);
}
@ -135,7 +131,7 @@ using namespace GameLogic;
{
case ObjectSpecialType_StandarsBox:
//move obj to limbo in physics to make sure it wont collide with anything
Oyster::Physics::API::Instance().MoveToLimbo(obj);
// Oyster::Physics::API::Instance().MoveToLimbo(obj);
weapon->heldObject = obj; //weapon now holds the object
weapon->hasObject = true;

View File

@ -8,11 +8,10 @@ JumpPad::JumpPad(void)
{
}
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 pushForce)
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, Oyster::Math::Float3 pushForce)
:StaticObject(rigidBody, collisionFuncAfter, type)
{
this->pushForce = pushForce;
}

View File

@ -9,9 +9,10 @@ namespace GameLogic
JumpPad(void);
JumpPad(Oyster::Physics::ICustomBody *rigidBody
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
,void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
,ObjectSpecialType type, Oyster::Math::Float3 pushForce);
~JumpPad(void);
static void JumpPadActivated(Oyster::Physics::ICustomBody *rigidBodyJumpPad, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);

View File

@ -289,6 +289,13 @@ void Level::InitiateLevel(float radius)
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic));
rigidBody_House->SetCustomTag(this->staticObjects[0]);
this->staticObjects[0]->objectID = idCount++;
// add jumppad
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, JumpPad::JumpPadActivated, ObjectSpecialType_JumpPad, Oyster::Math::Float3(0,2000,0)));
rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]);
this->staticObjects[1]->objectID = idCount++;
}
void Level::AddPlayerToTeam(Player *player, int teamID)

View File

@ -9,6 +9,7 @@
#include "StaticObject.h"
#include "DynamicObject.h"
#include "GameModeType.h"
#include "JumpPad.h"
#include "Player.h"
#include "PhysicsAPI.h"
#include "TeamManager.h"

View File

@ -112,6 +112,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>$(SolutionDir)Physics/lib/debug/BulletCollision_Debugx64.lib;$(SolutionDir)Physics/lib/debug/BulletDynamics_Debugx64.lib;$(SolutionDir)Physics/lib/debug/LinearMath_Debugx64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -130,6 +131,7 @@
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>$(SolutionDir)Physics/lib/release/BulletCollision.lib;$(SolutionDir)Physics/lib/release/BulletDynamics.lib;$(SolutionDir)Physics/lib/release/LinearMath.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -148,6 +150,7 @@
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>$(SolutionDir)Physics/lib/release/BulletCollisionx64.lib;$(SolutionDir)Physics/lib/release/BulletDynamicsx64.lib;$(SolutionDir)Physics/lib/release/LinearMathx64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -201,7 +201,7 @@ void API_Impl::UpdateWorld()
{
SimpleRigidBody* simpleBody = dynamic_cast<SimpleRigidBody*>(this->customBodies[i]);
btTransform trans;
simpleBody->GetMotionState()->getWorldTransform(trans);
trans = simpleBody->GetRigidBody()->getWorldTransform();
this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z()));
this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w()));

View File

@ -106,36 +106,36 @@ void SimpleRigidBody::SetLinearVelocity(Float3 velocity)
void SimpleRigidBody::SetPosition(::Oyster::Math::Float3 position)
{
btTransform trans;
this->motionState->getWorldTransform(trans);
trans = this->rigidBody->getWorldTransform();
trans.setOrigin(btVector3(position.x, position.y, position.z));
this->motionState->setWorldTransform(trans);
this->rigidBody->setWorldTransform(trans);
this->state.centerPos = position;
}
void SimpleRigidBody::SetRotation(Float4 quaternion)
{
btTransform trans;
this->motionState->getWorldTransform(trans);
trans = this->rigidBody->getWorldTransform();
trans.setRotation(btQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w));
this->motionState->setWorldTransform(trans);
this->rigidBody->setWorldTransform(trans);
this->state.quaternion = Quaternion(quaternion.xyz, quaternion.w);
}
void SimpleRigidBody::SetRotation(::Oyster::Math::Quaternion quaternion)
{
btTransform trans;
this->motionState->getWorldTransform(trans);
trans = this->rigidBody->getWorldTransform();
trans.setRotation(btQuaternion(quaternion.imaginary.x, quaternion.imaginary.y, quaternion.imaginary.z, quaternion.real));
this->motionState->setWorldTransform(trans);
this->rigidBody->setWorldTransform(trans);
this->state.quaternion = quaternion;
}
void SimpleRigidBody::SetRotation(Float3 eulerAngles)
{
btTransform trans;
this->motionState->getWorldTransform(trans);
trans = this->rigidBody->getWorldTransform();
trans.setRotation(btQuaternion(eulerAngles.x, eulerAngles.y, eulerAngles.z));
this->motionState->setWorldTransform(trans);
this->rigidBody->setWorldTransform(trans);
this->state.quaternion = Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w());
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.