Bugs and Compilation errors dealt with

This commit is contained in:
Dander7BD 2014-02-12 14:33:56 +01:00
parent d7102fe7e6
commit 5ff8661843
14 changed files with 63 additions and 49 deletions

View File

@ -87,6 +87,8 @@ namespace DanBias
float dt = (float)data.timer.getElapsedSeconds(); float dt = (float)data.timer.getElapsedSeconds();
data.timer.reset(); data.timer.reset();
::Oyster::Graphics::API::Update( dt );
if(data.networkClient.IsConnected()) if(data.networkClient.IsConnected())
data.networkClient.Update(); data.networkClient.Update();
@ -95,7 +97,7 @@ namespace DanBias
{ {
if(Update(dt) != S_OK) if(Update(dt) != S_OK)
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
if(Render(dt) != S_OK) if(Render() != S_OK)
return DanBiasClientReturn_Error; return DanBiasClientReturn_Error;
data.capFrame = 0; data.capFrame = 0;
} }
@ -185,7 +187,7 @@ namespace DanBias
return S_OK; return S_OK;
} }
HRESULT DanBiasGame::Render(float deltaTime) HRESULT DanBiasGame::Render( )
{ {
data.state->Render(); data.state->Render();

View File

@ -17,12 +17,14 @@ namespace DanBias
class C_Object class C_Object
{ {
protected:
Oyster::Graphics::Model::Model *model;
private: private:
Oyster::Math::Float4x4 world; Oyster::Math::Float4x4 world;
Oyster::Math::Float3 position; Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation; Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
Oyster::Graphics::Model::Model *model;
int id; int id;
void updateWorld(); void updateWorld();
public: public:

View File

@ -3,19 +3,14 @@
using namespace DanBias::Client; using namespace DanBias::Client;
C_Player::C_Player(void) C_Player::C_Player(void)
:C_DynamicObj() :C_DynamicObj() {}
{
} C_Player::~C_Player(void) {}
C_Player::~C_Player(void)
{
}
void C_Player::Init(ModelInitData modelInit) void C_Player::Init(ModelInitData modelInit)
{ {
C_Object::Init(modelInit); C_Object::Init(modelInit);
Oyster::Graphics::API::PlayAnimation(model, L"movement");
Oyster::Graphics::API::PlayAnimation( this->model, L"movement" );
//Oyster::Graphics::API::Update(0.002f); //Oyster::Graphics::API::Update(0.002f);
} }

View File

@ -5,13 +5,15 @@ namespace DanBias
{ {
namespace Client namespace Client
{ {
class C_Player : public C_DynamicObj class C_Player : public C_DynamicObj
{ {
private: private:
public: public:
C_Player(void); C_Player(void);
virtual ~C_Player(void); virtual ~C_Player(void);
void Init(ModelInitData modelInit); void Init(ModelInitData modelInit);
};};}; };
}
}
#endif #endif

View File

@ -11,5 +11,5 @@ GameClientState::~GameClientState(void)
{ {
} }
void DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e ) void GameClientState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{ /* do nothing */ } { /* do nothing */ }

View File

@ -409,10 +409,6 @@ void GameState::readKeyInput(InputClass* KeyInput)
GameLogic::Protocol_PlayerLook playerLookDir; GameLogic::Protocol_PlayerLook playerLookDir;
Float4 look = camera.GetLook(); Float4 look = camera.GetLook();
playerLookDir.lookDirX = look.x;
playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z;
playerLookDir.deltaX = -KeyInput->GetYaw();
privData->nwClient->Send( playerLookDir ); privData->nwClient->Send( playerLookDir );
} }

View File

@ -164,7 +164,7 @@ GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput)
return ClientState_Same; return ClientState_Same;
} }
bool LanMenuState::Render(float dt) bool LanMenuState::Render( )
{ {
Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj); Oyster::Graphics::API::SetProjection( privData->proj);

View File

@ -22,7 +22,7 @@ namespace DanBias
bool LoadModels(std::wstring file); bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos); bool InitCamera(Oyster::Math::Float3 startPos);
virtual bool Render(float dt); virtual bool Render();
virtual bool Release(); virtual bool Release();
private: private:

View File

@ -98,9 +98,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
return ClientState_Same; return ClientState_Same;
} }
bool LobbyState::Render(float dt) bool LobbyState::Render( )
{ {
Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj); Oyster::Graphics::API::SetProjection( privData->proj);

View File

@ -7,10 +7,15 @@
#include <GameServerAPI.h> #include <GameServerAPI.h>
#include "NetworkClient.h" #include "NetworkClient.h"
#include "EventHandler\EventHandler.h"
#include "Buttons\ButtonRectangle.h"
using namespace ::DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster::Math3D; using namespace ::Oyster::Math3D;
using namespace ::Oyster::Network; using namespace ::Oyster::Network;
using namespace ::Utility::DynamicMemory; using namespace ::Utility::DynamicMemory;
using namespace ::Utility::StaticArray;
using namespace ::Oyster::Event;
struct MainState::MyData struct MainState::MyData
{ {
@ -20,10 +25,12 @@ struct MainState::MyData
Float4x4 proj; Float4x4 proj;
UniquePointer<C_Object> object[2]; UniquePointer<C_Object> object[2];
int modelCount;
NetworkClient *nwClient; NetworkClient *nwClient;
EventButtonCollection button;
}; };
void OnButtonInteract( Oyster::Event::ButtonEvent<GameClientState*>& e );
MainState::MainState(void) {} MainState::MainState(void) {}
MainState::~MainState(void) {} MainState::~MainState(void) {}
@ -32,6 +39,13 @@ bool MainState::Init( NetworkClient* nwClient )
{ {
this->privData = new MyData(); this->privData = new MyData();
// create buttons
ButtonRectangle<GameClientState*> *button = new ButtonRectangle<GameClientState*>( L"box_tex.png", OnButtonInteract, this, 0.5f, 0.5f, 0.1f, 0.1f, true );
this->privData->button.AddButton( button );
// bind button collection to the singleton eventhandler
EventHandler::Instance().AddCollection( &this->privData->button );
// load models // load models
LoadModels(L"UImodels.txt"); LoadModels(L"UImodels.txt");
InitCamera( Float3(0.0f, 0.0f, 5.4f) ); InitCamera( Float3(0.0f, 0.0f, 5.4f) );
@ -49,7 +63,6 @@ bool MainState::LoadModels(std::wstring file)
// open file // open file
// read file // read file
// init models // init models
privData->modelCount = 2;
ModelInitData modelData; ModelInitData modelData;
@ -126,16 +139,19 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI
bool MainState::Render() bool MainState::Render()
{ {
Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetView(privData->view);
Oyster::Graphics::API::SetProjection( privData->proj); Oyster::Graphics::API::SetProjection( privData->proj);
Oyster::Graphics::API::NewFrame(); Oyster::Graphics::API::NewFrame();
// render objects // render objects
for (int i = 0; i < privData->modelCount; i++) //for (int i = 0; i < NumElementsOf(privData->object); i++)
{ //{
privData->object[i]->Render(); // privData->object[i]->Render();
} //}
Oyster::Graphics::API::StartGuiRender();
this->privData->button.Render();
// render effects // render effects
@ -147,15 +163,19 @@ bool MainState::Render()
bool MainState::Release() bool MainState::Release()
{ {
for (int i = 0; i < privData->modelCount; i++) for (int i = 0; i < NumElementsOf(privData->object); i++)
{ {
privData->object[i]->Release();
delete privData->object[i];
privData->object[i] = NULL; privData->object[i] = NULL;
} }
delete privData;
privData = NULL; privData = NULL;
// button collection will be autoreleased from EventHandler
return true; return true;
} }
/// button actions
void OnButtonInteract( Oyster::Event::ButtonEvent<GameClientState*>& e )
{
}

View File

@ -24,8 +24,6 @@ namespace DanBias
bool Render(); bool Render();
bool Release(); bool Release();
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
}; };
} }
} }

View File

@ -52,7 +52,7 @@ namespace DanBias
static HRESULT InitInput(); static HRESULT InitInput();
static HRESULT Update(float deltaTime); static HRESULT Update(float deltaTime);
static HRESULT Render(float deltaTime); static HRESULT Render();
static HRESULT CleanUp(); static HRESULT CleanUp();
}; };

View File

@ -38,7 +38,6 @@ struct NetworkClient::PrivateData : public IThreadObject
{ {
NetworkSession *owner; NetworkSession *owner;
NetworkClient *parent; NetworkClient *parent;
ClientEventFunction OnRecieve;
Connection connection; Connection connection;
Translator translator; Translator translator;
OysterThread thread; OysterThread thread;
@ -57,7 +56,6 @@ struct NetworkClient::PrivateData : public IThreadObject
: ID(currID++) : ID(currID++)
, parent(0) , parent(0)
, owner(0) , owner(0)
, OnRecieve(OnRecieve_Default)
{ {
InitWinSock(); InitWinSock();
this->thread.Create(this, false); this->thread.Create(this, false);
@ -226,7 +224,8 @@ unsigned int NetworkClient::PrivateData::currID = 0;
*************************************/ *************************************/
NetworkClient::NetworkClient() NetworkClient::NetworkClient()
: privateData(0) : privateData(nullptr),
OnRecieve(OnRecieve_Default)
{ } { }
NetworkClient::~NetworkClient() NetworkClient::~NetworkClient()
@ -326,11 +325,11 @@ void NetworkClient::SetMessagePump( NetworkClient::ClientEventFunction func )
{ {
if( func ) if( func )
{ {
this->privateData->OnRecieve = func; this->OnRecieve = func;
} }
else else
{ {
this->privateData->OnRecieve = OnRecieve_Default; this->OnRecieve = OnRecieve_Default;
} }
} }
@ -353,7 +352,7 @@ void NetworkClient::DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e)
} }
else else
{ {
this->privateData->OnRecieve( e ); this->OnRecieve( e );
} }
} }

View File

@ -140,6 +140,7 @@ namespace Oyster
NetworkClient(const NetworkClient& obj); NetworkClient(const NetworkClient& obj);
NetworkClient& operator =(const NetworkClient& obj); NetworkClient& operator =(const NetworkClient& obj);
ClientEventFunction OnRecieve;
struct PrivateData; struct PrivateData;
PrivateData* privateData; PrivateData* privateData;
}; };