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

This commit is contained in:
dean11 2014-02-20 08:57:06 +01:00
commit 9e26095dd0
4 changed files with 92 additions and 82 deletions

View File

@ -192,47 +192,49 @@ bool GameState::Render()
light->second->Render(); light->second->Render();
}*/ }*/
// RB DEBUG render wire frame #ifdef _DEBUG
//if(this->privData->renderWhireframe) //RB DEBUG render wire frame
//{ if(this->privData->renderWhireframe)
// Oyster::Graphics::API::StartRenderWireFrame(); {
// Oyster::Graphics::API::StartRenderWireFrame();
// Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
// Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
// Oyster::Math3D::Float4x4 world = translation * scale; Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
// Oyster::Graphics::API::RenderDebugCube( world ); Oyster::Math3D::Float4x4 world = translation * scale;
// Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); Oyster::Graphics::API::RenderDebugCube( world );
// Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
// staticObject = this->privData->staticObjects->begin();
// for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) staticObject = this->privData->staticObjects->begin();
// { for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
// if( staticObject->second->getBRtype() == RB_Type_Cube) {
// { if( staticObject->second->getBRtype() == RB_Type_Cube)
// Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); {
// } Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld());
// if( staticObject->second->getBRtype() == RB_Type_Sphere) }
// { if( staticObject->second->getBRtype() == RB_Type_Sphere)
// Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); {
// } Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld());
// } }
// }
// dynamicObject = this->privData->dynamicObjects->begin();
// for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) dynamicObject = this->privData->dynamicObjects->begin();
// { for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
// if( dynamicObject->second ) {
// { if( dynamicObject->second )
// if( dynamicObject->second->getBRtype() == RB_Type_Cube) {
// { if( dynamicObject->second->getBRtype() == RB_Type_Cube)
// Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); {
// } Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
// if( dynamicObject->second->getBRtype() == RB_Type_Sphere) }
// { if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
// Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); {
// } Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
// } }
// } }
//} }
// !RB DEBUG }
//!RB DEBUG
#endif
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return true; return true;

View File

@ -154,7 +154,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2;
RBData.type = RB_Type_Cube; RBData.type = RB_Type_Cube;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
@ -163,7 +163,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2;
RBData.type = RB_Type_Sphere; RBData.type = RB_Type_Sphere;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
@ -198,7 +198,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2;
RBData.type = RB_Type_Cube; RBData.type = RB_Type_Cube;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }
@ -207,7 +207,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2;
RBData.type = RB_Type_Sphere; RBData.type = RB_Type_Sphere;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }

View File

@ -23,6 +23,7 @@ Game::PlayerData::PlayerData()
} }
Game::PlayerData::PlayerData(int playerID,int teamID) Game::PlayerData::PlayerData(int playerID,int teamID)
{ {
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,250,0); Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,250,0);
Oyster::Math::Float height = 2.0f; Oyster::Math::Float height = 2.0f;
Oyster::Math::Float radius = 0.5f; Oyster::Math::Float radius = 0.5f;

View File

@ -27,6 +27,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
key_backward = 0; key_backward = 0;
key_strafeRight = 0; key_strafeRight = 0;
key_strafeLeft = 0; key_strafeLeft = 0;
key_jump = 0;
invincibleCooldown = 0;
this->previousPosition = Oyster::Math::Float3(0,0,0); this->previousPosition = Oyster::Math::Float3(0,0,0);
@ -50,6 +52,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
key_backward = 0; key_backward = 0;
key_strafeRight = 0; key_strafeRight = 0;
key_strafeLeft = 0; key_strafeLeft = 0;
key_jump = 0;
invincibleCooldown = 0;
this->previousPosition = Oyster::Math::Float3(0,0,0); this->previousPosition = Oyster::Math::Float3(0,0,0);
this->moveDir = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0);
@ -71,12 +75,12 @@ Player::~Player(void)
void Player::BeginFrame() void Player::BeginFrame()
{ {
//weapon->Update(0.002f); //weapon->Update(0.002f);
Object::BeginFrame(); //Object::BeginFrame();
Oyster::Math::Float maxSpeed = 30; Oyster::Math::Float maxSpeed = 30;
Oyster::Math::Float4x4 xform; /*Oyster::Math::Float4x4 xform;
xform = this->rigidBody->GetState().GetOrientation(); xform = this->rigidBody->GetState().GetOrientation();*/
/* Handle turning */ /* Handle turning */
/*if (left) /*if (left)
@ -86,11 +90,11 @@ void Player::BeginFrame()
//xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle)); //xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle));
Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity(); Oyster::Math::Float3 linearVelocity(0,0,0); // = this->rigidBody->GetLinearVelocity();
Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength(); Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength();
Oyster::Math::Float3 forwardDir = xform.v[2]; Oyster::Math::Float3 forwardDir(0,0,1); //= xform.v[2];
Oyster::Math::Float3 rightDir = xform.v[0]; Oyster::Math::Float3 rightDir(1,0,0); // = xform.v[0];
forwardDir.Normalize(); forwardDir.Normalize();
rightDir.Normalize(); rightDir.Normalize();
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
@ -98,50 +102,50 @@ void Player::BeginFrame()
if (key_forward > 0.001) if (key_forward > 0.001)
{ {
key_forward -= gameInstance->GetFrameTime(); key_forward -= gameInstance->GetFrameTime();
walkDirection += forwardDir; walkDirection += forwardDir;
walkDirection.Normalize(); walkDirection.Normalize();
} }
if (key_backward > 0.001) if (key_backward > 0.001)
{ {
key_backward -= gameInstance->GetFrameTime(); key_backward -= gameInstance->GetFrameTime();
walkDirection -= forwardDir; walkDirection -= forwardDir;
walkDirection.Normalize(); walkDirection.Normalize();
} }
if (key_strafeRight > 0.001) if (key_strafeRight > 0.001)
{ {
key_strafeRight -= gameInstance->GetFrameTime(); key_strafeRight -= gameInstance->GetFrameTime();
walkDirection -= rightDir; walkDirection -= rightDir;
walkDirection.Normalize(); walkDirection.Normalize();
} }
if (key_strafeLeft > 0.001) if (key_strafeLeft > 0.001)
{ {
key_strafeLeft -= gameInstance->GetFrameTime(); key_strafeLeft -= gameInstance->GetFrameTime();
walkDirection += rightDir; walkDirection += rightDir;
walkDirection.Normalize(); walkDirection.Normalize();
maxSpeed = 40; maxSpeed = 40;
} }
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f) if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 ) //&& this->rigidBody->GetLambda() < 0.7f)
{ {
/* Dampen when on the ground and not being moved by the player */ /* Dampen when on the ground and not being moved by the player */
linearVelocity *= 0.2f; linearVelocity *= 0.2f;
this->rigidBody->SetLinearVelocity (linearVelocity); //this->rigidBody->SetLinearVelocity (linearVelocity);
}
else
{
if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f)
{
Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed;
this->rigidBody->SetLinearVelocity(velocity);
}
else if(speed < maxSpeed)
{
Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f;
this->rigidBody->SetLinearVelocity(velocity);
}
} }
//else
//{
// if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f)
// {
// Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed;
// this->rigidBody->SetLinearVelocity(velocity);
// }
// else if(speed < maxSpeed)
// {
// Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f;
// this->rigidBody->SetLinearVelocity(velocity);
// }
//}
if (key_jump > 0.001) if (key_jump > 0.001)
{ {
@ -153,8 +157,11 @@ void Player::BeginFrame()
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
} }
} }
Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos;
if(pos.x < -300000)
int i =0;
this->weapon->Update(0.01f); //this->weapon->Update(0.01f);
} }
void Player::EndFrame() void Player::EndFrame()
@ -162,9 +169,9 @@ void Player::EndFrame()
// snap to axis // snap to axis
Oyster::Math::Float4 rotation; Oyster::Math::Float4 rotation;
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); //this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
Object::EndFrame(); //Object::EndFrame();
} }
void Player::Move(const PLAYER_MOVEMENT &movement) void Player::Move(const PLAYER_MOVEMENT &movement)