GL - movement with physics working!!
This commit is contained in:
parent
a070e4d459
commit
a168328a44
|
@ -85,6 +85,15 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
||||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
modelData.id ++;
|
||||
|
||||
obj = new C_DynamicObj();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -260,7 +269,13 @@ void GameState::Protocol( ObjPos* pos )
|
|||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
if(privData->object[i]->GetId() == pos->object_ID)
|
||||
{
|
||||
privData->object[i]->setPos(world);
|
||||
|
||||
//privData->view = world;
|
||||
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,8 @@ namespace DanBias
|
|||
//world.v[3].y = -2;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
Oyster::Math::Float4x4 world = c->GetPlayer()->GetOrientation();
|
||||
Protocol_ObjectPosition p(world, 1);
|
||||
Send(p.GetProtocol());
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerMouseMovement:
|
||||
|
@ -78,6 +77,8 @@ namespace DanBias
|
|||
case protocol_Gameplay_ObjectPosition:
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
this->modifiedClient.Push(e);
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace DanBias
|
|||
Sleep(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this->ParseEvents();
|
||||
|
||||
this->gameInstance.NewFrame();
|
||||
|
@ -56,6 +58,15 @@ namespace DanBias
|
|||
//e.data.player->GetOrientation();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(clients.Size() == 1)
|
||||
{
|
||||
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
|
||||
Protocol_ObjectPosition p(world, 1);
|
||||
Send(p.GetProtocol());
|
||||
Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ Object::Object()
|
|||
//poi
|
||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
||||
|
||||
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
||||
|
||||
//rigidBody->gameObjectRef = this;
|
||||
|
||||
this->objectID = GID();
|
||||
|
@ -33,6 +36,8 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
|||
//poi
|
||||
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
||||
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
||||
|
||||
rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc));
|
||||
|
||||
//rigidBody->gameObjectRef = this;
|
||||
|
|
|
@ -13,7 +13,12 @@ Player::Player()
|
|||
life = 100;
|
||||
teamID = -1;
|
||||
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
lookDir = Oyster::Math::Float4(1,0,0,0);
|
||||
lookDir = Oyster::Math::Float4(0,0,-1,0);
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
this->rigidBody->GetState( this->setState );
|
||||
setState.SetLinearMomentum( Oyster::Math::Float4(20, 0, 0, 0) );
|
||||
this->rigidBody->SetState( setState );
|
||||
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -61,13 +66,16 @@ void Player::MoveBackwards()
|
|||
void Player::MoveRight()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
||||
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 * 100);
|
||||
|
||||
}
|
||||
void Player::MoveLeft()
|
||||
{
|
||||
//Do cross product with forward vector and negative gravity vector
|
||||
Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
||||
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 * 100);
|
||||
}
|
||||
|
||||
|
@ -135,4 +143,5 @@ void Player::BeginFrame()
|
|||
void Player::EndFrame()
|
||||
{
|
||||
this->rigidBody->GetState(this->getState);
|
||||
this->setState = this->getState;
|
||||
}
|
|
@ -42,7 +42,7 @@ namespace GameLogic
|
|||
bTurnLeft = val[3].value.netBool;
|
||||
bTurnRight = val[4].value.netBool;
|
||||
bStrafeRight = val[5].value.netBool;
|
||||
bStrafeRight = val[6].value.netBool;
|
||||
bStrafeLeft = val[6].value.netBool;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace GameLogic
|
|||
this->protocol[3].value = bTurnLeft;
|
||||
this->protocol[4].value = bTurnRight;
|
||||
this->protocol[5].value = bStrafeRight;
|
||||
this->protocol[6].value = bStrafeRight;
|
||||
this->protocol[6].value = bStrafeLeft;
|
||||
|
||||
return &protocol;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue