GL - almost rotating

This commit is contained in:
lindaandersson 2014-02-11 11:46:06 +01:00
parent 2d22d5d274
commit 528a591fab
4 changed files with 14 additions and 21 deletions

View File

@ -453,14 +453,14 @@ void GameState::readKeyInput(InputClass* KeyInput)
} }
//send delta mouse movement //send delta mouse movement
//if (KeyInput->IsMousePressed()) if (KeyInput->IsMousePressed())
{ {
camera->Yaw(-KeyInput->GetYaw()); camera->Yaw(-KeyInput->GetYaw());
camera->Pitch(KeyInput->GetPitch()); camera->Pitch(KeyInput->GetPitch());
pitch = KeyInput->GetPitch(); pitch = KeyInput->GetPitch();
camera->UpdateViewMatrix(); camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir; GameLogic::Protocol_PlayerLook playerLookDir;
Oyster::Math::Float4 look = camera->GetLook(); Oyster::Math::Float4 look = camera->GetRight();
playerLookDir.lookDirX = look.x; playerLookDir.lookDirX = look.x;
playerLookDir.lookDirY = look.y; playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z; playerLookDir.lookDirZ = look.z;

View File

@ -16,7 +16,7 @@ Game::PlayerData::PlayerData()
//create rigid body //create rigid body
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
//rigidBody->SetAngularFactor(0.0f);
//create player with this rigid body //create player with this rigid body
this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
this->player->GetRigidBody()->SetCustomTag(this); this->player->GetRigidBody()->SetCustomTag(this);

View File

@ -107,13 +107,9 @@ void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage
Oyster::Math::Float3 Object::GetPosition() Oyster::Math::Float3 Object::GetPosition()
{ {
Oyster::Physics::ICustomBody::State state; return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos;
state = this->rigidBody->GetState();
return state.centerPos;
} }
Oyster::Math::Float4x4 Object::GetOrientation() Oyster::Math::Float4x4 Object::GetOrientation()
{ {
Oyster::Physics::ICustomBody::State state; return this->rigidBody->GetState().GetOrientation();
state = this->rigidBody->GetState();
return state.GetOrientation();
} }

View File

@ -22,7 +22,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
{ {
InitPlayer(); InitPlayer();
} }
Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
:DynamicObject(collisionFuncBefore,collisionFuncAfter,type) :DynamicObject(collisionFuncBefore,collisionFuncAfter,type)
{ {
@ -60,21 +59,14 @@ Player::~Player(void)
void Player::BeginFrame() void Player::BeginFrame()
{ {
weapon->Update(0.002f); //weapon->Update(0.002f);
Object::BeginFrame(); Object::BeginFrame();
} }
void Player::EndFrame() void Player::EndFrame()
{ {
// snap to axis // snap to axis
Object::EndFrame(); Object::EndFrame();
// rotate
//Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1];
//Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ;
//currPhysicsState.AddRotation(deltaAxis);
} }
void Player::Move(const PLAYER_MOVEMENT &movement) void Player::Move(const PLAYER_MOVEMENT &movement)
@ -143,11 +135,12 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->life = 100; this->life = 100;
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float4(1,0,0); this->lookDir = Oyster::Math::Float4(1,0,0);
//this->newPhysicsState.centerPos = spawnPoint; this->rigidBody->SetPosition(spawnPoint);
} }
void Player::Rotate(const Oyster::Math3D::Float4 lookDir) void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
{ {
// right
Oyster::Math::Float dx = lookDir.w; Oyster::Math::Float dx = lookDir.w;
if(dx > 0.0f) if(dx > 0.0f)
{ {
@ -156,12 +149,16 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
this->lookDir = lookDir.xyz; this->lookDir = lookDir.xyz;
this->dx = lookDir.w; this->dx = lookDir.w;
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
this->rigidBody->SetUpAndRight(up, lookDir.xyz);
} }
void Player::Jump() void Player::Jump()
{ {
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
//newPhysicsState.ApplyLinearImpulse(up * MOVE_FORCE * this->gameInstance->GetFrameTime()); //this->rigidBody->GetState().SetLinearVelocity(up *10);
} }
bool Player::IsWalking() bool Player::IsWalking()