GL - gameState merge
This commit is contained in:
parent
74ac5e2d31
commit
5b984db9ba
|
@ -44,7 +44,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameP
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -272,18 +272,18 @@ Global
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64
|
{060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.Build.0 = Debug|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64
|
{5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -299,6 +299,5 @@ Global
|
||||||
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
{060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
||||||
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "C_obj/C_DynamicObj.h"
|
#include "C_obj/C_DynamicObj.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "Camera.h"
|
|
||||||
|
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ struct GameState::myData
|
||||||
gameStateState state;
|
gameStateState state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
GameState::GameState(void)
|
GameState::GameState(void)
|
||||||
|
@ -37,35 +38,22 @@ GameState::~GameState(void)
|
||||||
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
||||||
{
|
{
|
||||||
// load models
|
// load models
|
||||||
camera = new Camera;
|
|
||||||
privData = new myData();
|
privData = new myData();
|
||||||
privData->state = gameStateState_loading;
|
privData->state = gameStateState_loading;
|
||||||
privData->nwClient = nwClient;
|
privData->nwClient = nwClient;
|
||||||
privData->state = LoadGame();
|
privData->state = LoadGame();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
GameState::gameStateState GameState::LoadGame()
|
GameState::gameStateState GameState::LoadGame()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::Definitions::Pointlight plight;
|
Oyster::Graphics::Definitions::Pointlight plight;
|
||||||
plight.Pos = Oyster::Math::Float3(0,15,5);
|
plight.Pos = Oyster::Math::Float3(0,3,0);
|
||||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||||
plight.Radius = 50;
|
plight.Radius = 5;
|
||||||
plight.Bright = 2;
|
plight.Bright = 2;
|
||||||
Oyster::Graphics::API::AddLight(plight);
|
|
||||||
plight.Pos = Oyster::Math::Float3(10,15,5);
|
|
||||||
plight.Color = Oyster::Math::Float3(1,0,0);
|
|
||||||
plight.Radius = 50;
|
|
||||||
plight.Bright = 2;
|
|
||||||
Oyster::Graphics::API::AddLight(plight);
|
|
||||||
plight.Pos = Oyster::Math::Float3(10,-15,5);
|
|
||||||
plight.Color = Oyster::Math::Float3(0,0,1);
|
|
||||||
plight.Radius = 50;
|
|
||||||
plight.Bright = 2;
|
|
||||||
|
|
||||||
Oyster::Graphics::API::AddLight(plight);
|
Oyster::Graphics::API::AddLight(plight);
|
||||||
LoadModels(L"map");
|
LoadModels(L"map");
|
||||||
InitCamera(Oyster::Math::Float3(0,0,20.0f));
|
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||||
return gameStateState_playing;
|
return gameStateState_playing;
|
||||||
}
|
}
|
||||||
bool GameState::LoadModels(std::wstring mapFile)
|
bool GameState::LoadModels(std::wstring mapFile)
|
||||||
|
@ -102,15 +90,6 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
modelData.modelPath = L"..\\Content\\Models\\char_white.dan";
|
||||||
modelData.id ++;
|
modelData.id ++;
|
||||||
|
|
||||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0));
|
|
||||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity;
|
|
||||||
scale.v[0].x = 8;
|
|
||||||
scale.v[1].y = 8;
|
|
||||||
scale.v[2].z = 8;
|
|
||||||
modelData.world = scale; //modelData.world * translate
|
|
||||||
modelData.modelPath = L"ball.dan";
|
|
||||||
modelData.id ++;
|
|
||||||
|
|
||||||
obj = new C_DynamicObj();
|
obj = new C_DynamicObj();
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
@ -120,19 +99,10 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
}
|
}
|
||||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
|
|
||||||
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
|
|
||||||
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20);
|
|
||||||
|
|
||||||
camera->LookAt(pos, dir, up);
|
|
||||||
camera->SetLens(3.14f/2, 1024/768, 1, 1000);
|
|
||||||
|
|
||||||
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
|
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
|
||||||
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
|
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
|
||||||
Oyster::Graphics::API::SetProjection(privData->proj);
|
Oyster::Graphics::API::SetProjection(privData->proj);
|
||||||
camera->UpdateViewMatrix();
|
|
||||||
privData->view = camera->View();
|
|
||||||
privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
|
|
||||||
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
|
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
|
||||||
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
||||||
return true;
|
return true;
|
||||||
|
@ -157,57 +127,14 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
||||||
// read server data
|
// read server data
|
||||||
// update objects
|
// update objects
|
||||||
{
|
{
|
||||||
readKeyInput(KeyInput);
|
|
||||||
camera->UpdateViewMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case gameStateState_end:
|
|
||||||
return ClientState_Lobby;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// send key input to server.
|
|
||||||
return ClientState_Same;
|
|
||||||
}
|
|
||||||
bool GameState::Render()
|
|
||||||
{
|
|
||||||
Oyster::Graphics::API::SetView(camera->View());
|
|
||||||
//Oyster::Graphics::API::SetProjection(camera->Proj());
|
|
||||||
//Oyster::Graphics::API::SetView(privData->view);
|
|
||||||
Oyster::Graphics::API::SetProjection(privData->proj);
|
|
||||||
Oyster::Graphics::API::NewFrame();
|
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
|
||||||
{
|
|
||||||
privData->object[i]->Render();
|
|
||||||
}
|
|
||||||
Oyster::Graphics::API::EndFrame();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool GameState::Release()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
|
||||||
{
|
|
||||||
privData->object[i]->Release();
|
|
||||||
delete privData->object[i];
|
|
||||||
privData->object[i] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete privData;
|
|
||||||
privData = NULL;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
void GameState::readKeyInput(InputClass* KeyInput)
|
|
||||||
{
|
|
||||||
|
|
||||||
bool send = false;
|
bool send = false;
|
||||||
GameLogic::Protocol_PlayerMovement movePlayer;
|
GameLogic::Protocol_PlayerMovement movePlayer;
|
||||||
movePlayer.bForward = false;
|
movePlayer.bForward = false;
|
||||||
movePlayer.bBackward = false;
|
movePlayer.bBackward = false;
|
||||||
movePlayer.bLeft = false;
|
movePlayer.bStrafeLeft = false;
|
||||||
movePlayer.bRight = false;
|
movePlayer.bStrafeRight = false;
|
||||||
|
movePlayer.bTurnLeft = false;
|
||||||
|
movePlayer.bTurnRight = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_W))
|
if(KeyInput->IsKeyPressed(DIK_W))
|
||||||
{
|
{
|
||||||
|
@ -238,7 +165,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
||||||
{
|
{
|
||||||
if(!key_strafeLeft)
|
if(!key_strafeLeft)
|
||||||
{
|
{
|
||||||
movePlayer.bLeft = true;
|
movePlayer.bStrafeLeft = true;
|
||||||
send = true;
|
send = true;
|
||||||
key_strafeLeft = true;
|
key_strafeLeft = true;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +177,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
||||||
{
|
{
|
||||||
if(!key_strafeRight)
|
if(!key_strafeRight)
|
||||||
{
|
{
|
||||||
movePlayer.bRight = true;
|
movePlayer.bStrafeRight = true;
|
||||||
send = true;
|
send = true;
|
||||||
key_strafeRight = true;
|
key_strafeRight = true;
|
||||||
}
|
}
|
||||||
|
@ -267,24 +194,53 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
||||||
//send delta mouse movement
|
//send delta mouse movement
|
||||||
if (KeyInput->IsMousePressed())
|
if (KeyInput->IsMousePressed())
|
||||||
{
|
{
|
||||||
|
GameLogic::Protocol_PlayerMouse deltaMouseMove;
|
||||||
|
deltaMouseMove.dxMouse = KeyInput->GetYaw();
|
||||||
|
deltaMouseMove.dyMouse = KeyInput->GetPitch();
|
||||||
|
//privData->nwClient->Send(deltaMouseMove);
|
||||||
|
|
||||||
|
|
||||||
camera->Yaw(KeyInput->GetYaw());
|
|
||||||
camera->Pitch(KeyInput->GetPitch());
|
|
||||||
camera->UpdateViewMatrix();
|
|
||||||
GameLogic::Protocol_PlayerLook playerLookDir;
|
|
||||||
Oyster::Math::Float3 look = camera->GetLook();
|
|
||||||
playerLookDir.lookDirX = look.x;
|
|
||||||
playerLookDir.lookDirY = look.y;
|
|
||||||
playerLookDir.lookDirZ = look.z;
|
|
||||||
privData->nwClient->Send(playerLookDir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// send event data
|
// send event data
|
||||||
//
|
//
|
||||||
if(KeyInput->IsKeyPressed(DIK_L))
|
if(KeyInput->IsKeyPressed(DIK_L))
|
||||||
privData->state = GameState::gameStateState_end;
|
privData->state = GameState::gameStateState_end;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case gameStateState_end:
|
||||||
|
return ClientState_Lobby;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// send key input to server.
|
||||||
|
return ClientState_Same;
|
||||||
|
}
|
||||||
|
bool GameState::Render()
|
||||||
|
{
|
||||||
|
Oyster::Graphics::API::SetView(privData->view);
|
||||||
|
Oyster::Graphics::API::SetProjection(privData->proj);
|
||||||
|
Oyster::Graphics::API::NewFrame();
|
||||||
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
|
{
|
||||||
|
privData->object[i]->Render();
|
||||||
|
}
|
||||||
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool GameState::Release()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
|
{
|
||||||
|
privData->object[i]->Release();
|
||||||
|
delete privData->object[i];
|
||||||
|
privData->object[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete privData;
|
||||||
|
privData = NULL;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::Protocol(ProtocolStruct* pos)
|
void GameState::Protocol(ProtocolStruct* pos)
|
||||||
|
@ -311,16 +267,14 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
world[i] = pos->worldPos[i];
|
world[i] = pos->worldPos[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
{
|
{
|
||||||
if(privData->object[i]->GetId() == pos->object_ID)
|
if(privData->object[i]->GetId() == pos->object_ID)
|
||||||
{
|
{
|
||||||
privData->object[i]->setPos(world);
|
privData->object[i]->setPos(world);
|
||||||
//camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2])));
|
|
||||||
//camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6])));
|
//privData->view = world;
|
||||||
//camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10])));
|
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
|
||||||
camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14]));
|
|
||||||
camera->UpdateViewMatrix();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +306,7 @@ void GameState::Protocol( NewObj* newObj )
|
||||||
|
|
||||||
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < privData->object.size(); i++)
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
{
|
{
|
||||||
if(privData->object[i]->GetId() == obj->object_ID)
|
if(privData->object[i]->GetId() == obj->object_ID)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue