Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameClient

This commit is contained in:
dean11 2014-02-17 15:12:29 +01:00
commit a0c9677123
18 changed files with 273 additions and 341 deletions

View File

@ -21,19 +21,19 @@ namespace DanBias
ButtonEllipse() ButtonEllipse()
: EventButtonGUI(), radius(0) : EventButtonGUI(), radius(0)
{} {}
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
{} {}
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
{} {}
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
{} {}
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
{} {}

View File

@ -21,19 +21,19 @@ namespace DanBias
ButtonRectangle() ButtonRectangle()
: EventButtonGUI(), width(0), height(0) : EventButtonGUI(), width(0), height(0)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize) : EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
{} {}

View File

@ -31,30 +31,30 @@ namespace DanBias
{ {
public: public:
EventButtonGUI() EventButtonGUI()
: EventButton(), pos(0, 0), size(0, 0), texture(NULL), buttonText(""), textColor(0, 0, 0) : EventButton(), pos(0, 0), size(0, 0), texture(NULL), buttonText(""), textColor(1, 1, 1, 1)
{} {}
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor) : EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor) : EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor) : EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor) : EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
@ -77,7 +77,7 @@ namespace DanBias
if(EventButton<Owner>::Enabled()) if(EventButton<Owner>::Enabled())
{ {
// let the using dev decide what is rendered // let the using dev decide what is rendered
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float4(1.0f, 1.0f, 1.0f, 1.0f));
//Render att xPos and yPos //Render att xPos and yPos
//With width and height //With width and height
@ -125,7 +125,7 @@ namespace DanBias
Oyster::Graphics::API::Texture texture; Oyster::Graphics::API::Texture texture;
std::wstring buttonText; std::wstring buttonText;
Oyster::Math::Float3 textColor; Oyster::Math::Float4 textColor;
}; };
} }
} }

View File

@ -20,7 +20,7 @@ namespace DanBias { namespace Client
{ {
public: public:
TextField(); TextField();
TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height ); TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height );
virtual ~TextField(); virtual ~TextField();
virtual void RenderText(); virtual void RenderText();
@ -62,7 +62,7 @@ namespace DanBias { namespace Client
} }
template<typename Owner> template<typename Owner>
TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize ) TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize )
: ButtonRectangle( backgroundTexture, L"", textColor, owner, pos, size, resize ) : ButtonRectangle( backgroundTexture, L"", textColor, owner, pos, size, resize )
{ {
this->fontHeight = 0.025f; this->fontHeight = 0.025f;

View File

@ -5,10 +5,16 @@
#include "Camera_FPS.h" #include "Camera_FPS.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
#include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.h"
using namespace ::DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster; using namespace ::Oyster;
using namespace ::Oyster::Network; using namespace ::Oyster::Network;
using namespace ::Oyster::Math3D; using namespace ::Oyster::Math3D;
using namespace ::GameLogic;
using namespace ::Utility::DynamicMemory;
struct GameState::MyData struct GameState::MyData
{ {
@ -16,14 +22,27 @@ struct GameState::MyData
GameClientState::ClientState nextState; GameClientState::ClientState nextState;
NetworkClient *nwClient; NetworkClient *nwClient;
InputClass *input; InputClass *input;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
bool key_Shoot;
bool key_Jump;
C_Player player;
Camera_FPS camera;
int myId;
} privData; } privData;
GameState::GameState() GameState::GameState()
{ {
key_forward = false; this->privData = nullptr;
key_backward = false;
key_strafeRight = false;
key_strafeLeft = false;
} }
GameState::~GameState() GameState::~GameState()
@ -34,202 +53,69 @@ GameState::~GameState()
bool GameState::Init( SharedStateContent &shared ) bool GameState::Init( SharedStateContent &shared )
{ {
// load models // we may assume that shared.network is properly connected
privData = new MyData(); // and there is content in shared.dynamicObjects and shared.staticObjects
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->input = shared.input; this->privData->input = shared.input;
this->privData->staticObjects = &shared.staticObjects;
LoadGame(); this->privData->dynamicObjects = &shared.dynamicObjects;
//tell server ready //tell server ready
this->privData->nwClient->Send( GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready) ); this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
return true;
}
GameState::gameStateState GameState::LoadGame()
{
return gameStateState_playing;
}
bool GameState::LoadModels(std::string mapFile)
{
GameLogic::LevelLoader levelLoader;
std::vector<Utility::DynamicMemory::SmartPointer<GameLogic::ObjectTypeHeader>> objects;
objects = levelLoader.LoadLevel(mapFile);
int objCount = objects.size();
int modelId = 0;
ModelInitData modelData;
for (int i = 0; i < objCount; i++)
{
GameLogic::ObjectTypeHeader* obj = objects.at(i);
switch (obj->typeID)
{
case GameLogic::ObjectType::ObjectType_LevelMetaData:
break;
case GameLogic::ObjectType::ObjectType_Static:
{
GameLogic::ObjectHeader* staticObjData = ((GameLogic::ObjectHeader*)obj);
modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end());
modelData.visible = true;
//modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2);
modelData.id = modelId++;
this->staticObjects.Push(new C_StaticObj());
this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
}
break;
case GameLogic::ObjectType::ObjectType_Dynamic:
{
GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj);
//modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2);
modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end());
modelData.visible = true;
modelData.id = modelId++;
this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
}
break;
case GameLogic::ObjectType::ObjectType_Light:
{
GameLogic::BasicLight* lightData = ((GameLogic::BasicLight*)obj);
switch( lightData->lightType )
{
case GameLogic::LightType_PointLight:
{
//Oyster::Graphics::Definitions::Pointlight plight;
//plight.Pos = ((GameLogic::PointLight*)lightData)->position;
//plight.Color = lightData->diffuseColor;
//plight.Radius = 100;
//plight.Bright = 0.9f;
//Oyster::Graphics::API::AddLight(plight);
}
break;
default: break;
}
}
break;
default:
break;
}
}
myId += modelId++;
// add player model
//modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2);
modelData.visible = true;
modelData.modelPath = L"char_still_sizeref.dan";
modelData.id = myId;
// load models
this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
/*C_Player* obj = new C_Player();
privData->object.push_back(obj);
privData->object[privData->object.size() -1 ]->Init(modelData);
*/
return true;
}
bool GameState::InitCamera(Float3 startPos)
{
camera.SetHeadOffset( Float3(0.0f, 1.0f, 1.0f) );
camera.SetPerspectiveProjection( pi / 4.0f, 1024.0f/768.0f, 1.0f, 1000.0f );
camera.UpdateOrientation();
Oyster::Graphics::API::SetProjection(camera.GetProjectionMatrix());
return true; return true;
} }
void GameState::InitiatePlayer( int id, std::wstring modelName, Float4x4 world ) void GameState::InitiatePlayer( int id, std::wstring modelName, Float4x4 world )
{ {
myId = id; this->privData->myId = id;
ModelInitData modelData; ModelInitData modelData;
C_Object* obj;
modelData.visible = true; modelData.visible = true;
//modelData.world = world;
modelData.position = Float3(world[12], world[13], world[14]); modelData.position = Float3(world[12], world[13], world[14]);
modelData.rotation = Quaternion(Float3(0,0,0), 1); modelData.rotation = Quaternion(Float3(0,0,0), 1);
modelData.scale = Float3(1,1,1); modelData.scale = Float3(1,1,1);
modelData.modelPath = modelName; modelData.modelPath = modelName;
modelData.id = myId; modelData.id = this->privData->myId;
this->privData->player.Init( modelData );
obj = new C_Player(); this->privData->camera.SetPosition( this->privData->player.getPos() );
this->dynamicObjects.Push(obj); this->privData->camera.UpdateOrientation();
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
Float3 pos = Float3(world[12], world[13], world[14]);
camera.SetPosition( pos );
camera.UpdateOrientation();
} }
GameClientState::ClientState GameState::Update( float deltaTime ) GameClientState::ClientState GameState::Update( float deltaTime )
{ {
//switch (privData->state)
//{
//case gameStateState_loading: //Will this ever happen in this scope??
// {
// // load map
// // wait for all players
// LoadGame();
// GameLogic::Protocol_General_Status gameStatus;
// gameStatus.status = GameLogic::Protocol_General_Status::States_ready;
// privData->nwClient->Send(gameStatus);
// privData->state = gameStateState_playing;
// }
// break;
//case gameStateState_playing:
// // read server data
// // update objects
// {
// readKeyInput(KeyInput);
// camera.UpdateOrientation();
// }
// break;
//case gameStateState_end:
// return ClientState_Lobby;
// break;
//default:
// break;
//}
//
//// send key input to server.
//return ClientState_Same;
return this->privData->nextState; return this->privData->nextState;
} }
bool GameState::Render() bool GameState::Render()
{ {
Oyster::Graphics::API::SetView( camera.GetViewMatrix() ); Oyster::Graphics::API::SetView( this->privData->camera.GetViewMatrix() );
Oyster::Graphics::API::NewFrame(); Oyster::Graphics::API::NewFrame();
for (unsigned int i = 0; i < staticObjects.Size(); i++)
// for debugging to be replaced with render weapon
this->privData->player.Render();
auto staticObject = this->privData->staticObjects->begin();
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
{ {
staticObjects[i]->Render(); staticObject->second->Render();
} }
for (unsigned int i = 0; i < dynamicObjects.Size(); i++)
auto dynamicObject = this->privData->dynamicObjects->begin();
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{ {
dynamicObjects[i]->Render(); dynamicObject->second->Render();
} }
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
@ -238,8 +124,25 @@ bool GameState::Render()
bool GameState::Release() bool GameState::Release()
{ {
if( privData )
{
auto staticObject = this->privData->staticObjects->begin();
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
{
staticObject->second = nullptr;
}
auto dynamicObject = this->privData->dynamicObjects->begin();
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{
dynamicObject->second = nullptr;
}
this->privData->staticObjects->clear();
this->privData->dynamicObjects->clear();
privData = NULL; privData = NULL;
}
return true; return true;
} }
@ -248,138 +151,119 @@ void GameState::ChangeState( ClientState next )
this->privData->nextState = next; this->privData->nextState = next;
} }
void GameState::readKeyInput(InputClass* KeyInput) void GameState::ReadKeyInput()
{ {
if(KeyInput->IsKeyPressed(DIK_W)) if( this->privData->input->IsKeyPressed(DIK_W) )
{ {
if(!key_forward) if(!this->privData->key_forward)
{ {
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementForward()); this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
key_forward = true; this->privData->key_forward = true;
} }
} }
else else
key_forward = false; this->privData->key_forward = false;
if(KeyInput->IsKeyPressed(DIK_S)) if( this->privData->input->IsKeyPressed(DIK_S) )
{ {
if(!key_backward) if( !this->privData->key_backward )
{ {
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementBackward()); this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
key_backward = true; this->privData->key_backward = true;
} }
} }
else else
key_backward = false; this->privData->key_backward = false;
if(KeyInput->IsKeyPressed(DIK_A)) if( this->privData->input->IsKeyPressed(DIK_A) )
{ {
if(!key_strafeLeft) if( !this->privData->key_strafeLeft )
{ {
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementLeft()); this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
key_strafeLeft = true; this->privData->key_strafeLeft = true;
} }
} }
else else
key_strafeLeft = false; this->privData->key_strafeLeft = false;
if(KeyInput->IsKeyPressed(DIK_D)) if( this->privData->input->IsKeyPressed(DIK_D) )
{ {
if(!key_strafeRight) if( !this->privData->key_strafeRight )
{ {
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementRight()); this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
key_strafeRight = true; this->privData->key_strafeRight = true;
} }
} }
else else
key_strafeRight = false; this->privData->key_strafeRight = false;
//send delta mouse movement //send delta mouse movement
//if (KeyInput->IsMousePressed())
{ {
camera.YawRight( -KeyInput->GetYaw() ); this->privData->camera.YawRight( -this->privData->input->GetYaw() );
camera.PitchUp( KeyInput->GetPitch() ); this->privData->camera.PitchUp( this->privData->input->GetPitch() );
camera.UpdateOrientation(); this->privData->camera.UpdateOrientation();
GameLogic::Protocol_PlayerLook playerLookDir; privData->nwClient->Send( Protocol_PlayerLook(this->privData->camera.GetLook(), this->privData->camera.GetRight()) );
Float4 look = camera.GetLook();
privData->nwClient->Send( playerLookDir );
} }
// shoot // shoot
if(KeyInput->IsKeyPressed(DIK_Z)) if( this->privData->input->IsKeyPressed(DIK_Z) )
{ {
if(!key_Shoot) if( !this->privData->key_Shoot )
{ {
GameLogic::Protocol_PlayerShot playerShot; Protocol_PlayerShot playerShot;
playerShot.primaryPressed = true; playerShot.primaryPressed = true;
playerShot.secondaryPressed = false; playerShot.secondaryPressed = false;
playerShot.utilityPressed = false; playerShot.utilityPressed = false;
privData->nwClient->Send(playerShot); this->privData->nwClient->Send( playerShot );
key_Shoot = true; this->privData->key_Shoot = true;
} }
} }
else else
key_Shoot = false; this->privData->key_Shoot = false;
if(KeyInput->IsKeyPressed(DIK_X)) if( this->privData->input->IsKeyPressed(DIK_X) )
{ {
if(!key_Shoot) if( !this->privData->key_Shoot )
{ {
GameLogic::Protocol_PlayerShot playerShot; Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false; playerShot.primaryPressed = false;
playerShot.secondaryPressed = true; playerShot.secondaryPressed = true;
playerShot.utilityPressed = false; playerShot.utilityPressed = false;
privData->nwClient->Send(playerShot); this->privData->nwClient->Send( playerShot );
key_Shoot = true; this->privData->key_Shoot = true;
} }
} }
else else
key_Shoot = false; this->privData->key_Shoot = false;
if(KeyInput->IsKeyPressed(DIK_C)) if( this->privData->input->IsKeyPressed(DIK_C) )
{ {
if(!key_Shoot) if( !this->privData->key_Shoot )
{ {
GameLogic::Protocol_PlayerShot playerShot; Protocol_PlayerShot playerShot;
playerShot.primaryPressed = false; playerShot.primaryPressed = false;
playerShot.secondaryPressed = false; playerShot.secondaryPressed = false;
playerShot.utilityPressed = true; playerShot.utilityPressed = true;
privData->nwClient->Send(playerShot); this->privData->nwClient->Send( playerShot );
key_Shoot = true; this->privData->key_Shoot = true;
} }
} }
else else
key_Shoot = false; this->privData->key_Shoot = false;
// jump // jump
if(KeyInput->IsKeyPressed(DIK_SPACE)) if( this->privData->input->IsKeyPressed(DIK_SPACE) )
{ {
if(!key_Jump) if(!this->privData->key_Jump)
{ {
privData->nwClient->Send(GameLogic::Protocol_PlayerJump()); this->privData->nwClient->Send( Protocol_PlayerJump() );
key_Jump = true; this->privData->key_Jump = true;
} }
} }
else else
key_Jump = false; this->privData->key_Jump = false;
// send event data // TODO: implement sub-menu
//
//if(KeyInput->IsKeyPressed(DIK_L))
// privData->state = GameState::gameStateState_end;
}
using namespace ::Oyster::Network;
using namespace ::Utility::DynamicMemory;
// returns -1 if none found
int FindObject( const DynamicArray<SmartPointer<C_Object>> &collection, int id )
{
int num = collection.Size();
for( int i = 0; i < num; ++i ) if( id == collection[i]->GetId() )
return i;
return -1;
} }
void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e ) void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
@ -396,76 +280,67 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectPosition: case protocol_Gameplay_ObjectPosition:
{ {
GameLogic::Protocol_ObjectPosition decoded(data); Protocol_ObjectPosition decoded(data);
// if is this player. Remember to change camera // if is this player. Remember to change camera
if( this->myId == decoded.object_ID ) if( this->privData->myId == decoded.object_ID )
camera.SetPosition( decoded.position ); this->privData->camera.SetPosition( decoded.position );
int i = FindObject( this->dynamicObjects, decoded.object_ID ); (*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
if( i > -1 )
this->dynamicObjects[i]->setPos( decoded.position );
} }
break; break;
case protocol_Gameplay_ObjectScale: case protocol_Gameplay_ObjectScale:
{ {
GameLogic::Protocol_ObjectScale decoded(data); Protocol_ObjectScale decoded(data);
int i = FindObject( this->dynamicObjects, decoded.object_ID ); (*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
if( i > -1 )
this->dynamicObjects[i]->setScale( decoded.scale );
} }
break; break;
case protocol_Gameplay_ObjectRotation: case protocol_Gameplay_ObjectRotation:
{ {
GameLogic::Protocol_ObjectRotation decoded(data); Protocol_ObjectRotation decoded(data);
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] ); Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
// if is this player. Remember to change camera // if is this player. Remember to change camera
if( this->myId == decoded.object_ID ) if( this->privData->myId == decoded.object_ID )
camera.SetAngular( AngularAxis(rotation) ); this->privData->camera.SetAngular( AngularAxis(rotation) );
int i = FindObject( this->dynamicObjects, decoded.object_ID ); (*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
if( i > -1 )
this->dynamicObjects[i]->setRot( rotation );
} }
break; break;
case protocol_Gameplay_ObjectPositionRotation: case protocol_Gameplay_ObjectPositionRotation:
{ {
GameLogic::Protocol_ObjectPositionRotation decoded(data); Protocol_ObjectPositionRotation decoded(data);
Float3 position = decoded.position; Float3 position = decoded.position;
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] ); Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
// if is this player. Remember to change camera // if is this player. Remember to change camera
if( this->myId == decoded.object_ID ) if( this->privData->myId == decoded.object_ID )
{ {
camera.SetPosition( position ); this->privData->camera.SetPosition( position );
camera.SetAngular( AngularAxis(rotation) ); this->privData->camera.SetAngular( AngularAxis(rotation) );
} }
int i = FindObject( this->dynamicObjects, decoded.object_ID ); C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
if( i > -1 ) object->setPos( position );
{ object->setRot( rotation );
this->dynamicObjects[i]->setPos( position );
this->dynamicObjects[i]->setRot( rotation );
}
} }
break; break;
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectDisabled: case protocol_Gameplay_ObjectDisabled:
{ {
GameLogic::Protocol_ObjectDisable decoded(data); Protocol_ObjectDisable decoded(data);
int i = FindObject( this->dynamicObjects, decoded.objectID ); auto object = this->privData->dynamicObjects->find( decoded.objectID );
if( i > -1 ) if( object != this->privData->dynamicObjects->end() )
{ {
this->dynamicObjects[i].Release(); object->second = nullptr;
this->dynamicObjects.Pop(i); this->privData->dynamicObjects->erase( object );
} }
} }
break; break;
case protocol_Gameplay_ObjectCreate: case protocol_Gameplay_ObjectCreate:
{ {
GameLogic::Protocol_ObjectCreate decoded(data); Protocol_ObjectCreate decoded(data);
C_DynamicObj* object = new C_DynamicObj(); C_DynamicObj* object = new C_DynamicObj();
ModelInitData modelData; ModelInitData modelData;
@ -480,7 +355,7 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
} }
object->Init(modelData); object->Init(modelData);
dynamicObjects.Push(object); (*this->privData->dynamicObjects)[decoded.object_ID] = object;
} }
break; break;

View File

@ -4,13 +4,6 @@
#include "OysterMath.h" #include "OysterMath.h"
#include <string> #include <string>
#include "Camera_FPS.h"
#include "LevelLoader/LevelLoader.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.h"
#include "DynamicArray.h"
namespace DanBias { namespace Client namespace DanBias { namespace Client
{ {
class GameState : public GameClientState class GameState : public GameClientState
@ -27,12 +20,8 @@ namespace DanBias { namespace Client
~GameState(void); ~GameState(void);
bool Init( SharedStateContent &shared ); bool Init( SharedStateContent &shared );
GameClientState::ClientState Update( float deltaTime ) override; GameClientState::ClientState Update( float deltaTime ) override;
bool LoadModels(std::string mapFile);
bool InitCamera(Oyster::Math::Float3 startPos) ;
void InitiatePlayer( int id, std::wstring modelName, Oyster::Math::Float4x4 world ); void InitiatePlayer( int id, std::wstring modelName, Oyster::Math::Float4x4 world );
gameStateState LoadGame(); void ReadKeyInput();
void readKeyInput(InputClass* KeyInput);
bool Render()override; bool Render()override;
bool Release()override; bool Release()override;
@ -43,20 +32,6 @@ namespace DanBias { namespace Client
private: private:
struct MyData; struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData; ::Utility::DynamicMemory::UniquePointer<MyData> privData;
bool key_forward;
bool key_backward;
bool key_strafeRight;
bool key_strafeLeft;
bool key_Shoot;
bool key_Jump;
Camera_FPS camera;
int myId;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_StaticObj>> staticObjects;
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_Object>> dynamicObjects;
//Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_Player>> playObjects;
}; };
} } } }
#endif #endif

View File

@ -58,7 +58,7 @@ bool LanMenuState::Init( SharedStateContent &shared )
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" ); this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
// create guiElements // create guiElements
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None ); this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float4(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
this->privData->connectIP->ReserveLines( 1 ); this->privData->connectIP->ReserveLines( 1 );
this->privData->connectIP->AppendText( L"127.0.0.1" ); this->privData->connectIP->AppendText( L"127.0.0.1" );
this->privData->connectIP->SetFontHeight( 0.08f ); this->privData->connectIP->SetFontHeight( 0.08f );
@ -68,10 +68,10 @@ bool LanMenuState::Init( SharedStateContent &shared )
this->privData->guiElements.AddButton( this->privData->connectIP ); this->privData->guiElements.AddButton( this->privData->connectIP );
ButtonRectangle<LanMenuState*> *guiElements; ButtonRectangle<LanMenuState*> *guiElements;
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None ); guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float4(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements ); this->privData->guiElements.AddButton( guiElements );
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float3(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None ); guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float4(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements ); this->privData->guiElements.AddButton( guiElements );
// bind guiElements collection to the singleton eventhandler // bind guiElements collection to the singleton eventhandler
@ -123,8 +123,8 @@ void LanMenuState::ChangeState( ClientState next )
{ {
case GameClientState::ClientState_Lobby: case GameClientState::ClientState_Lobby:
// attempt to connect to lobby // attempt to connect to lobby
//if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) ) if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
// return; // TODO: temporary commented out return;
break; break;
default: break; default: break;
} }

View File

@ -50,7 +50,7 @@ bool LobbyAdminState::Init( SharedStateContent &shared )
// create buttons // create buttons
ButtonRectangle<LobbyAdminState*> *button; ButtonRectangle<LobbyAdminState*> *button;
button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float4(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button ); this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler // bind button collection to the singleton eventhandler

View File

@ -50,7 +50,7 @@ bool LobbyState::Init( SharedStateContent &shared )
// create buttons // create buttons
ButtonRectangle<LobbyState*> *button; ButtonRectangle<LobbyState*> *button;
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float4(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button ); this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler // bind button collection to the singleton eventhandler

View File

@ -54,13 +54,13 @@ bool MainState::Init( SharedStateContent &shared )
// create buttons // create buttons
ButtonRectangle<MainState*> *button; ButtonRectangle<MainState*> *button;
button = new ButtonRectangle<MainState*>( L"earth_md.png", L"Create", Float3(1.0f), OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); button = new ButtonRectangle<MainState*>( L"earth_md.png", L"Create", Float4(1.0f), OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button ); this->privData->guiElements.AddButton( button );
button = new ButtonRectangle<MainState*>( L"skysphere_md.png", L"Join", Float3(1.0f), OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); button = new ButtonRectangle<MainState*>( L"skysphere_md.png", L"Join", Float4(1.0f), OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button ); this->privData->guiElements.AddButton( button );
button = new ButtonRectangle<MainState*>( L"plane_texture_md.png", L"Quit", Float3(1.0f), OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); button = new ButtonRectangle<MainState*>( L"plane_texture_md.png", L"Quit", Float4(1.0f), OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( button ); this->privData->guiElements.AddButton( button );
// bind button collection to the singleton eventhandler // bind button collection to the singleton eventhandler

View File

@ -1,13 +1,18 @@
#include "NetLoadState.h" #include "NetLoadState.h"
#include "NetworkClient.h" #include "NetworkClient.h"
#include "OysterMath.h" #include "OysterMath.h"
#include "../Game/GameProtocols/Protocols.h" #include "Protocols.h"
#include "LevelLoader\LevelLoader.h"
#include "Utilities.h"
#include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h"
using namespace ::DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster; using namespace ::Oyster;
using namespace ::Oyster::Math; using namespace ::Oyster::Math;
using namespace ::Oyster::Network; using namespace ::Oyster::Network;
using namespace ::GameLogic; using namespace ::GameLogic;
using namespace ::Utility::String;
struct NetLoadState::MyData struct NetLoadState::MyData
{ {
@ -16,9 +21,17 @@ struct NetLoadState::MyData
GameClientState::ClientState nextState; GameClientState::ClientState nextState;
NetworkClient *nwClient; NetworkClient *nwClient;
Graphics::API::Texture background; Graphics::API::Texture background;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
bool loading; bool loading;
}; };
inline Quaternion ArrayToQuaternion( float source[4] )
{
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
}
NetLoadState::NetLoadState(void) {} NetLoadState::NetLoadState(void) {}
NetLoadState::~NetLoadState(void) NetLoadState::~NetLoadState(void)
@ -34,6 +47,9 @@ bool NetLoadState::Init( SharedStateContent &shared )
this->privData->nextState = GameClientState::ClientState_Same; this->privData->nextState = GameClientState::ClientState_Same;
this->privData->nwClient = shared.network; this->privData->nwClient = shared.network;
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" ); this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
this->privData->dynamicObjects = &shared.dynamicObjects;
this->privData->staticObjects = &shared.staticObjects;
this->privData->loading = false; this->privData->loading = false;
// we may assume that nwClient is properly connected to the server // we may assume that nwClient is properly connected to the server
@ -82,6 +98,7 @@ void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientE
if( ID == protocol_Lobby_CreateGame && !this->privData->loading ) if( ID == protocol_Lobby_CreateGame && !this->privData->loading )
{ {
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName ); this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
this->ChangeState( ClientState_Game );
} }
} }
@ -89,7 +106,69 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
{ {
this->privData->loading = true; this->privData->loading = true;
// TODO: ask Sam about level loader LevelLoader loader;
auto objects = loader.LoadLevel( fileName );
auto object = objects.begin();
ObjectHeader *oh;
int objectID = 100; // first 100 is reserved for players. This is how the server does it.
for( ; object != objects.end(); ++object )
{
++objectID;
oh = (ObjectHeader*)&*object;
switch( oh->typeID )
{
case ObjectType::ObjectType_Static:
{
ModelInitData desc;
desc.id = objectID;
StringToWstring( oh->ModelFile, desc.modelPath );
desc.position = oh->position;
desc.rotation = ArrayToQuaternion( oh->rotation );
desc.scale = oh->scale;
desc.visible = true;
C_StaticObj *staticObject = new C_StaticObj();
if( staticObject->Init( desc ) )
{
(*this->privData->staticObjects)[objectID] = staticObject;
}
else
{
delete staticObject;
}
}
break;
case ObjectType::ObjectType_Dynamic:
{
ModelInitData desc;
desc.id = objectID;
StringToWstring( oh->ModelFile, desc.modelPath );
desc.position = oh->position;
desc.rotation = ArrayToQuaternion( oh->rotation );
desc.scale = oh->scale;
desc.visible = true;
C_DynamicObj *dynamicObject = new C_DynamicObj();
if( dynamicObject->Init( desc ) )
{
(*this->privData->dynamicObjects)[objectID] = dynamicObject;
}
else
{
delete dynamicObject;
}
}
break;
case ObjectType::ObjectType_Light:
{
/* TODO: implement light into the leveformat */
}
break;
default: break;
}
}
this->privData->nextState = ClientState::ClientState_Game; this->privData->nextState = ClientState::ClientState_Game;
} }

View File

@ -11,6 +11,8 @@
#include <map> #include <map>
#include "Utilities.h" #include "Utilities.h"
#include "C_Object.h" #include "C_Object.h"
#include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h"
#include "NetworkClient.h" #include "NetworkClient.h"
#include "L_inputClass.h" #include "L_inputClass.h"
@ -19,7 +21,8 @@ namespace DanBias { namespace Client
struct SharedStateContent struct SharedStateContent
{ {
public: public:
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Object>> scene; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> staticObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> dynamicObjects;
::Oyster::Network::NetworkClient *network; ::Oyster::Network::NetworkClient *network;
InputClass* input; InputClass* input;
}; };

View File

@ -161,7 +161,7 @@ namespace Oyster
Render::Gui::Begin2DRender(); Render::Gui::Begin2DRender();
} }
void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float3 color) void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float4 color)
{ {
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color); Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color);
} }
@ -196,7 +196,7 @@ namespace Oyster
Render::Gui::Begin2DTextRender(); Render::Gui::Begin2DTextRender();
} }
void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 color) void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float4 color)
{ {
Render::Gui::RenderText(text, Pos, Size, FontSize, color); Render::Gui::RenderText(text, Pos, Size, FontSize, color);
} }

View File

@ -57,13 +57,13 @@ namespace Oyster
static void StartGuiRender(); static void StartGuiRender();
//! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system //! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system
static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float4 Color = Math::Float4(1,1,1,1));
//! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame() //! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame()
static void StartTextRender(); static void StartTextRender();
//! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system //! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system
static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 Color = Math::Float3(1,1,1)); static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float4 Color = Math::Float4(1,1,1,1));
//! @brief Performs light calculations, post effects and presents the scene //! @brief Performs light calculations, post effects and presents the scene
static void EndFrame(); static void EndFrame();

View File

@ -16,7 +16,7 @@ namespace Oyster
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
} }
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float3 color) void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float4 color)
{ {
Core::deviceContext->PSSetShaderResources(0,1,&tex); Core::deviceContext->PSSetShaderResources(0,1,&tex);
@ -37,7 +37,7 @@ namespace Oyster
Render::Resources::Gui::Data.Unmap(); Render::Resources::Gui::Data.Unmap();
data = Render::Resources::Color.Map(); data = Render::Resources::Color.Map();
memcpy(data,&color,sizeof(Math::Float3)); memcpy(data,&color,sizeof(Math::Float4));
Render::Resources::Color.Unmap(); Render::Resources::Color.Unmap();
@ -50,7 +50,7 @@ namespace Oyster
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass); Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
} }
void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 color) void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float4 color)
{ {
//size.x = size.x / (text.length() * TEXT_SPACING /2); //size.x = size.x / (text.length() * TEXT_SPACING /2);
@ -81,7 +81,7 @@ namespace Oyster
Definitions::Text2D tmpInst; Definitions::Text2D tmpInst;
data = Render::Resources::Color.Map(); data = Render::Resources::Color.Map();
memcpy(data,&color,sizeof(Math::Float3)); memcpy(data,&color,sizeof(Math::Float4));
Render::Resources::Color.Unmap(); Render::Resources::Color.Unmap();
void* dest = Resources::Gui::Text::Vertex.Map(); void* dest = Resources::Gui::Text::Vertex.Map();

View File

@ -12,9 +12,9 @@ namespace Oyster
{ {
public: public:
static void Begin2DRender(); static void Begin2DRender();
static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float4 tint = Math::Float4(1,1,1,1));
static void Begin2DTextRender(); static void Begin2DTextRender();
static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 tint = Math::Float3(1,1,1)); static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float4 tint = Math::Float4(1,1,1,1));
}; };
} }
} }

View File

@ -2,5 +2,5 @@
float4 main(Pixel2DIn input) : SV_Target0 float4 main(Pixel2DIn input) : SV_Target0
{ {
return Material.Sample(LinearSampler,input.Uv) * float4(Color,1); return Material.Sample(LinearSampler,input.Uv) * Color;
} }

View File

@ -10,7 +10,7 @@ cbuffer EveryObject2D : register(b0)
cbuffer ColorData : register(b0) cbuffer ColorData : register(b0)
{ {
float3 Color; float4 Color;
}; };
struct Pixel2DIn struct Pixel2DIn