From 263eba782bb292d2fad6a6b71e11096e0ebbd45b Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 20 Feb 2014 10:04:38 +0100 Subject: [PATCH 01/11] Found unmarked debug hack Naughty collegues --- Code/Game/GameClient/GameClientState/MainState.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/Game/GameClient/GameClientState/MainState.cpp b/Code/Game/GameClient/GameClientState/MainState.cpp index f34b9ad6..5b96b385 100644 --- a/Code/Game/GameClient/GameClientState/MainState.cpp +++ b/Code/Game/GameClient/GameClientState/MainState.cpp @@ -79,9 +79,10 @@ GameClientState::ClientState MainState::Update( float deltaTime ) { bool test = this->privData->input->IsMousePressed(); if(test) - { + { // HACK: debug trap still in use? int i = 0; }; + this->privData->input->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = this->privData->input->IsMousePressed(); } From dd397ec7521f77d1a7a4cd8468f90d00725dc491 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 10:13:01 +0100 Subject: [PATCH 02/11] GameClient set onMoveFunc for all objects --- Code/Game/GameLogic/Object.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 1f43263b..22273b7e 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -30,6 +30,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfte this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Move)((Game*)&Game::Instance())->onMoveFnc); } @@ -41,6 +42,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICusto this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Move)((Game*)&Game::Instance())->onMoveFnc); } Object::~Object(void) From e6cd1f1e5f376196c4233aa62c28ef3e01bcdf2f Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 10:33:27 +0100 Subject: [PATCH 03/11] GameClient now objects say to client that they have moved! --- Code/Game/GameLogic/Level.cpp | 1 + Code/Game/GameLogic/Object.cpp | 2 -- Code/Game/GameLogic/Player.cpp | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 9febbe47..c9938dbd 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -300,6 +300,7 @@ bool Level::InitiateLevel(std::wstring levelPath) Object* dynamicGameObj = CreateGameObj(dynamicObjData, rigidBody_Dynamic); if (dynamicGameObj != NULL) { + dynamicGameObj->GetRigidBody()->SetSubscription(Level::PhysicsOnMoveLevel); this->dynamicObjects.Push((DynamicObject*)dynamicGameObj); } } diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 22273b7e..1f43263b 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -30,7 +30,6 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfte this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); - this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Move)((Game*)&Game::Instance())->onMoveFnc); } @@ -42,7 +41,6 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICusto this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); - this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Move)((Game*)&Game::Instance())->onMoveFnc); } Object::~Object(void) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 77953d43..848c528a 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -127,7 +127,7 @@ void Player::BeginFrame() } - 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 */ linearVelocity *= 0.2f; From d1fb6a7718dfac6a6513c598ebbdb33a69d47126 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 20 Feb 2014 11:01:25 +0100 Subject: [PATCH 04/11] Added udp connection if we want to implement broadcast. --- .../NetworkDependencies/ConnectionUDP.cpp | 218 ++++++++++++++++++ .../NetworkDependencies/ConnectionUDP.h | 57 +++++ .../NetworkDependencies.vcxproj | 2 + .../NetworkDependencies.vcxproj.filters | 2 + 4 files changed, 279 insertions(+) create mode 100644 Code/Network/NetworkDependencies/ConnectionUDP.cpp create mode 100644 Code/Network/NetworkDependencies/ConnectionUDP.h diff --git a/Code/Network/NetworkDependencies/ConnectionUDP.cpp b/Code/Network/NetworkDependencies/ConnectionUDP.cpp new file mode 100644 index 00000000..e7d065a6 --- /dev/null +++ b/Code/Network/NetworkDependencies/ConnectionUDP.cpp @@ -0,0 +1,218 @@ +#include "ConnectionUDP.h" + +#include + +using namespace Oyster::Network; + +ConnectionUDP::ConnectionUDP() +{ + this->ipSize = 16; + this->socket = -1; + this->stillSending = false; + this->closed = true; + this->Address = NULL; +} + +ConnectionUDP::ConnectionUDP( int socket ) +{ + this->ipSize = 16; + this->socket = socket; + this->stillSending = false; + this->closed = true; + this->Address = NULL; +} + +ConnectionUDP::~ConnectionUDP() +{ + closesocket( this->socket ); +} + +int ConnectionUDP::Connect(unsigned short port, const char serverName[]) +{ + this->port = port; + + closed = false; + stillSending = true; + + struct hostent *hostEnt; + if((hostEnt = gethostbyname(serverName)) == NULL) + { + return SOCKET_ERROR; + } + + + this->Address = *(unsigned long*)hostEnt->h_addr; + this->port = htons(this->port); + return 0; +} + +int ConnectionUDP::Disconnect() +{ + int result = closesocket(this->socket); + + if(result == SOCKET_ERROR) + { + return result; + } + + return 0; +} + +int ConnectionUDP::InitiateServer(unsigned short port) +{ + int errorCode = 0; + + if((errorCode = InitiateSocket()) != 0) + { + return errorCode; + } + + struct sockaddr_in server; + server.sin_family = AF_INET; + server.sin_addr.s_addr = INADDR_ANY; + server.sin_port = htons(port); + + if(bind(this->socket, (sockaddr*)&server, sizeof(server)) == SOCKET_ERROR) + { + errorCode = SOCKET_ERROR; + closesocket(this->socket); + return errorCode; + } + + closed = false; + stillSending = true; + return 0; +} + +int ConnectionUDP::InitiateClient() +{ + return InitiateSocket(); +} + +int ConnectionUDP::InitiateBroadcast(unsigned short port) +{ + int result = InitiateSocket(); + + + int flag = 1; + result = setsockopt(this->socket, /* socket affected */ + SOL_SOCKET, /* set option at TCP level */ + SO_BROADCAST, /* name of option */ + (char *) &flag, /* the cast is historical cruft */ + sizeof(flag)); /* length of option value */ + if (result < 0) + return -1; +} + +int ConnectionUDP::Send(OysterByte &bytes) +{ + int nBytes; + struct sockaddr_in reciever; + reciever.sin_family = AF_INET; + reciever.sin_addr.s_addr = this->Address; + reciever.sin_port = port; + + //printf("Send: %d\n", bytes.GetSize()); + nBytes = sendto(this->socket, + bytes, + bytes.GetSize(), + 0, + (sockaddr*)&reciever, + sizeof(sockaddr_in) + ); + + if ( nBytes != bytes.GetSize() ) + { + return nBytes; + } + + return 0; +} + +int ConnectionUDP::Recieve(OysterByte &bytes) +{ + int nBytes; + sockaddr_in from; + int fromLength = sizeof( from ); + + bytes.Resize(1000); + nBytes = recvfrom(this->socket, + bytes, + 1000, + 0, + (sockaddr*)&from, + &fromLength + ); + + + if(nBytes <= 0) + { + bytes.SetSize(0); + return WSAGetLastError(); + } + else + { + bytes.SetSize(nBytes); + } + + + //address and port of the client who sent the message + unsigned int from_address = ntohl( from.sin_addr.s_addr ); + unsigned int from_port = ntohs( from.sin_port ); + + + return 0; +} + +bool ConnectionUDP::IsSending() +{ + return stillSending; +} + +bool ConnectionUDP::IsConnected() +{ + if(closed) + { + return false; + } + + return true; +} + +int ConnectionUDP::SetBlockingMode( bool blocking ) +{ + DWORD nonBlocking; + + if(blocking) + { + nonBlocking = 0; + } + else + { + nonBlocking = 1; + } + + int result = ioctlsocket(this->socket, FIONBIO, &nonBlocking); + if(result != 0) + { + return result; + } + + //Success + return 0; +} +////////////////////////////////////// +// Private Methods +////////////////////////////////////// + +int ConnectionUDP::InitiateSocket() +{ + this->socket = (int)::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + + if(this->socket == SOCKET_ERROR) + { + return socket; + } + + return 0; +} \ No newline at end of file diff --git a/Code/Network/NetworkDependencies/ConnectionUDP.h b/Code/Network/NetworkDependencies/ConnectionUDP.h new file mode 100644 index 00000000..163ad741 --- /dev/null +++ b/Code/Network/NetworkDependencies/ConnectionUDP.h @@ -0,0 +1,57 @@ +#ifndef NETWORK_DEPENDENCIES_CONNECTIONUDP_H +#define NETWORK_DEPENDENCIES_CONNECTIONUDP_H + +////////////////////////////////// +// Created by Sam Svensson 2013 // +////////////////////////////////// + +#include "IConnection.h" +#include "../NetworkDependencies/OysterByte.h" + +namespace Oyster +{ + namespace Network + { + class ConnectionUDP : public IConnection + { + public: + ConnectionUDP(); + ConnectionUDP( int socket); + virtual ~ConnectionUDP(); + + virtual int InitiateServer( unsigned short port ); + virtual int InitiateClient(); + + virtual int InitiateBroadcast(unsigned short port); + + virtual int Send ( OysterByte &byte ); + virtual int Recieve( OysterByte &byte ); + + virtual int Connect( unsigned short port, const char serverName[] ); + + virtual int Disconnect(); + + bool IsSending(); + bool IsConnected(); + int GetIpSize(); + + int SetBlockingMode( bool blocking ); + + private: + int InitiateSocket(); + + int socket; + //char ipAddress[16]; + //unsigned short port; + int ipSize; + + unsigned long Address; + unsigned short port; + + bool stillSending; + bool closed; + }; + } +} + +#endif diff --git a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj index 79521d28..9f508f0c 100644 --- a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj +++ b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj @@ -147,6 +147,7 @@ + @@ -157,6 +158,7 @@ + diff --git a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters index 6a695e88..f24743d1 100644 --- a/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters +++ b/Code/Network/NetworkDependencies/NetworkDependencies.vcxproj.filters @@ -9,6 +9,7 @@ + @@ -25,5 +26,6 @@ + \ No newline at end of file From a2bba95003d8d1a229c6955aaeff6a8b19e1a127 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 11:12:08 +0100 Subject: [PATCH 05/11] GameClient sending rotation to server --- Code/Game/GameProtocols/PlayerProtocols.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index 57137fb4..350c2cf6 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -97,6 +97,8 @@ namespace GameLogic { this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn; this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short; + // deltaRadian + this->protocol[1].type = ::Oyster::Network::NetAttributeType_Float; this->deltaRadian = deltaRadian; } From 89c52d34f459f1067ac37525dd46c992fe519881 Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Thu, 20 Feb 2014 11:13:52 +0100 Subject: [PATCH 06/11] Changed order of move call --- .../GamePhysics/Implementation/PhysicsAPI_Impl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index f2f97280..df66bc12 100644 --- a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -283,6 +283,11 @@ void API_Impl::UpdateWorld() SimpleRigidBody* simpleBody = dynamic_cast(this->customBodies[i]); this->customBodies[i]->SetGravity(-(this->customBodies[i]->GetState().centerPos - this->gravityPoint).GetNormalized()*this->gravity); simpleBody->PreStep(this->dynamicsWorld); + + if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG) + { + this->customBodies[i]->CallSubscription_Move(); + } } this->dynamicsWorld->stepSimulation(this->timeStep, 1, this->timeStep); @@ -295,12 +300,7 @@ void API_Impl::UpdateWorld() btTransform 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())); - - if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG) - { - this->customBodies[i]->CallSubscription_Move(); - } + this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w())); } int numManifolds = this->dynamicsWorld->getDispatcher()->getNumManifolds(); From d945eea9928b05b9e25067f18e07b156004c8279 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 20 Feb 2014 11:17:11 +0100 Subject: [PATCH 07/11] Fixed left turn mirroring and filter turn signals --- Code/Game/GameClient/GameClientState/GameState.cpp | 6 +++++- Code/Misc/Input/Input.vcxproj | 2 ++ Code/Misc/Input/L_inputClass.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 462422a6..a4e22bbc 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -327,7 +327,11 @@ void GameState::ReadKeyInput() { static const float mouseSensitivity = Radian( 1.0f ); this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity ); - this->privData->nwClient->Send( Protocol_PlayerLeftTurn(this->privData->input->GetYaw() * mouseSensitivity) ); + float yaw = this->privData->input->GetYaw(); + if( yaw != 0.0f ) + { + this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) ); + } } // shoot diff --git a/Code/Misc/Input/Input.vcxproj b/Code/Misc/Input/Input.vcxproj index 8642e69e..6e945f94 100644 --- a/Code/Misc/Input/Input.vcxproj +++ b/Code/Misc/Input/Input.vcxproj @@ -28,6 +28,7 @@ + @@ -35,6 +36,7 @@ + diff --git a/Code/Misc/Input/L_inputClass.cpp b/Code/Misc/Input/L_inputClass.cpp index 03271333..c0fe6a63 100644 --- a/Code/Misc/Input/L_inputClass.cpp +++ b/Code/Misc/Input/L_inputClass.cpp @@ -189,7 +189,7 @@ float InputClass::GetPitch( ) float InputClass::GetYaw( ) { float dX = (static_cast( m_mouseState.lX)/5); - return -dX; + return dX; } bool InputClass::IsMousePressed() From bf41bd38d4e4a153cef33ff417b6f580089d7e64 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 11:34:29 +0100 Subject: [PATCH 08/11] 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 09/11] 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) ); } From 4150ba0fc37087fd57a85a30fe40ab2dce0e60bc Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 20 Feb 2014 11:57:26 +0100 Subject: [PATCH 10/11] GameLogic - Added default scael 1:1 --- Code/Game/GameLogic/Object.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 1f43263b..84ff248b 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -30,6 +30,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfte this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); + this->scale = Float3(1.0f, 1.0f, 1.0f); } @@ -41,6 +42,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICusto this->objectID = objectID; this->extraDamageOnCollision = 0; this->rigidBody->SetCustomTag(this); + this->scale = Float3(1.0f, 1.0f, 1.0f); } Object::~Object(void) From 1079b20e15b1282114fd34244cb121bbb2590d13 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 11:59:26 +0100 Subject: [PATCH 11/11] Updating player pos and RB, moved camera pos for testing --- Code/Game/GameClient/GameClientState/GameState.cpp | 12 +++++++++++- .../Game/GameClient/GameClientState/NetLoadState.cpp | 2 ++ Code/Game/GameLogic/Game_PlayerData.cpp | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 69a37597..d355fc97 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -126,6 +126,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa RBData.position = position; RBData.rotation = ArrayToQuaternion( rotation ); RBData.scale = scale; + RBData.type = RB_Type_Cube; // !RB DEBUG if( isMyPlayer ) { @@ -138,7 +139,10 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa this->privData->myId = id; this->privData->camera.SetPosition( this->privData->player.getPos() ); Float3 offset = Float3( 0.0f ); - offset.y = this->privData->player.getScale().y * 0.9f; + // DEBUG position of camera so we can see the player model + offset.y = this->privData->player.getScale().y * 5.0f; + offset.z = this->privData->player.getScale().z * -5.0f; + // !DEBUG this->privData->camera.SetHeadOffset( offset ); this->privData->camera.UpdateOrientation(); } @@ -500,6 +504,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState this->privData->camera.SetRotation( rotation ); this->privData->player.setPos( position ); this->privData->player.setRot( rotation ); + this->privData->player.updateWorld(); + // RB DEBUG + this->privData->player.setRBPos ( position ); + this->privData->player.setRBRot ( rotation ); + this->privData->player.updateRBWorld(); + // !RB DEBUG } C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index de4f57d5..9ef0dac9 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -157,6 +157,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2; RBData.type = RB_Type_Cube; staticObject->InitRB( RBData ); + staticObject->updateRBWorld(); } if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere) @@ -166,6 +167,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2; RBData.type = RB_Type_Sphere; staticObject->InitRB( RBData ); + staticObject->updateRBWorld(); } // !RB DEBUG diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index ed964724..045da742 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -5,7 +5,7 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,250,0); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0); Oyster::Math::Float height = 2.0f; Oyster::Math::Float radius = 0.5f; Oyster::Math::Float mass = 40; @@ -24,7 +24,7 @@ Game::PlayerData::PlayerData() 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,180,0); Oyster::Math::Float height = 2.0f; Oyster::Math::Float radius = 0.5f; Oyster::Math::Float mass = 40;