Merge remote-tracking branch 'origin/GameClient' into New-inputsystem

Conflicts:
	Code/Game/GameClient/GameClientState/GameState.cpp
	Code/Game/GameClient/GameClientState/GamingUI.cpp
This commit is contained in:
Dander7BD 2014-02-20 17:19:48 +01:00
commit ab70cb53c4
27 changed files with 490 additions and 203 deletions

View File

@ -226,6 +226,8 @@
<ClCompile Include="GameClientState\RespawnUI.cpp" /> <ClCompile Include="GameClientState\RespawnUI.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GameClientState\Buttons\Plane_UI.h" />
<ClInclude Include="GameClientState\Buttons\Text_UI.h" />
<ClInclude Include="GameClientState\Camera_Basic.h" /> <ClInclude Include="GameClientState\Camera_Basic.h" />
<ClInclude Include="GameClientState\Buttons\ButtonEllipse.h" /> <ClInclude Include="GameClientState\Buttons\ButtonEllipse.h" />
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" /> <ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>false</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>

View File

@ -113,7 +113,7 @@ namespace DanBias
{ {
if(buttonText.size() > 0) if(buttonText.size() > 0)
{ {
Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, -0.001f), size, size.y * 0.5f, textColor); Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, +0.001f), size, size.y * 0.5f, textColor);
} }
} }

View File

@ -0,0 +1,51 @@
#ifndef DANBIAS_CLIENT_PLANE_UI_H
#define DANBIAS_CLIENT_PLANE_UI_H
#include "DllInterfaces/GFXAPI.h"
namespace DanBias
{
namespace Client
{
class Plane_UI
{
public:
Plane_UI( )
{
pos = Oyster::Math::Float3::null;
size = Oyster::Math::Float2::null;
tintColor = Oyster::Math::Float4(1);
texture = NULL;
}
Plane_UI( std::wstring textureName, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, Oyster::Math::Float4 tintColor = Oyster::Math::Float4(1))
: pos(pos), size(size), tintColor(tintColor)
{
CreateTexture(textureName);
}
virtual ~Plane_UI()
{
Oyster::Graphics::API::DeleteTexture(texture);
texture = NULL;
}
void CreateTexture(std::wstring textureName)
{
//Create texture
texture = Oyster::Graphics::API::CreateTexture(textureName);
}
virtual void RenderTexture() const
{
if(texture)
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, tintColor);
}
private:
Oyster::Math::Float3 pos;
Oyster::Math::Float2 size;
Oyster::Graphics::API::Texture texture;
Oyster::Math::Float4 tintColor;
};
}
}
#endif

View File

@ -0,0 +1,41 @@
#ifndef DANBIAS_CLIENT_TEXT_UI_H
#define DANBIAS_CLIENT_TEXT_UI_H
#include "DllInterfaces/GFXAPI.h"
namespace DanBias
{
namespace Client
{
class Text_UI
{
public:
Text_UI( )
{
pos = Oyster::Math::Float3::null;
size = Oyster::Math::Float2::null;
text = L"";
textColor = Oyster::Math::Float4(1);
}
Text_UI(std::wstring text, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, Oyster::Math::Float4 textColor = Oyster::Math::Float4(1))
: pos(pos), size(size), text(text), textColor(textColor)
{
}
void RenderText() const
{
if(text.size() > 0)
{
Oyster::Graphics::API::RenderText(text, pos, size, size.y * 0.5f, textColor);
}
}
private:
Oyster::Math::Float3 pos;
Oyster::Math::Float2 size;
std::wstring text;
Oyster::Math::Float4 textColor;
};
}
}
#endif

View File

@ -9,6 +9,8 @@
#include "C_obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.h" #include "C_obj/C_StaticObj.h"
#include "Utilities.h" #include "Utilities.h"
#include "GamingUI.h"
#include "RespawnUI.h"
using namespace ::DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster; using namespace ::Oyster;
@ -32,19 +34,6 @@ struct GameState::MyData
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
bool key_Shoot;
bool key_Jump;
// DEGUG KEYS
bool key_Reload_Shaders;
bool key_Wireframe_Toggle;
bool renderWhireframe;
// !DEGUG KEYS
C_Player player; C_Player player;
Camera_FPSV2 camera; Camera_FPSV2 camera;
@ -75,11 +64,6 @@ bool GameState::Init( SharedStateContent &shared )
this->privData = new MyData(); this->privData = new MyData();
this->privData->key_forward = false;
this->privData->key_backward = false;
this->privData->key_strafeRight = false;
this->privData->key_strafeLeft = false;
this->privData->nextState = GameClientState::ClientState_Same; this->privData->nextState = GameClientState::ClientState_Same;
this->privData->nwClient = shared.network; this->privData->nwClient = shared.network;
this->privData->mouseInput = shared.mouseDevice; this->privData->mouseInput = shared.mouseDevice;
@ -95,16 +79,18 @@ bool GameState::Init( SharedStateContent &shared )
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
gfxOp.AmbientValue = 1.0f; gfxOp.AmbientValue = 0.5f;
gfxOp.GlobalGlowTint = Math::Float3(2,1,1);
gfxOp.GlobalTint = Math::Float3(1,1,1);
Graphics::API::SetOptions(gfxOp); Graphics::API::SetOptions(gfxOp);
//tell server ready //tell server ready
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) ); this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
// DEGUG KEYS // DEGUG KEYS
this->privData->key_Reload_Shaders = false; this->key_Reload_Shaders = false;
this->privData->key_Wireframe_Toggle = false; this->key_Wireframe_Toggle = false;
this->privData->renderWhireframe = false; this->renderWhireframe = false;
// !DEGUG KEYS // !DEGUG KEYS
auto light = this->privData->lights->begin(); auto light = this->privData->lights->begin();
@ -113,6 +99,12 @@ bool GameState::Init( SharedStateContent &shared )
light->second->Render(); light->second->Render();
} }
// create UI states
this->gameUI = new GamingUI(this->privData->input, this->privData->nwClient, &this->privData->camera);
this->respawnUI = new RespawnUI(this->privData->nwClient, 20);
this->currGameUI = gameUI;
((GamingUI*)gameUI)->Init();
// TODO init respawn
return true; return true;
} }
@ -146,8 +138,8 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
this->privData->camera.SetPosition( this->privData->player.getPos() ); this->privData->camera.SetPosition( this->privData->player.getPos() );
Float3 offset = Float3( 0.0f ); Float3 offset = Float3( 0.0f );
// DEBUG position of camera so we can see the player model // DEBUG position of camera so we can see the player model
offset.y = this->privData->player.getScale().y * 5.0f; //offset.y = this->privData->player.getScale().y * 5.0f;
offset.z = this->privData->player.getScale().z * -5.0f; //offset.z = this->privData->player.getScale().z * -5.0f;
// !DEBUG // !DEBUG
this->privData->camera.SetHeadOffset( offset ); this->privData->camera.SetHeadOffset( offset );
this->privData->camera.UpdateOrientation(); this->privData->camera.UpdateOrientation();
@ -169,7 +161,25 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
GameClientState::ClientState GameState::Update( float deltaTime ) GameClientState::ClientState GameState::Update( float deltaTime )
{ {
this->ReadKeyInput(); GameStateUI::UIState UIstate = this->currGameUI->Update( deltaTime );
switch (UIstate)
{
case DanBias::Client::GameStateUI::UIState_same:
break;
case DanBias::Client::GameStateUI::UIState_gaming:
break;
case DanBias::Client::GameStateUI::UIState_main_menu:
//this->privData->nextState =
break;
case DanBias::Client::GameStateUI::UIState_shut_down:
this->privData->nextState = ClientState_Quit;
break;
default:
break;
}
// DEBUG keybindings
ReadKeyInput();
return this->privData->nextState; return this->privData->nextState;
} }
@ -194,19 +204,13 @@ bool GameState::Render()
if( dynamicObject->second ) if( dynamicObject->second )
{ {
dynamicObject->second->Render(); dynamicObject->second->Render();
} }
} }
/*auto light = this->privData->lights->begin();
for( ; light != this->privData->lights->end(); ++light )
{
light->second->Render();
}*/
#ifdef _DEBUG #ifdef _DEBUG
//RB DEBUG render wire frame //RB DEBUG render wire frame
if(this->privData->renderWhireframe) if(this->renderWhireframe)
{ {
Oyster::Graphics::API::StartRenderWireFrame(); Oyster::Graphics::API::StartRenderWireFrame();
@ -248,6 +252,12 @@ bool GameState::Render()
//!RB DEBUG //!RB DEBUG
#endif #endif
// render current UI state
if(currGameUI->HaveGUIRender())
currGameUI->RenderGUI();
if(currGameUI->HaveTextRender())
currGameUI->RenderText();
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return true; return true;
} }
@ -281,6 +291,22 @@ bool GameState::Release()
privData = NULL; privData = NULL;
} }
if(respawnUI)
{
respawnUI->Release();
delete respawnUI;
respawnUI = NULL;
}
if(gameUI)
{
gameUI->Release();
delete gameUI;
gameUI = NULL;
}
currGameUI = NULL;
return true; return true;
} }
@ -331,6 +357,7 @@ void GameState::ReadKeyInput()
//if( deltaPos.x != 0.0f ) //This made the camera reset to a specific rotation. Why? //if( deltaPos.x != 0.0f ) //This made the camera reset to a specific rotation. Why?
{ {
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(deltaPos.x * mouseSensitivity) ); this->privData->nwClient->Send( Protocol_PlayerLeftTurn(deltaPos.x * mouseSensitivity) );
}
} }
} }
@ -369,28 +396,28 @@ void GameState::ReadKeyInput()
// Reload shaders // Reload shaders
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_R) ) if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_R) )
{ {
if( !this->privData->key_Reload_Shaders ) if( !this->key_Reload_Shaders )
{ {
Graphics::API::ReloadShaders(); Graphics::API::ReloadShaders();
this->privData->key_Reload_Shaders = true; this->key_Reload_Shaders = true;
} }
} }
else else
this->privData->key_Reload_Shaders = false; this->key_Reload_Shaders = false;
// toggle wire frame render // toggle wire frame render
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_T) ) if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_T) )
{ {
if( !this->privData->key_Wireframe_Toggle ) if( !this->key_Wireframe_Toggle )
{ {
this->privData->renderWhireframe = !this->privData->renderWhireframe; this->renderWhireframe = !this->renderWhireframe;
this->privData->key_Wireframe_Toggle = true; this->key_Wireframe_Toggle = true;
} }
} }
else else
this->privData->key_Wireframe_Toggle = false; this->key_Wireframe_Toggle = false;
#endif // !DEGUG KEYS #endif // !DEGUG KEYS
} }
@ -480,19 +507,21 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
this->privData->player.updateRBWorld(); this->privData->player.updateRBWorld();
// !RB DEBUG // !RB DEBUG
} }
else
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
if( object )
{ {
object->setPos( position ); C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
object->setRot( rotation );
object->updateWorld(); if( object )
// RB DEBUG {
object->setRBPos ( position ); object->setPos( position );
object->setRBRot ( rotation ); object->setRot( rotation );
object->updateRBWorld(); object->updateWorld();
// !RB DEBUG // RB DEBUG
object->setRBPos ( position );
object->setRBRot ( rotation );
object->updateRBWorld();
// !RB DEBUG
}
} }
} }
return GameClientState::event_processed; return GameClientState::event_processed;
@ -549,8 +578,24 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectRespawn: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectRespawn:
case protocol_Gameplay_ObjectDie: break; /** @todo TODO: implement */ this->currGameUI = this->gameUI;
return GameClientState::event_processed;
case protocol_Gameplay_ObjectDie:
this->currGameUI = this->respawnUI;
// set countdown
case protocol_Gameplay_ObjectDisconnectPlayer:
{
//Removes
Protocol_ObjectDisconnectPlayer decoded(data);
auto object = this->privData->dynamicObjects->find( decoded.objectID );
if( object != this->privData->dynamicObjects->end() )
{
object->second = nullptr;
this->privData->dynamicObjects->erase( object );
}
}
return GameClientState::event_processed;
default: break; default: break;
} }
} }

View File

@ -3,6 +3,7 @@
#include "GameClientState.h" #include "GameClientState.h"
#include "OysterMath.h" #include "OysterMath.h"
#include <string> #include <string>
#include "GameStateUI.h"
namespace DanBias { namespace Client namespace DanBias { namespace Client
{ {
@ -31,6 +32,13 @@ namespace DanBias { namespace Client
private: private:
struct MyData; struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData; ::Utility::DynamicMemory::UniquePointer<MyData> privData;
GameStateUI *currGameUI, *gameUI, *respawnUI;
// DEGUG KEYS
bool key_Reload_Shaders;
bool key_Wireframe_Toggle;
bool renderWhireframe;
// !DEGUG KEYS
}; };
} } } }
#endif #endif

View File

@ -1,5 +1,5 @@
#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H #ifndef DANBIAS_CLIENT_GAMESTATEUI_H
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H #define DANBIAS_CLIENT_GAMESTATEUI_H
#include "Utilities.h" #include "Utilities.h"
#include "NetworkClient.h" #include "NetworkClient.h"

View File

@ -6,6 +6,7 @@ using namespace ::DanBias::Client;
using namespace ::Oyster::Network; using namespace ::Oyster::Network;
using namespace ::GameLogic; using namespace ::GameLogic;
using namespace ::Utility::Value; using namespace ::Utility::Value;
using namespace ::Oyster::Math;
using namespace ::Input; using namespace ::Input;
GamingUI::GamingUI() : GamingUI::GamingUI() :
@ -16,6 +17,8 @@ GamingUI::GamingUI() :
this->keyboardInput = nullptr; this->keyboardInput = nullptr;
this->netClient = nullptr; this->netClient = nullptr;
this->camera = nullptr; this->camera = nullptr;
this->plane = nullptr;
this->text = nullptr;
} }
GamingUI::GamingUI( Mouse *mouseInput, Keyboard *keyboardInput, NetworkClient *connection, Camera_FPSV2 *camera ) : GamingUI::GamingUI( Mouse *mouseInput, Keyboard *keyboardInput, NetworkClient *connection, Camera_FPSV2 *camera ) :
@ -28,35 +31,49 @@ GamingUI::GamingUI( Mouse *mouseInput, Keyboard *keyboardInput, NetworkClient *c
} }
GamingUI::~GamingUI() { /* Do nothing */ } GamingUI::~GamingUI() { /* Do nothing */ }
bool GamingUI::Init()
{
// 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));
return true;
}
GameStateUI::UIState GamingUI::Update( float deltaTime ) GameStateUI::UIState GamingUI::Update( float deltaTime )
{ {
ReadKeyInput();
return this->nextState; return this->nextState;
} }
bool GamingUI::HaveGUIRender() const bool GamingUI::HaveGUIRender() const
{ {
return false; // TODO: change to true when we want UI elements like a crosshair return true;
} }
bool GamingUI::HaveTextRender() const bool GamingUI::HaveTextRender() const
{ {
return false; // TODO: change to true when we want UI elements like a chat window return true;
} }
void GamingUI::RenderGUI() const void GamingUI::RenderGUI() const
{ {
// TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender Oyster::Graphics::API::StartGuiRender();
this->plane->RenderTexture();
} }
void GamingUI::RenderText() const void GamingUI::RenderText() const
{ {
// TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender Oyster::Graphics::API::StartTextRender();
this->text->RenderText();
} }
bool GamingUI::Release() bool GamingUI::Release()
{ {
// TODO: Release UI components here. // TODO: Release UI components here.
if(this->plane)
delete this->plane;
if(this->text)
delete this->text;
return true; return true;
} }
@ -82,75 +99,78 @@ void GamingUI::ReadKeyInput()
this->netClient->Send( Protocol_PlayerMovementRight() ); this->netClient->Send( Protocol_PlayerMovementRight() );
} }
// if( this->input->IsKeyPressed(DIK_R) ) //send delta mouse movement
// {
// if( !this->key_Reload_Shaders )
// {
//#ifdef _DEBUG
// Graphics::API::ReloadShaders();
//#endif
// this->key_Reload_Shaders = true;
// }
// }
// else
// this->key_Reload_Shaders = false;
//send delta mouse movement
{ {
static const float mouseSensitivity = Radian( 1.0f ); static const float mouseSensitivity = Radian( 1.0f );
this->camera->PitchDown( this->input->GetPitch() * mouseSensitivity ); this->camera->PitchDown( this->input->GetPitch() * mouseSensitivity );
this->netClient->Send( Protocol_PlayerLeftTurn(this->input->GetYaw() * mouseSensitivity) ); float yaw = this->input->GetYaw();
//if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
{
this->netClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
}
} }
// shoot // shoot
//if( this->input->IsKeyPressed(DIK_Z) ) if( this->input->IsKeyPressed(DIK_Z) )
//{ {
// if( !this->key_Shoot ) if( !this->key_Shoot )
// { {
// Protocol_PlayerShot playerShot; Protocol_PlayerShot playerShot;
// playerShot.primaryPressed = true; playerShot.primaryPressed = true;
// playerShot.secondaryPressed = false; playerShot.secondaryPressed = false;
// playerShot.utilityPressed = false; playerShot.utilityPressed = false;
// this->netClient->Send( playerShot ); this->netClient->Send( playerShot );
// this->key_Shoot = true; this->key_Shoot = true;
// } }
//} }
//else else
// this->key_Shoot = false; this->key_Shoot = false;
if( this->input->IsKeyPressed(DIK_X) )
//if( this->input->IsKeyPressed(DIK_X) ) {
//{ if( !this->key_Shoot )
// if( !this->key_Shoot ) {
// { Protocol_PlayerShot playerShot;
// Protocol_PlayerShot playerShot; playerShot.primaryPressed = false;
// playerShot.primaryPressed = false; playerShot.secondaryPressed = true;
// playerShot.secondaryPressed = true; playerShot.utilityPressed = false;
// playerShot.utilityPressed = false; this->netClient->Send( playerShot );
// this->netClient->Send( playerShot ); this->key_Shoot = true;
// this->key_Shoot = true; }
// } }
//} else
//else this->key_Shoot = false;
// this->key_Shoot = false; if( this->input->IsKeyPressed(DIK_C) )
{
//if( this->input->IsKeyPressed(DIK_C) ) if( !this->key_Shoot )
//{ {
// if( !this->key_Shoot ) Protocol_PlayerShot playerShot;
// { playerShot.primaryPressed = false;
// Protocol_PlayerShot playerShot; playerShot.secondaryPressed = false;
// playerShot.primaryPressed = false; playerShot.utilityPressed = true;
// playerShot.secondaryPressed = false; this->netClient->Send( playerShot );
// playerShot.utilityPressed = true; this->key_Shoot = true;
// this->netClient->Send( playerShot ); }
// this->key_Shoot = true; }
// } else
//} this->key_Shoot = false;
//else
// this->key_Shoot = false;
// jump // jump
if( this->input->IsKeyPressed(DIK_SPACE) ) if( this->input->IsKeyPressed(DIK_SPACE) )
{ {
this->netClient->Send( Protocol_PlayerJump() ); if(!this->key_Jump)
{
this->netClient->Send( Protocol_PlayerJump() );
this->key_Jump = true;
}
} }
else
this->key_Jump = false;
if( this->input->IsKeyPressed(DIK_ESCAPE) )
{
this->nextState = GameStateUI::UIState_shut_down;
}
// !DEGUG KEYS
// TODO: implement sub-menu
} }

View File

@ -4,6 +4,8 @@
#include "GameStateUI.h" #include "GameStateUI.h"
#include "Input.h" #include "Input.h"
#include "Camera_FPSV2.h" #include "Camera_FPSV2.h"
#include "Buttons\Text_UI.h"
#include "Buttons\Plane_UI.h"
namespace DanBias { namespace Client namespace DanBias { namespace Client
{ {
@ -12,6 +14,7 @@ namespace DanBias { namespace Client
public: public:
GamingUI( ::Input::Mouse *mouseInput, ::Input::Keyboard *keyboardInput, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera ); GamingUI( ::Input::Mouse *mouseInput, ::Input::Keyboard *keyboardInput, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
virtual ~GamingUI(); virtual ~GamingUI();
bool Init();
UIState Update( float deltaTime ); UIState Update( float deltaTime );
bool HaveGUIRender() const; bool HaveGUIRender() const;
@ -25,6 +28,15 @@ namespace DanBias { namespace Client
::Input::Keyboard *keyboardInput; ::Input::Keyboard *keyboardInput;
::Oyster::Network::NetworkClient *netClient; ::Oyster::Network::NetworkClient *netClient;
Camera_FPSV2 *camera; Camera_FPSV2 *camera;
Text_UI* text;
Plane_UI* plane;
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
bool key_Shoot;
bool key_Jump;
GamingUI(); GamingUI();
void ReadKeyInput(); void ReadKeyInput();

View File

@ -106,6 +106,8 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
args.pushForce = pushForce; args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
if(hitCone) delete hitCone;
} }
/******************************************************** /********************************************************
@ -141,6 +143,8 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt)
args.pushForce = -pushForce; args.pushForce = -pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
if(hitCone) delete hitCone;
} }
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
@ -150,5 +154,5 @@ void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt)
Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
delete hitSphere; if(hitSphere) delete hitSphere;
} }

View File

@ -79,99 +79,133 @@ void Player::BeginFrame()
Oyster::Math::Float maxSpeed = 30; Oyster::Math::Float maxSpeed = 30;
// Rotate player accordingly
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
Oyster::Math::Quaternion firstUp = this->rigidBody->GetState().quaternion;
this->rigidBody->SetRotationAsAngularAxis(Oyster::Math3D::Float4(this->rigidBody->GetState().centerPos.GetNormalized(), this->rotationUp));
Oyster::Math::Quaternion secondTurn = this->rigidBody->GetState().quaternion;
this->rigidBody->SetRotation(secondTurn*firstUp);
// Direction data
Oyster::Math::Float4x4 xform; Oyster::Math::Float4x4 xform;
xform = this->rigidBody->GetState().GetOrientation(); xform = this->rigidBody->GetState().GetOrientation();
/* Handle turning */
/*if (left)
m_turnAngle -= dt * m_turnVelocity;
if (right)
m_turnAngle += dt * m_turnVelocity;
xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle));*/
Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity();
Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength();
Oyster::Math::Float3 forwardDir = xform.v[2]; Oyster::Math::Float3 forwardDir = xform.v[2];
Oyster::Math::Float3 upDir = xform.v[1];
Oyster::Math::Float3 rightDir = xform.v[0]; Oyster::Math::Float3 rightDir = xform.v[0];
forwardDir.Normalize(); forwardDir.Normalize();
upDir.Normalize();
rightDir.Normalize(); rightDir.Normalize();
// Previous velocities data
Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity();
Oyster::Math::Float3 forwardVelocity = linearVelocity*Oyster::Math::Float3(fabs(forwardDir.x), fabs(forwardDir.y), fabs(forwardDir.z));
Oyster::Math::Float forwardSpeed = (linearVelocity*forwardDir).GetLength();
Oyster::Math::Float3 rightVelocity = linearVelocity*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z));
Oyster::Math::Float rightSpeed = (linearVelocity*rightDir).GetLength();
Oyster::Math::Float3 upVelocity = linearVelocity*Oyster::Math::Float3(fabs(upDir.x), fabs(upDir.y), fabs(upDir.z));
// Walking data
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);
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f; Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
if (key_forward > 0.001) // Check for input
if(key_forward > 0.001)
{ {
key_forward -= gameInstance->GetFrameTime(); key_forward -= gameInstance->GetFrameTime();
walkDirection += forwardDir; walkDirection += forwardDir;
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();
} }
if (key_strafeRight > 0.001) if(key_strafeRight > 0.001)
{ {
key_strafeRight -= gameInstance->GetFrameTime(); key_strafeRight -= gameInstance->GetFrameTime();
walkDirection -= rightDir; walkDirection += rightDir;
walkDirection.Normalize();
} }
if (key_strafeLeft > 0.001) if(key_strafeLeft > 0.001)
{ {
key_strafeLeft -= gameInstance->GetFrameTime(); key_strafeLeft -= gameInstance->GetFrameTime();
walkDirection += rightDir; walkDirection -= rightDir;
}
// Dampen velocity if certain keys are not pressed
if(key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.9f)
{
if(key_forward <= 0.001 && key_backward <= 0.001)
{
forwardVelocity *= Oyster::Math::Float3(0.2f*fabs(forwardDir.x), 0.2f*fabs(forwardDir.y), 0.2f*fabs(forwardDir.z));
}
if(key_strafeRight <= 0.001 && key_strafeLeft <= 0.001)
{
rightVelocity *= Oyster::Math::Float3(0.2f*fabs(rightDir.x), 0.2f*fabs(rightDir.y), 0.2f*fabs(rightDir.z));
}
}
// Walk if walkdirection is something
if(walkDirection != Oyster::Math::Float3::null)
{
walkDirection.Normalize(); walkDirection.Normalize();
maxSpeed = 40;
}
// If on the ground, accelerate normally
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(this->rigidBody->GetLambda() < 0.9f)
{
/* Dampen when on the ground and not being moved by the player */
linearVelocity *= 0.2f;
this->rigidBody->SetLinearVelocity (linearVelocity);
}
else
{
if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f)
{ {
Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; if(forwardSpeed < maxSpeed)
this->rigidBody->SetLinearVelocity(velocity); {
forwardVelocity += walkDirection*Oyster::Math::Float3(fabs(forwardDir.x), fabs(forwardDir.y), fabs(forwardDir.z)) * walkSpeed;
}
if(rightSpeed < maxSpeed)
{
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), abs(rightDir.y), fabs(rightDir.z)) * walkSpeed;
}
} }
else if(speed < maxSpeed) // If in the air, accelerate slower
if(this->rigidBody->GetLambda() >= 0.9f)
{ {
Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; if(forwardSpeed < maxSpeed)
this->rigidBody->SetLinearVelocity(velocity); {
forwardVelocity += walkDirection*Oyster::Math::Float3(fabs(forwardDir.x), fabs(forwardDir.y), fabs(forwardDir.z)) * walkSpeed*0.2f;
}
if(rightSpeed < maxSpeed)
{
rightVelocity += walkDirection*Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z)) * walkSpeed*0.2f;
}
} }
} }
if (key_jump > 0.001) // Adjust velocities so no squaring occurs
forwardVelocity *= Oyster::Math::Float3(fabs(forwardDir.x), fabs(forwardDir.y), fabs(forwardDir.z));
rightVelocity *= Oyster::Math::Float3(fabs(rightDir.x), fabs(rightDir.y), fabs(rightDir.z));
upVelocity *= Oyster::Math::Float3(fabs(upDir.x), fabs(upDir.y), fabs(upDir.z));
this->rigidBody->SetLinearVelocity(forwardVelocity+rightVelocity+upVelocity);
//Jump
if(key_jump > 0.001)
{ {
this->key_jump -= this->gameInstance->GetFrameTime(); this->key_jump -= this->gameInstance->GetFrameTime();
if(this->rigidBody->GetLambda() < 1.0f) if(this->rigidBody->GetLambda() < 0.9f)
{ {
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.GetNormalized();
this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass*20); this->rigidBody->ApplyImpulse(up*this->rigidBody->GetState().mass*20);
this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING;
} }
} }
Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos;
if(pos == Oyster::Math::Float3(0,0,0))
int i =0;
//this->weapon->Update(0.01f); //this->weapon->Update(0.01f);
} }
void Player::EndFrame() void Player::EndFrame()
{ {
// snap to axis
Oyster::Math::Float4 rotation;
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)
@ -235,13 +269,10 @@ void Player::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D:
// this is the camera right vector // this is the camera right vector
this->lookDir = lookDir; this->lookDir = lookDir;
//Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
//this->rigidBody->SetUpAndRight(up, right);
} }
void Player::TurnLeft(Oyster::Math3D::Float deltaRadians) void Player::TurnLeft(Oyster::Math3D::Float deltaRadians)
{ {
this->rotationUp += deltaRadians; this->rotationUp += deltaRadians;
this->rigidBody->SetRotationAsAngularAxis(Oyster::Math3D::Float4(this->rigidBody->GetState().centerPos.GetNormalized(), this->rotationUp));
} }
void Player::Jump() void Player::Jump()

View File

@ -892,6 +892,38 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectDisconnectPlayer 367
struct Protocol_ObjectDisconnectPlayer :public Oyster::Network::CustomProtocolObject
{
int objectID;
Protocol_ObjectDisconnectPlayer()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->objectID = 0;
}
Protocol_ObjectDisconnectPlayer(int objectID)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->objectID = objectID;
}
Protocol_ObjectDisconnectPlayer(Oyster::Network::CustomNetProtocol& p)
{
this->objectID = p[1].value.netInt;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->objectID;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
} }
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -69,6 +69,8 @@
#define protocol_Gameplay_ObjectWeaponEnergy 364 #define protocol_Gameplay_ObjectWeaponEnergy 364
#define protocol_Gameplay_ObjectRespawn 365 #define protocol_Gameplay_ObjectRespawn 365
#define protocol_Gameplay_ObjectDie 366 #define protocol_Gameplay_ObjectDie 366
//Disconnect
#define protocol_Gameplay_ObjectDisconnectPlayer 367
#define protocol_GameplayMAX 399 #define protocol_GameplayMAX 399

View File

@ -61,8 +61,19 @@ using namespace DanBias;
switch (e.args.type) switch (e.args.type)
{ {
case NetworkClient::ClientEventArgs::EventType_Disconnect: case NetworkClient::ClientEventArgs::EventType_Disconnect:
{
//Send disconnect message to all the other players so the player can be removed from the client.
Protocol_ObjectDisconnectPlayer dp(cl->GetClient()->GetID());
for(int i = 0; i < this->gClients.Size(); i++)
{
if(this->gClients[i] && this->gClients[i] != cl)
{
this->gClients[i]->GetClient()->Send(dp);
}
}
printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
this->gClients[temp]->Invalidate(); this->gClients[temp]->Invalidate();
}
break; break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
break; break;

View File

@ -62,6 +62,9 @@ namespace Oyster
struct PostData struct PostData
{ {
float Amb; float Amb;
Math::Float3 Tint;
Math::Float3 GlowTint;
float PAD;
}; };
struct Text2D struct Text2D

View File

@ -123,6 +123,8 @@ namespace Oyster
Definitions::PostData pd; Definitions::PostData pd;
pd.Amb = option.AmbientValue; pd.Amb = option.AmbientValue;
pd.Tint = option.GlobalTint;
pd.GlowTint = option.GlobalGlowTint;
void* data = Render::Resources::Post::Data.Map(); void* data = Render::Resources::Post::Data.Map();
memcpy(data,&pd,sizeof(Definitions::PostData)); memcpy(data,&pd,sizeof(Definitions::PostData));

View File

@ -30,6 +30,9 @@ namespace Oyster
//between 0-1 //between 0-1
float AmbientValue; float AmbientValue;
Math::Float3 GlobalTint;
Math::Float3 GlobalGlowTint;
Math::Float2 Resolution; Math::Float2 Resolution;
//Bytes on the GPU //Bytes on the GPU

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>true</ShowAllFiles> <ShowAllFiles>false</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -56,8 +56,8 @@ namespace Oyster
//size.x = size.x / (text.length() * TEXT_SPACING /2); //size.x = size.x / (text.length() * TEXT_SPACING /2);
pos *= 2; pos.xy *= 2;
pos -= 1; pos.xy -= 1;
pos.y *= -1; pos.y *= -1;

View File

@ -41,8 +41,8 @@ PixelOut main(VertexOut input)
{ {
PixelOut output; PixelOut output;
float4 DiffGlow = Diffuse.Sample(S1, input.UV); float4 DiffGlow = Diffuse.Sample(S1, input.UV);
float3 tint = Color*(1-DiffGlow) + GlowColor * DiffGlow; float3 tint = Color*(1-DiffGlow.w) + GlowColor * DiffGlow.w;
tint = tint / 2; tint = Color*(1-DiffGlow.w) + GlowColor * DiffGlow.w;
output.DiffuseGlow = DiffGlow * float4(tint,1); output.DiffuseGlow = DiffGlow * float4(tint,1);
//NORMALIZE //NORMALIZE

View File

@ -47,7 +47,7 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
DepthBase = DepthBase /4; DepthBase = DepthBase /4;
Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue); Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue);
Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy];
Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w * 10 /* * (2-DepthBase) */,1); Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w /* * (2-DepthBase) */,DiffBase.w);
Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1); Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1);
} }

View File

@ -1,7 +1,7 @@
#include "Defines.hlsli" #include "Defines.hlsli"
#include "PosManipulation.hlsli" #include "PosManipulation.hlsli"
static float Radius = 10; static float Radius = 1;
float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID)
{ {

View File

@ -9,6 +9,8 @@ SamplerState S1 : register(s0);
cbuffer Size : register(b0) cbuffer Size : register(b0)
{ {
float AmbFactor; float AmbFactor;
float3 Color;
float3 GlowColor;
} }
[numthreads(16, 16, 1)] [numthreads(16, 16, 1)]
@ -26,9 +28,10 @@ void main( uint3 DTid : SV_DispatchThreadID )
SSAO = SSAO / 16; SSAO = SSAO / 16;
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
float3 Amb = Ambient[DTid.xy/2].xyz * SSAO; float3 Amb = Ambient[DTid.xy/2].xyz * SSAO * Color;
float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz; float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
Glow = float4(Glow.xyz * GlowColor, 1);
float4 GUI; float4 GUI;
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0); uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
@ -40,4 +43,5 @@ void main( uint3 DTid : SV_DispatchThreadID )
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1); //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1);
//Output[DTid.xy] = SSAO * float4(1,1,1,1); //Output[DTid.xy] = SSAO * float4(1,1,1,1);
//Output[DTid.xy] = Ambient[DTid.xy];
} }

View File

@ -168,9 +168,15 @@ void SimpleRigidBody::SetRotationAsAngularAxis(::Oyster::Math::Float4 angularAxi
return; return;
} }
float s = sin(angularAxis.w/2);
float x = angularAxis.x * s;
float y = angularAxis.y * s;
float z = angularAxis.z * s;
float w = cos(angularAxis.w/2);
btTransform trans; btTransform trans;
btVector3 vector(angularAxis.x, angularAxis.y, angularAxis.z); btVector3 vector(angularAxis.x, angularAxis.y, angularAxis.z);
btQuaternion quaternion(vector, angularAxis.w); btQuaternion quaternion(x,y,z,w);
trans = this->rigidBody->getWorldTransform(); trans = this->rigidBody->getWorldTransform();
trans.setRotation(quaternion); trans.setRotation(quaternion);
@ -263,22 +269,11 @@ Float4x4 SimpleRigidBody::GetRotation() const
Float4 SimpleRigidBody::GetRotationAsAngularAxis() Float4 SimpleRigidBody::GetRotationAsAngularAxis()
{ {
Float4 axis = Float4::null; Float4 axis = Float4::null;
Float s = sqrtf(1 - this->state.quaternion.real*this->state.quaternion.real); btTransform trans;
axis.w = 2*acos(this->state.quaternion.real*this->state.quaternion.real); trans = this->rigidBody->getWorldTransform();
axis.xyz = trans.getRotation().getAxis();
if(1 - this->state.quaternion.real > 0.001f) axis.w = trans.getRotation().getAngle();
{
axis.x = this->state.quaternion.imaginary.x/s;
axis.y = this->state.quaternion.imaginary.y/s;
axis.z = this->state.quaternion.imaginary.z/s;
}
else
{
axis.x = this->state.quaternion.imaginary.x;
axis.y = this->state.quaternion.imaginary.y;
axis.z = this->state.quaternion.imaginary.z;
}
return axis; return axis;
} }
@ -353,7 +348,8 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
{ {
btTransform xform; btTransform xform;
xform = this->rigidBody->getWorldTransform (); xform = this->rigidBody->getWorldTransform ();
btVector3 down = -xform.getBasis()[1]; Float3 normalDown = -this->state.centerPos.GetNormalized();
btVector3 down(normalDown.x, normalDown.y, normalDown.z);
btVector3 forward = xform.getBasis()[2]; btVector3 forward = xform.getBasis()[2];
down.normalize (); down.normalize ();
forward.normalize(); forward.normalize();
@ -361,12 +357,17 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
this->raySource[0] = xform.getOrigin(); this->raySource[0] = xform.getOrigin();
this->raySource[1] = xform.getOrigin(); this->raySource[1] = xform.getOrigin();
if(this->state.reach.y < 1.0f)
Float angle = acos(Float3(0, 1, 0).Dot(this->state.centerPos.GetNormalized())); Float angle = acos(Float3(0, 1, 0).Dot(this->state.centerPos.GetNormalized()));
down.setZ(-down.z()); //down.setZ(-down.z());
down.setX(-down.x());
btVector3 targetPlus = down * this->state.reach.y * btScalar(1.1); btVector3 targetPlus = down * this->state.reach.y * btScalar(1.1);
if(this->state.mass == 40)
{
const char* breakpoint = "STOP";
}
this->rayTarget[0] = this->raySource[0] + targetPlus; this->rayTarget[0] = this->raySource[0] + targetPlus;
this->rayTarget[1] = this->raySource[1] + forward * this->state.reach.y * btScalar(1.1); this->rayTarget[1] = this->raySource[1] + forward * this->state.reach.y * btScalar(1.1);
@ -383,7 +384,6 @@ void SimpleRigidBody::PreStep (const btCollisionWorld* collisionWorld)
{ {
if (rayResult.m_collisionObject == m_me) if (rayResult.m_collisionObject == m_me)
return 1.0; return 1.0;
return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace); return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace);
} }
protected: protected:
@ -413,3 +413,13 @@ float SimpleRigidBody::GetLambda() const
{ {
return this->rayLambda[0]; return this->rayLambda[0];
} }
void SimpleRigidBody::MoveToLimbo()
{
this->rigidBody->setCollisionFlags(this->rigidBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
}
void SimpleRigidBody::ReleaseFromLimbo()
{
this->rigidBody->setCollisionFlags(btCollisionObject::CF_KINEMATIC_OBJECT);
}

View File

@ -69,6 +69,9 @@ namespace Oyster
float GetLambda() const; float GetLambda() const;
void MoveToLimbo();
void ReleaseFromLimbo();
private: private:
btCollisionShape* collisionShape; btCollisionShape* collisionShape;

View File

@ -169,6 +169,9 @@ namespace Oyster
virtual void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss) = 0; virtual void CallSubscription_AfterCollisionResponse(ICustomBody* bodyA, ICustomBody* bodyB, Math::Float kineticEnergyLoss) = 0;
virtual void CallSubscription_Move() = 0; virtual void CallSubscription_Move() = 0;
virtual void MoveToLimbo() = 0;
virtual void ReleaseFromLimbo() = 0;
/******************************************************** /********************************************************
* @return the void pointer set by SetCustomTag. * @return the void pointer set by SetCustomTag.
* nullptr if none is set. * nullptr if none is set.