diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index 0f34b9c8..717899a3 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -17,12 +17,13 @@ GamingUI::GamingUI() : this->sharedData = nullptr; this->camera = nullptr; this->plane = nullptr; - this->text = nullptr; + this->energy = nullptr; + this->hp = nullptr; this->key_backward = false; this->key_forward = false; this->key_strafeLeft = false; this->key_strafeRight = false; - this->nextState = GameStateUI::UIState_same; + this->nextState = GameStateUI::UIState_same; } GamingUI::GamingUI( SharedStateContent* shared, Camera_FPSV2 *camera ) : @@ -31,7 +32,8 @@ GamingUI::GamingUI( SharedStateContent* shared, Camera_FPSV2 *camera ) : this->sharedData = shared; this->camera = camera; this->plane = nullptr; - this->text = nullptr; + this->hp = nullptr; + this->energy = nullptr; this->key_backward = false; this->key_forward = false; this->key_strafeLeft = false; @@ -44,11 +46,10 @@ bool GamingUI::Init() { // z value should be between 0.5 - 0.9 so that it will be behind other states // add textures and text - this->plane = new Plane_UI(L"box_tex.png", Float3(0.5f, 0.0f, 0.5f), Float2(0.3f, 0.1f)); - this->text = new Text_UI(L"hej", Float3(0.5f,0.0f,0.1f), Float2(0.1f,0.1f)); + this->hp = new Text_UI(L"100", Float3(0.04f,0.91f,0.1f), Float2(0.1f,0.1f), Float4(1,0,0,1)); + this->energy = new Text_UI(L"100", Float3(0.8f,0.91f,0.1f), Float2(0.4f,0.1f), Float4(1,1,0,1)); this->sharedData = sharedData; - // setting input mode to all raw this->sharedData->keyboardDevice->Activate(); this->sharedData->keyboardDevice->AddKeyboardEvent(this); @@ -75,12 +76,13 @@ bool GamingUI::HaveTextRender() const void GamingUI::RenderGUI() const { - this->plane->RenderTexture(); + //this->plane->RenderTexture(); } void GamingUI::RenderText() const { - this->text->RenderText(); + this->hp->RenderText(); + this->energy->RenderText(); } bool GamingUI::Release() @@ -90,16 +92,15 @@ bool GamingUI::Release() this->sharedData->mouseDevice->RemoveMouseEvent(this); // TODO: Release UI components here. - if(this->plane) delete this->plane; - if(this->text) delete this->text; - + if(this->plane) delete this->plane; + if(this->hp) delete this->hp; + if(this->energy) delete this->energy; this->sharedData = 0; - return true; } void GamingUI::SetHPtext( std::wstring hp ) { - this->text->setText(hp); + this->hp->setText(hp); } void GamingUI::ReadKeyInput() { diff --git a/Code/Game/GameClient/GameClientState/GamingUI.h b/Code/Game/GameClient/GameClientState/GamingUI.h index a8f3bc7a..d0d1121e 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.h +++ b/Code/Game/GameClient/GameClientState/GamingUI.h @@ -45,7 +45,8 @@ namespace DanBias { namespace Client Camera_FPSV2 *camera; // TODO add multiple UI elements - Text_UI* text; + Text_UI* hp; + Text_UI* energy; Plane_UI* plane; bool key_forward; diff --git a/Code/Game/GameClient/GameClientState/RespawnUI.cpp b/Code/Game/GameClient/GameClientState/RespawnUI.cpp index 21732df6..cb5cb6b5 100644 --- a/Code/Game/GameClient/GameClientState/RespawnUI.cpp +++ b/Code/Game/GameClient/GameClientState/RespawnUI.cpp @@ -27,7 +27,7 @@ bool RespawnUI::Init() { // z value should be between 0.5 - 0.9 so that it will be behind other states // add textures and text - this->text = new Text_UI(L"DEAD", Float3(0.5f,0.0f,0.5f), Float2(0.2f,0.2f)); + this->text = new Text_UI(L"DEAD", Float3(0.35f,0.35f,0.5f), Float2(0.5f,0.2f)); return true; } GameStateUI::UIState RespawnUI::Update( float deltaTime ) diff --git a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 772bf32e..ee562083 100644 --- a/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/Physics/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -93,6 +93,8 @@ ICustomBody* API_Impl::AddCollisionSphere(float radius, ::Oyster::Math::Float4 r this->dynamicsWorld->addRigidBody(rigidBody); this->customBodies.push_back(body); + dynamic_cast(collisionShape)->setMargin(0.2f); + state.centerPos = position; state.reach = Float3(radius, radius, radius); state.dynamicFrictionCoeff = dynamicFriction; @@ -132,6 +134,8 @@ ICustomBody* API_Impl::AddCollisionBox(Float3 halfSize, ::Oyster::Math::Float4 r this->dynamicsWorld->addRigidBody(rigidBody); this->customBodies.push_back(body); + dynamic_cast(collisionShape)->setMargin(0.2f); + state.centerPos = position; state.reach = halfSize; state.dynamicFrictionCoeff = dynamicFriction; @@ -171,6 +175,8 @@ ICustomBody* API_Impl::AddCollisionCylinder(::Oyster::Math::Float3 halfSize, ::O this->dynamicsWorld->addRigidBody(rigidBody); this->customBodies.push_back(body); + dynamic_cast(collisionShape)->setMargin(0.2f); + state.centerPos = position; state.reach = halfSize; state.dynamicFrictionCoeff = dynamicFriction; @@ -212,6 +218,8 @@ ICustomBody* API_Impl::AddCharacter(::Oyster::Math::Float height, ::Oyster::Math this->dynamicsWorld->addRigidBody(rigidBody); this->customBodies.push_back(body); + dynamic_cast(collisionShape)->setMargin(0.2f); + state.centerPos = position; state.reach = Float3(radius, height, radius); state.dynamicFrictionCoeff = dynamicFriction; @@ -245,9 +253,11 @@ ICustomBody* API_Impl::AddTriangleMesh(const std::wstring fileName, ::Oyster::Ma btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w),btVector3(position.x, position.y, position.z))); body->SetMotionState(motionState); + + // Add rigid body btVector3 fallInertia(0, 0, 0); - //collisionShape->calculateLocalInertia(mass, fallInertia); + //collisionShape->calcu%lateLocalInertia(mass, fallInertia); btRigidBody::btRigidBodyConstructionInfo rigidBodyCI(0, motionState, collisionShape, fallInertia); btRigidBody* rigidBody = new btRigidBody(rigidBodyCI); rigidBody->setFriction(staticFriction); @@ -259,6 +269,8 @@ ICustomBody* API_Impl::AddTriangleMesh(const std::wstring fileName, ::Oyster::Ma this->dynamicsWorld->addRigidBody(rigidBody); this->customBodies.push_back(body); + dynamic_cast(collisionShape)->setMargin(0.5); + state.centerPos = position; state.reach = Float3(0, 0, 0); state.dynamicFrictionCoeff = dynamicFriction; @@ -284,10 +296,7 @@ void API_Impl::UpdateWorld() 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(); - } + simpleBody->SetPreviousVelocity(simpleBody->GetLinearVelocity()); } @@ -301,7 +310,12 @@ 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())); + 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(); + } } int numManifolds = this->dynamicsWorld->getDispatcher()->getNumManifolds(); diff --git a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp index 7a8665a1..e81152ee 100644 --- a/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/Physics/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -73,6 +73,7 @@ void SimpleRigidBody::SetState( const SimpleRigidBody::State &state ) void SimpleRigidBody::ApplyImpulse(Float3 impulse) { this->rigidBody->applyCentralImpulse(btVector3(impulse.x, impulse.y, impulse.z)); + this->rigidBody->setActivationState(ACTIVE_TAG); } void SimpleRigidBody::SetCollisionShape(btCollisionShape* shape) diff --git a/Code/Physics/lib/Debug/BulletCollision_Debug.lib b/Code/Physics/lib/Debug/BulletCollision_Debug.lib index e47dbff6..af72b886 100644 Binary files a/Code/Physics/lib/Debug/BulletCollision_Debug.lib and b/Code/Physics/lib/Debug/BulletCollision_Debug.lib differ