From bf41bd38d4e4a153cef33ff417b6f580089d7e64 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 11:34:29 +0100 Subject: [PATCH 1/2] Updating model worldMatrix --- .../GameClient/GameClientState/C_Object.cpp | 21 ++++++++++++------- .../GameClient/GameClientState/C_Object.h | 2 ++ .../GameClient/GameClientState/GameState.cpp | 2 ++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/C_Object.cpp b/Code/Game/GameClient/GameClientState/C_Object.cpp index 50664a92..22820850 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.cpp +++ b/Code/Game/GameClient/GameClientState/C_Object.cpp @@ -5,7 +5,7 @@ C_Object::C_Object() world = Oyster::Math::Float4x4::identity; position = Oyster::Math::Float3::null; rotation = Oyster::Math::Quaternion::identity; - scale = Oyster::Math::Float3::null; + scale = Oyster::Math::Float3(1); id = 0; model = NULL; @@ -89,7 +89,10 @@ int C_Object::GetId() const } void C_Object::Render() { - Oyster::Graphics::API::RenderModel(model); + if( this->model ) + { + Oyster::Graphics::API::RenderModel(model); + } } void C_Object::Release() { @@ -113,14 +116,16 @@ bool C_Object::InitRB(RBInitData RBInit) type = RBInit.type; return true; } +void C_Object::updateRBWorld() +{ + Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position); + Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale); + RBworld = translation * rot * scale; +} Oyster::Math::Float4x4 C_Object::getRBWorld() const { - Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->RBposition); - Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->RBrotation); - Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->RBscale); - Oyster::Math3D::Float4x4 world = translation * rot * scale; - - return world; + return RBworld; } void C_Object::setRBPos(Oyster::Math::Float3 newPos) { diff --git a/Code/Game/GameClient/GameClientState/C_Object.h b/Code/Game/GameClient/GameClientState/C_Object.h index dcc2731c..c0784436 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.h +++ b/Code/Game/GameClient/GameClientState/C_Object.h @@ -40,6 +40,7 @@ namespace DanBias Oyster::Math::Float3 scale; // RB DEBUG + Oyster::Math::Float4x4 RBworld; Oyster::Math::Float3 RBposition; Oyster::Math::Quaternion RBrotation; Oyster::Math::Float3 RBscale; @@ -67,6 +68,7 @@ namespace DanBias Oyster::Math::Float3 getScale() const; // RB DEBUG + void updateRBWorld(); bool InitRB(RBInitData modelInit); Oyster::Math::Float4x4 getRBWorld() const; void setRBPos(Oyster::Math::Float3 newPos); diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index a4e22bbc..45246fb3 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -508,9 +508,11 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState { object->setPos( position ); object->setRot( rotation ); + object->updateWorld(); // RB DEBUG object->setRBPos ( position ); object->setRBRot ( rotation ); + object->updateRBWorld(); // !RB DEBUG } } From bdf8c199a3c45b637237b126482302b9c811c28a Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 20 Feb 2014 11:47:18 +0100 Subject: [PATCH 2/2] Removed check to not send rotation since it fucked up the rotation. --- Code/Game/GameClient/GameClientState/GameState.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index a4e22bbc..3b814c08 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -328,7 +328,7 @@ void GameState::ReadKeyInput() static const float mouseSensitivity = Radian( 1.0f ); this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity ); float yaw = this->privData->input->GetYaw(); - if( yaw != 0.0f ) + //if( yaw != 0.0f ) //This made the camera reset to a specific rotation. { this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) ); }