Merge branch 'GameClient' of https://github.com/dean11/Danbias into GameClient
This commit is contained in:
commit
da94d7d827
|
@ -207,6 +207,7 @@
|
|||
<ClCompile Include="GameClientState\Camera_BasicV2.cpp" />
|
||||
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
|
||||
<ClCompile Include="GameClientState\Camera_FPSV2.cpp" />
|
||||
<ClCompile Include="GameClientState\C_Light.cpp" />
|
||||
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
||||
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
||||
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
|
||||
|
@ -214,12 +215,15 @@
|
|||
<ClCompile Include="DLLMain.cpp" />
|
||||
<ClCompile Include="GameClientState\GameClientState.cpp" />
|
||||
<ClCompile Include="GameClientState\GameState.cpp" />
|
||||
<ClCompile Include="GameClientState\GameStateUI.cpp" />
|
||||
<ClCompile Include="GameClientState\GamingUI.cpp" />
|
||||
<ClCompile Include="GameClientState\LanMenuState.cpp" />
|
||||
<ClCompile Include="GameClientState\LobbyAdminState.cpp" />
|
||||
<ClCompile Include="GameClientState\LobbyState.cpp" />
|
||||
<ClCompile Include="GameClientState\C_Object.cpp" />
|
||||
<ClCompile Include="GameClientState\MainState.cpp" />
|
||||
<ClCompile Include="GameClientState\NetLoadState.cpp" />
|
||||
<ClCompile Include="GameClientState\RespawnUI.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameClientState\Camera_Basic.h" />
|
||||
|
@ -230,16 +234,20 @@
|
|||
<ClInclude Include="GameClientState\Camera_BasicV2.h" />
|
||||
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
||||
<ClInclude Include="GameClientState\Camera_FPSV2.h" />
|
||||
<ClInclude Include="GameClientState\C_Light.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
|
||||
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
|
||||
<ClInclude Include="GameClientState\GameClientState.h" />
|
||||
<ClInclude Include="GameClientState\GameState.h" />
|
||||
<ClInclude Include="GameClientState\GameStateUI.h" />
|
||||
<ClInclude Include="GameClientState\GamingUI.h" />
|
||||
<ClInclude Include="GameClientState\LanMenuState.h" />
|
||||
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
||||
<ClInclude Include="GameClientState\MainState.h" />
|
||||
<ClInclude Include="GameClientState\NetLoadState.h" />
|
||||
<ClInclude Include="GameClientState\RespawnUI.h" />
|
||||
<ClInclude Include="GameClientState\SharedStateContent.h" />
|
||||
<ClInclude Include="Include\GameClient.h" />
|
||||
<ClInclude Include="GameClientState\LobbyState.h" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include "C_Light.h"
|
||||
using namespace DanBias::Client;
|
||||
C_Light::C_Light( Oyster::Graphics::Definitions::Pointlight pointLightDesc, int id )
|
||||
{
|
||||
this->pointLightDesc = pointLightDesc;
|
||||
this->id = id;
|
||||
}
|
||||
C_Light::~C_Light()
|
||||
{
|
||||
|
||||
}
|
||||
Oyster::Graphics::Definitions::Pointlight C_Light::getLightDesc() const
|
||||
{
|
||||
return this->pointLightDesc;
|
||||
}
|
||||
void C_Light::setLightDesc( Oyster::Graphics::Definitions::Pointlight pointLightDesc )
|
||||
{
|
||||
this->pointLightDesc = pointLightDesc;
|
||||
}
|
||||
Oyster::Math::Float3 C_Light::getPos() const
|
||||
{
|
||||
return this->pointLightDesc.Pos;
|
||||
}
|
||||
void C_Light::setPos( Oyster::Math::Float3 newPos)
|
||||
{
|
||||
this->pointLightDesc.Pos = newPos;
|
||||
}
|
||||
|
||||
int C_Light::GetId() const
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
void C_Light::Render()
|
||||
{
|
||||
// will be changed to new API
|
||||
Oyster::Graphics::API::AddLight(pointLightDesc);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef DANBIAS_CLIENT_CLIGHT_H
|
||||
#define DANBIAS_CLIENT_CLIGHT_H
|
||||
#include "DllInterfaces/GFXAPI.h"
|
||||
namespace DanBias
|
||||
{
|
||||
namespace Client
|
||||
{
|
||||
class C_Light
|
||||
{
|
||||
private:
|
||||
Oyster::Graphics::Definitions::Pointlight pointLightDesc;
|
||||
int id;
|
||||
|
||||
public:
|
||||
C_Light( Oyster::Graphics::Definitions::Pointlight pointLightDesc, int id );
|
||||
virtual ~C_Light();
|
||||
|
||||
Oyster::Graphics::Definitions::Pointlight getLightDesc() const;
|
||||
void setLightDesc( Oyster::Graphics::Definitions::Pointlight pointLightDesc );
|
||||
|
||||
Oyster::Math::Float3 getPos() const;
|
||||
void setPos( Oyster::Math::Float3 newPos);
|
||||
void Render();
|
||||
int GetId() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -9,6 +9,10 @@ C_Object::C_Object()
|
|||
|
||||
id = 0;
|
||||
model = NULL;
|
||||
|
||||
// RB DEBUG
|
||||
type = RB_Type_None;
|
||||
// !RB DEBUG
|
||||
}
|
||||
C_Object::~C_Object()
|
||||
{
|
||||
|
@ -31,32 +35,27 @@ void C_Object::updateWorld()
|
|||
{
|
||||
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
|
||||
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
|
||||
//Oyster::Math3D::Float4x4 scale = Oyster::Math3D::;
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Matrix::identity;
|
||||
scale.v[0].x = this->scale[0];
|
||||
scale.v[1].y = this->scale[1];
|
||||
scale.v[2].z = this->scale[2];
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale);
|
||||
world = translation * rot * scale;
|
||||
|
||||
model->WorldMatrix = world;
|
||||
}
|
||||
void C_Object::setWorld(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
model->WorldMatrix = world;
|
||||
}
|
||||
Oyster::Math::Float4x4 C_Object::getWorld() const
|
||||
{
|
||||
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
|
||||
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale);
|
||||
Oyster::Math3D::Float4x4 world = translation * rot * scale;
|
||||
|
||||
return world;
|
||||
}
|
||||
void C_Object::setPos(Oyster::Math::Float3 newPos)
|
||||
{
|
||||
this->position = newPos;
|
||||
updateWorld();
|
||||
}
|
||||
void C_Object::addPos(Oyster::Math::Float3 deltaPos)
|
||||
{
|
||||
this->position += deltaPos;
|
||||
updateWorld();
|
||||
}
|
||||
Oyster::Math::Float3 C_Object::getPos() const
|
||||
{
|
||||
|
@ -65,12 +64,6 @@ Oyster::Math::Float3 C_Object::getPos() const
|
|||
void C_Object::setRot(Oyster::Math::Quaternion newRot)
|
||||
{
|
||||
this->rotation = newRot;
|
||||
updateWorld();
|
||||
}
|
||||
void C_Object::addRot(Oyster::Math::Quaternion deltaRot)
|
||||
{
|
||||
this->rotation += deltaRot;
|
||||
updateWorld();
|
||||
}
|
||||
Oyster::Math::Quaternion C_Object::getRotation() const
|
||||
{
|
||||
|
@ -79,12 +72,10 @@ Oyster::Math::Quaternion C_Object::getRotation() const
|
|||
void C_Object::setScale(Oyster::Math::Float3 newScale)
|
||||
{
|
||||
this->scale = newScale;
|
||||
updateWorld();
|
||||
}
|
||||
void C_Object::addScale(Oyster::Math::Float3 deltaScale)
|
||||
{
|
||||
this->scale += deltaScale;
|
||||
updateWorld();
|
||||
}
|
||||
Oyster::Math::Float3 C_Object::getScale() const
|
||||
{
|
||||
|
@ -106,3 +97,55 @@ void C_Object::Release()
|
|||
this->model = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// RB DEBUG
|
||||
////////////////////////////////////////////////
|
||||
bool C_Object::InitRB(RBInitData RBInit)
|
||||
{
|
||||
RBposition = RBInit.position;
|
||||
RBrotation = RBInit.rotation;
|
||||
RBscale = RBInit.scale;
|
||||
type = RBInit.type;
|
||||
return true;
|
||||
}
|
||||
Oyster::Math::Float4x4 C_Object::getRBWorld() const
|
||||
{
|
||||
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->RBposition);
|
||||
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->RBrotation);
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->RBscale);
|
||||
Oyster::Math3D::Float4x4 world = translation * rot * scale;
|
||||
|
||||
return world;
|
||||
}
|
||||
void C_Object::setRBPos(Oyster::Math::Float3 newPos)
|
||||
{
|
||||
this->RBposition = newPos;
|
||||
}
|
||||
Oyster::Math::Float3 C_Object::getRBPos() const
|
||||
{
|
||||
return this->RBposition;
|
||||
}
|
||||
void C_Object::setRBRot(Oyster::Math::Quaternion newRot)
|
||||
{
|
||||
this->RBrotation = newRot;
|
||||
}
|
||||
Oyster::Math::Quaternion C_Object::getRBRotation() const
|
||||
{
|
||||
return this->RBrotation;
|
||||
}
|
||||
void C_Object::setRBScale(Oyster::Math::Float3 newScale)
|
||||
{
|
||||
this->RBscale = newScale;
|
||||
}
|
||||
Oyster::Math::Float3 C_Object::getRBScale() const
|
||||
{
|
||||
return this->RBscale;
|
||||
}
|
||||
RB_Type C_Object::getBRtype()const
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
// !RB DEBUG
|
|
@ -5,6 +5,21 @@ namespace DanBias
|
|||
{
|
||||
namespace Client
|
||||
{
|
||||
// RB DEBUG
|
||||
enum RB_Type
|
||||
{
|
||||
RB_Type_Cube,
|
||||
RB_Type_Sphere,
|
||||
RB_Type_None,
|
||||
};
|
||||
struct RBInitData
|
||||
{
|
||||
Oyster::Math::Float3 position;
|
||||
Oyster::Math::Quaternion rotation;
|
||||
Oyster::Math::Float3 scale;
|
||||
RB_Type type;
|
||||
};
|
||||
// !RB DEBUG
|
||||
|
||||
struct ModelInitData
|
||||
{
|
||||
|
@ -24,27 +39,45 @@ namespace DanBias
|
|||
Oyster::Math::Quaternion rotation;
|
||||
Oyster::Math::Float3 scale;
|
||||
|
||||
// RB DEBUG
|
||||
Oyster::Math::Float3 RBposition;
|
||||
Oyster::Math::Quaternion RBrotation;
|
||||
Oyster::Math::Float3 RBscale;
|
||||
RB_Type type;
|
||||
// !RB DEBUG
|
||||
|
||||
int id;
|
||||
void updateWorld();
|
||||
|
||||
protected:
|
||||
Oyster::Graphics::Model::Model *model;
|
||||
public:
|
||||
C_Object();
|
||||
virtual ~C_Object();
|
||||
virtual bool Init(ModelInitData modelInit);
|
||||
|
||||
void setWorld(Oyster::Math::Float4x4 world);
|
||||
void updateWorld();
|
||||
//void setWorld(Oyster::Math::Float4x4 world);
|
||||
Oyster::Math::Float4x4 getWorld() const;
|
||||
void setPos(Oyster::Math::Float3 newPos);
|
||||
Oyster::Math::Float3 getPos() const;
|
||||
void addPos(Oyster::Math::Float3 deltaPos);
|
||||
void setRot(Oyster::Math::Quaternion newRot);
|
||||
Oyster::Math::Quaternion getRotation() const;
|
||||
void addRot(Oyster::Math::Quaternion deltaRot);
|
||||
void setScale(Oyster::Math::Float3 newScale);
|
||||
void addScale(Oyster::Math::Float3 deltaScale);
|
||||
Oyster::Math::Float3 getScale() const;
|
||||
|
||||
// RB DEBUG
|
||||
bool InitRB(RBInitData modelInit);
|
||||
Oyster::Math::Float4x4 getRBWorld() const;
|
||||
void setRBPos(Oyster::Math::Float3 newPos);
|
||||
Oyster::Math::Float3 getRBPos() const;
|
||||
void setRBRot(Oyster::Math::Quaternion newRot);
|
||||
Oyster::Math::Quaternion getRBRotation() const;
|
||||
void setRBScale(Oyster::Math::Float3 newScale);
|
||||
Oyster::Math::Float3 getRBScale() const;
|
||||
RB_Type getBRtype()const;
|
||||
// !RB DEBUG
|
||||
|
||||
virtual void Render();
|
||||
virtual void Release();
|
||||
virtual int GetId() const;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace DanBias { namespace Client
|
|||
|
||||
/******************************************************************
|
||||
* @param message of the event
|
||||
* @return message or GameClientState::event_processed.
|
||||
* @return message or a reference to GameClientState::event_processed.
|
||||
******************************************************************/
|
||||
virtual const NetEvent & DataRecieved( const NetEvent &message );
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "NetworkClient.h"
|
||||
#include "Camera_FPSV2.h"
|
||||
#include <GameServerAPI.h>
|
||||
|
||||
#include "C_Light.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
#include "C_obj/C_StaticObj.h"
|
||||
|
@ -28,6 +28,7 @@ struct GameState::MyData
|
|||
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
|
||||
|
||||
bool key_forward;
|
||||
bool key_backward;
|
||||
|
@ -36,7 +37,11 @@ struct GameState::MyData
|
|||
bool key_Shoot;
|
||||
bool key_Jump;
|
||||
|
||||
// DEGUG KEYS
|
||||
bool key_Reload_Shaders;
|
||||
bool key_Wireframe_Toggle;
|
||||
bool renderWhireframe;
|
||||
// !DEGUG KEYS
|
||||
|
||||
C_Player player;
|
||||
Camera_FPSV2 camera;
|
||||
|
@ -78,15 +83,28 @@ bool GameState::Init( SharedStateContent &shared )
|
|||
this->privData->input = shared.input;
|
||||
this->privData->staticObjects = &shared.staticObjects;
|
||||
this->privData->dynamicObjects = &shared.dynamicObjects;
|
||||
this->privData->lights = &shared.lights;
|
||||
|
||||
Graphics::API::Option gfxOp = Graphics::API::GetOption();
|
||||
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
|
||||
this->privData->camera.SetPerspectiveProjection( 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() );
|
||||
|
||||
//tell server ready
|
||||
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
|
||||
|
||||
// DEGUG KEYS
|
||||
this->privData->key_Reload_Shaders = false;
|
||||
this->privData->key_Wireframe_Toggle = false;
|
||||
this->privData->renderWhireframe = false;
|
||||
// !DEGUG KEYS
|
||||
|
||||
auto light = this->privData->lights->begin();
|
||||
for( ; light != this->privData->lights->end(); ++light )
|
||||
{
|
||||
light->second->Render();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -100,10 +118,20 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
|||
StringToWstring( modelName, modelData.modelPath );
|
||||
modelData.id = id;
|
||||
|
||||
// RB DEBUG
|
||||
RBInitData RBData;
|
||||
RBData.position = position;
|
||||
RBData.rotation = ArrayToQuaternion( rotation );
|
||||
RBData.scale = scale;
|
||||
// !RB DEBUG
|
||||
if( isMyPlayer )
|
||||
{
|
||||
if( this->privData->player.Init(modelData) )
|
||||
{
|
||||
// RB DEBUG
|
||||
this->privData->player.InitRB( RBData );
|
||||
// !RB DEBUG
|
||||
|
||||
this->privData->myId = id;
|
||||
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
||||
Float3 offset = Float3( 0.0f );
|
||||
|
@ -117,6 +145,10 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
|||
C_DynamicObj *p = new C_DynamicObj();
|
||||
if( p->Init(modelData) )
|
||||
{
|
||||
// RB DEBUG
|
||||
this->privData->player.InitRB( RBData );
|
||||
// !RB DEBUG
|
||||
|
||||
(*this->privData->dynamicObjects)[id] = p;
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +182,55 @@ bool GameState::Render()
|
|||
dynamicObject->second->Render();
|
||||
}
|
||||
|
||||
|
||||
/*auto light = this->privData->lights->begin();
|
||||
for( ; light != this->privData->lights->end(); ++light )
|
||||
{
|
||||
light->second->Render();
|
||||
}*/
|
||||
|
||||
// RB DEBUG render wire frame
|
||||
if(this->privData->renderWhireframe)
|
||||
{
|
||||
Oyster::Graphics::API::StartRenderWireFrame();
|
||||
|
||||
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
|
||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
|
||||
Oyster::Math3D::Float4x4 world = translation * scale;
|
||||
Oyster::Graphics::API::RenderDebugCube( world );
|
||||
Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
|
||||
|
||||
staticObject = this->privData->staticObjects->begin();
|
||||
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||
{
|
||||
if( staticObject->second->getBRtype() == RB_Type_Cube)
|
||||
{
|
||||
Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld());
|
||||
}
|
||||
if( staticObject->second->getBRtype() == RB_Type_Sphere)
|
||||
{
|
||||
Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld());
|
||||
}
|
||||
}
|
||||
|
||||
dynamicObject = this->privData->dynamicObjects->begin();
|
||||
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
||||
{
|
||||
if( dynamicObject->second )
|
||||
{
|
||||
if( dynamicObject->second->getBRtype() == RB_Type_Cube)
|
||||
{
|
||||
Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld());
|
||||
}
|
||||
if( dynamicObject->second->getBRtype() == RB_Type_Sphere)
|
||||
{
|
||||
Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// !RB DEBUG
|
||||
|
||||
Oyster::Graphics::API::EndFrame();
|
||||
return true;
|
||||
}
|
||||
|
@ -170,8 +251,15 @@ bool GameState::Release()
|
|||
dynamicObject->second = nullptr;
|
||||
}
|
||||
|
||||
auto light = this->privData->lights->begin();
|
||||
for( ; light != this->privData->lights->end(); ++light )
|
||||
{
|
||||
light->second->Render();
|
||||
}
|
||||
|
||||
this->privData->staticObjects->clear();
|
||||
this->privData->dynamicObjects->clear();
|
||||
this->privData->lights->clear();
|
||||
|
||||
privData = NULL;
|
||||
}
|
||||
|
@ -229,28 +317,11 @@ void GameState::ReadKeyInput()
|
|||
else
|
||||
this->privData->key_strafeRight = false;
|
||||
|
||||
if( this->privData->input->IsKeyPressed(DIK_R) )
|
||||
{
|
||||
if( !this->privData->key_Reload_Shaders )
|
||||
{
|
||||
//this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
||||
#ifdef _DEBUG
|
||||
Graphics::API::ReloadShaders();
|
||||
#endif
|
||||
this->privData->key_Reload_Shaders = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->privData->key_Reload_Shaders = false;
|
||||
|
||||
|
||||
//send delta mouse movement
|
||||
{
|
||||
this->privData->camera.YawRight( this->privData->input->GetYaw() * 0.017f );
|
||||
this->privData->camera.PitchDown( this->privData->input->GetPitch() * 0.017f );
|
||||
this->privData->camera.UpdateOrientation();
|
||||
|
||||
privData->nwClient->Send( Protocol_PlayerLook(this->privData->camera.GetLook(), this->privData->camera.GetRight()) );
|
||||
static const float mouseSensitivity = Radian( 1.0f );
|
||||
this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity );
|
||||
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(this->privData->input->GetYaw() * mouseSensitivity) );
|
||||
}
|
||||
|
||||
// shoot
|
||||
|
@ -309,6 +380,35 @@ void GameState::ReadKeyInput()
|
|||
else
|
||||
this->privData->key_Jump = false;
|
||||
|
||||
|
||||
// DEGUG KEYS
|
||||
|
||||
// Reload shaders
|
||||
if( this->privData->input->IsKeyPressed(DIK_R) )
|
||||
{
|
||||
if( !this->privData->key_Reload_Shaders )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
Graphics::API::ReloadShaders();
|
||||
#endif
|
||||
this->privData->key_Reload_Shaders = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->privData->key_Reload_Shaders = false;
|
||||
|
||||
// toggle wire frame render
|
||||
if( this->privData->input->IsKeyPressed(DIK_T) )
|
||||
{
|
||||
if( !this->privData->key_Wireframe_Toggle )
|
||||
{
|
||||
this->privData->renderWhireframe = !this->privData->renderWhireframe;
|
||||
this->privData->key_Wireframe_Toggle = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
this->privData->key_Wireframe_Toggle = false;
|
||||
// !DEGUG KEYS
|
||||
// TODO: implement sub-menu
|
||||
}
|
||||
|
||||
|
@ -342,12 +442,18 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
this->privData->camera.SetPosition( decoded.position );
|
||||
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
|
||||
// RB DEBUG
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBPos ( decoded.position );
|
||||
// !RB DEBUG
|
||||
}
|
||||
return GameClientState::event_processed;
|
||||
case protocol_Gameplay_ObjectScale:
|
||||
{
|
||||
Protocol_ObjectScale decoded(data);
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
|
||||
// RB DEBUG
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBScale ( decoded.scale );
|
||||
// !RB DEBUG
|
||||
}
|
||||
return GameClientState::event_processed;
|
||||
case protocol_Gameplay_ObjectRotation:
|
||||
|
@ -360,6 +466,9 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
this->privData->camera.SetRotation( rotation );
|
||||
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
||||
// RB DEBUG
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID]->setRBRot ( rotation );
|
||||
// !RB DEBUG
|
||||
}
|
||||
return GameClientState::event_processed;
|
||||
case protocol_Gameplay_ObjectPositionRotation:
|
||||
|
@ -372,16 +481,21 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
if( this->privData->myId == decoded.object_ID )
|
||||
{
|
||||
this->privData->camera.SetPosition( position );
|
||||
//this->privData->camera.SetRotation( rotation );
|
||||
this->privData->camera.SetRotation( rotation );
|
||||
this->privData->player.setPos( position );
|
||||
//this->privData->player.setRot( rotation );
|
||||
this->privData->player.setRot( rotation );
|
||||
}
|
||||
|
||||
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||
|
||||
if( object )
|
||||
{
|
||||
object->setPos( position );
|
||||
object->setRot( rotation );
|
||||
// RB DEBUG
|
||||
object->setRBPos ( position );
|
||||
object->setRBRot ( rotation );
|
||||
// !RB DEBUG
|
||||
}
|
||||
}
|
||||
return GameClientState::event_processed;
|
||||
|
@ -406,7 +520,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
ModelInitData modelData;
|
||||
{
|
||||
modelData.position = Float3( decoded.position );
|
||||
modelData.rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||
modelData.rotation = Quaternion( Float3(decoded.position), decoded.rotationQ[3] );
|
||||
modelData.scale = Float3( decoded.scale );
|
||||
modelData.visible = true;
|
||||
modelData.id = decoded.object_ID;
|
||||
|
@ -414,6 +528,15 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
|||
::Utility::String::StringToWstring( decoded.name, modelData.modelPath );
|
||||
}
|
||||
object->Init(modelData);
|
||||
// RB DEBUG
|
||||
// Is just using the model position since the rigid body data should never be sent to the client
|
||||
RBInitData RBData;
|
||||
RBData.position = decoded.position;
|
||||
RBData.rotation = ArrayToQuaternion( decoded.position );
|
||||
RBData.scale = Float3( decoded.scale );
|
||||
|
||||
this->privData->player.InitRB( RBData );
|
||||
// !RB DEBUG
|
||||
|
||||
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#include "GameStateUI.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster::Network;
|
||||
|
||||
GameStateUI::GameStateUI()
|
||||
{
|
||||
this->nextState = GameStateUI::UIState_same;
|
||||
}
|
||||
|
||||
GameStateUI::~GameStateUI() { /* Do nothing */ }
|
||||
|
||||
const GameStateUI::NetEvent & GameStateUI::DataRecieved( const GameStateUI::NetEvent &message )
|
||||
{
|
||||
/* Do nothing */
|
||||
return message;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||
|
||||
#include "Utilities.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
namespace DanBias { namespace Client
|
||||
{
|
||||
class GameStateUI
|
||||
{
|
||||
public:
|
||||
enum UIState
|
||||
{
|
||||
UIState_same,
|
||||
UIState_gaming,
|
||||
|
||||
|
||||
UIState_main_menu,
|
||||
UIState_shut_down
|
||||
};
|
||||
|
||||
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
|
||||
static const NetEvent event_processed;
|
||||
|
||||
GameStateUI();
|
||||
virtual ~GameStateUI();
|
||||
virtual UIState Update( float deltaTime ) = 0;
|
||||
virtual bool HaveGUIRender() const = 0;
|
||||
virtual bool HaveTextRender() const = 0;
|
||||
virtual void RenderGUI() const = 0;
|
||||
virtual void RenderText() const = 0;
|
||||
virtual bool Release() = 0;
|
||||
|
||||
/******************************************************************
|
||||
* @param message of the event
|
||||
* @return message or a reference to GameStateUI::event_processed.
|
||||
******************************************************************/
|
||||
virtual const NetEvent & DataRecieved( const NetEvent &message );
|
||||
|
||||
protected:
|
||||
UIState nextState;
|
||||
};
|
||||
} }
|
||||
|
||||
namespace Utility { namespace DynamicMemory
|
||||
{ // template specializationto allowuse of dynamicmemory tools
|
||||
template<>
|
||||
inline void SafeDeleteInstance( ::DanBias::Client::GameStateUI *dynamicInstance )
|
||||
{
|
||||
if( dynamicInstance )
|
||||
{
|
||||
dynamicInstance->Release();
|
||||
delete dynamicInstance;
|
||||
}
|
||||
}
|
||||
} }
|
||||
|
||||
#endif
|
|
@ -0,0 +1,153 @@
|
|||
#include "GamingUI.h"
|
||||
#include <Protocols.h>
|
||||
#include "Utilities.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster::Network;
|
||||
using namespace ::GameLogic;
|
||||
using namespace ::Utility::Value;
|
||||
|
||||
GamingUI::GamingUI() :
|
||||
GameStateUI()
|
||||
{
|
||||
/* Should never be called! */
|
||||
this->input = nullptr;
|
||||
this->netClient = nullptr;
|
||||
this->camera = nullptr;
|
||||
}
|
||||
|
||||
GamingUI::GamingUI( InputClass *input, NetworkClient *connection, Camera_FPSV2 *camera ) :
|
||||
GameStateUI()
|
||||
{
|
||||
this->input = input;
|
||||
this->netClient = connection;
|
||||
this->camera = camera;
|
||||
}
|
||||
|
||||
GamingUI::~GamingUI() { /* Do nothing */ }
|
||||
|
||||
GameStateUI::UIState GamingUI::Update( float deltaTime )
|
||||
{
|
||||
return this->nextState;
|
||||
}
|
||||
|
||||
bool GamingUI::HaveGUIRender() const
|
||||
{
|
||||
return false; // TODO: change to true when we want UI elements like a crosshair
|
||||
}
|
||||
|
||||
bool GamingUI::HaveTextRender() const
|
||||
{
|
||||
return false; // TODO: change to true when we want UI elements like a chat window
|
||||
}
|
||||
|
||||
void GamingUI::RenderGUI() const
|
||||
{
|
||||
// TODO: Render crosshairs and such here. Don't forget to adjust GamingUI::HaveGUIRender
|
||||
}
|
||||
|
||||
void GamingUI::RenderText() const
|
||||
{
|
||||
// TODO: Render chattext and such here. Don't forget to adjust GamingUI::HaveGUIRender
|
||||
}
|
||||
|
||||
bool GamingUI::Release()
|
||||
{
|
||||
// TODO: Release UI components here.
|
||||
return true;
|
||||
}
|
||||
|
||||
void GamingUI::ReadKeyInput()
|
||||
{
|
||||
if( this->input->IsKeyPressed(DIK_W) )
|
||||
{
|
||||
this->netClient->Send( Protocol_PlayerMovementForward() );
|
||||
}
|
||||
|
||||
if( this->input->IsKeyPressed(DIK_S) )
|
||||
{
|
||||
this->netClient->Send( Protocol_PlayerMovementBackward() );
|
||||
}
|
||||
|
||||
if( this->input->IsKeyPressed(DIK_A) )
|
||||
{
|
||||
this->netClient->Send( Protocol_PlayerMovementLeft() );
|
||||
}
|
||||
|
||||
if( this->input->IsKeyPressed(DIK_D) )
|
||||
{
|
||||
this->netClient->Send( Protocol_PlayerMovementRight() );
|
||||
}
|
||||
|
||||
// if( this->input->IsKeyPressed(DIK_R) )
|
||||
// {
|
||||
// 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 );
|
||||
this->camera->PitchDown( this->input->GetPitch() * mouseSensitivity );
|
||||
this->netClient->Send( Protocol_PlayerLeftTurn(this->input->GetYaw() * mouseSensitivity) );
|
||||
}
|
||||
|
||||
// shoot
|
||||
//if( this->input->IsKeyPressed(DIK_Z) )
|
||||
//{
|
||||
// if( !this->key_Shoot )
|
||||
// {
|
||||
// Protocol_PlayerShot playerShot;
|
||||
// playerShot.primaryPressed = true;
|
||||
// playerShot.secondaryPressed = false;
|
||||
// playerShot.utilityPressed = false;
|
||||
// this->netClient->Send( playerShot );
|
||||
// this->key_Shoot = true;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// this->key_Shoot = false;
|
||||
|
||||
//if( this->input->IsKeyPressed(DIK_X) )
|
||||
//{
|
||||
// if( !this->key_Shoot )
|
||||
// {
|
||||
// Protocol_PlayerShot playerShot;
|
||||
// playerShot.primaryPressed = false;
|
||||
// playerShot.secondaryPressed = true;
|
||||
// playerShot.utilityPressed = false;
|
||||
// this->netClient->Send( playerShot );
|
||||
// this->key_Shoot = true;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// this->key_Shoot = false;
|
||||
|
||||
//if( this->input->IsKeyPressed(DIK_C) )
|
||||
//{
|
||||
// if( !this->key_Shoot )
|
||||
// {
|
||||
// Protocol_PlayerShot playerShot;
|
||||
// playerShot.primaryPressed = false;
|
||||
// playerShot.secondaryPressed = false;
|
||||
// playerShot.utilityPressed = true;
|
||||
// this->netClient->Send( playerShot );
|
||||
// this->key_Shoot = true;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
// this->key_Shoot = false;
|
||||
|
||||
// jump
|
||||
if( this->input->IsKeyPressed(DIK_SPACE) )
|
||||
{
|
||||
this->netClient->Send( Protocol_PlayerJump() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef DANBIAS_CLIENT_GAMING_UI_H
|
||||
#define DANBIAS_CLIENT_GAMING_UI_H
|
||||
|
||||
#include "GameStateUI.h"
|
||||
#include "L_inputClass.h"
|
||||
#include "Camera_FPSV2.h"
|
||||
|
||||
namespace DanBias { namespace Client
|
||||
{
|
||||
class GamingUI : public GameStateUI
|
||||
{
|
||||
public:
|
||||
GamingUI( InputClass *input, ::Oyster::Network::NetworkClient *connection, Camera_FPSV2 *camera );
|
||||
virtual ~GamingUI();
|
||||
|
||||
UIState Update( float deltaTime );
|
||||
bool HaveGUIRender() const;
|
||||
bool HaveTextRender() const;
|
||||
void RenderGUI() const;
|
||||
void RenderText() const;
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
InputClass *input;
|
||||
::Oyster::Network::NetworkClient *netClient;
|
||||
Camera_FPSV2 *camera;
|
||||
|
||||
GamingUI();
|
||||
void ReadKeyInput();
|
||||
};
|
||||
} }
|
||||
|
||||
#endif
|
|
@ -6,6 +6,7 @@
|
|||
#include "Utilities.h"
|
||||
#include "C_obj\C_StaticObj.h"
|
||||
#include "C_obj\C_DynamicObj.h"
|
||||
#include "C_Light.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster;
|
||||
|
@ -23,6 +24,7 @@ struct NetLoadState::MyData
|
|||
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;
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
|
||||
|
||||
bool loading;
|
||||
};
|
||||
|
@ -49,6 +51,7 @@ bool NetLoadState::Init( SharedStateContent &shared )
|
|||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||
this->privData->dynamicObjects = &shared.dynamicObjects;
|
||||
this->privData->staticObjects = &shared.staticObjects;
|
||||
this->privData->lights = &shared.lights;
|
||||
|
||||
this->privData->loading = false;
|
||||
|
||||
|
@ -141,17 +144,31 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
|||
desc.scale = oh->scale;
|
||||
desc.visible = true;
|
||||
|
||||
// HACK: untill the world is right in lvl format
|
||||
if( oh->specialTypeID == ObjectSpecialType_World)
|
||||
{
|
||||
desc.position = Float3(0,0,0);
|
||||
desc.rotation = Quaternion::identity;
|
||||
desc.scale = Float3(300,300,300);
|
||||
}
|
||||
|
||||
C_StaticObj *staticObject = new C_StaticObj();
|
||||
if( staticObject->Init( desc ) )
|
||||
{
|
||||
|
||||
// RB DEBUG
|
||||
RBInitData RBData;
|
||||
if(oh->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||
{
|
||||
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
|
||||
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
|
||||
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
|
||||
RBData.type = RB_Type_Cube;
|
||||
staticObject->InitRB( RBData );
|
||||
}
|
||||
|
||||
if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
{
|
||||
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
|
||||
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
|
||||
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
|
||||
RBData.type = RB_Type_Sphere;
|
||||
staticObject->InitRB( RBData );
|
||||
}
|
||||
// !RB DEBUG
|
||||
|
||||
(*this->privData->staticObjects)[objectID] = staticObject;
|
||||
}
|
||||
else
|
||||
|
@ -175,6 +192,27 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
|||
C_DynamicObj *dynamicObject = new C_DynamicObj();
|
||||
if( dynamicObject->Init( desc ) )
|
||||
{
|
||||
// RB DEBUG
|
||||
RBInitData RBData;
|
||||
if(oh->boundingVolume.geoType == CollisionGeometryType_Box)
|
||||
{
|
||||
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
|
||||
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
|
||||
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
|
||||
RBData.type = RB_Type_Cube;
|
||||
dynamicObject->InitRB( RBData );
|
||||
}
|
||||
|
||||
if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
{
|
||||
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
|
||||
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
|
||||
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
|
||||
RBData.type = RB_Type_Sphere;
|
||||
dynamicObject->InitRB( RBData );
|
||||
}
|
||||
// !RB DEBUG
|
||||
|
||||
(*this->privData->dynamicObjects)[objectID] = dynamicObject;
|
||||
}
|
||||
else
|
||||
|
@ -185,7 +223,17 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
|||
break;
|
||||
case ObjectType::ObjectType_Light:
|
||||
{
|
||||
/* TODO: implement light into the leveformat */
|
||||
BasicLight *light = (BasicLight*)oth;
|
||||
Graphics::Definitions::Pointlight pointLight;
|
||||
|
||||
pointLight.Color = light->color;
|
||||
pointLight.Pos = light->position;
|
||||
pointLight.Bright = light->intensity;
|
||||
pointLight.Radius = light->raduis;
|
||||
|
||||
C_Light *newLight = new C_Light( pointLight, objectID );
|
||||
|
||||
(*this->privData->lights)[objectID] = newLight;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
#include "RespawnUI.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster::Network;
|
||||
using namespace ::Utility::Value;
|
||||
|
||||
RespawnUI::RespawnUI() :
|
||||
GameStateUI()
|
||||
{
|
||||
/* Should never be called! */
|
||||
this->netClient = nullptr;
|
||||
this->countDown = 0.0f;
|
||||
}
|
||||
|
||||
RespawnUI::RespawnUI( NetworkClient *connection, float delay ) :
|
||||
GameStateUI()
|
||||
{
|
||||
this->netClient = connection;
|
||||
this->countDown = delay;
|
||||
}
|
||||
|
||||
RespawnUI::~RespawnUI() { /* Do nothing */ }
|
||||
|
||||
GameStateUI::UIState RespawnUI::Update( float deltaTime )
|
||||
{
|
||||
this->countDown = Max( this->countDown - deltaTime, 0.0f );
|
||||
return this->nextState;
|
||||
}
|
||||
|
||||
bool RespawnUI::HaveGUIRender() const
|
||||
{
|
||||
return false; // TODO: change to true when we want UI elements like a crosshair
|
||||
}
|
||||
|
||||
bool RespawnUI::HaveTextRender() const
|
||||
{
|
||||
return false; // TODO: change to true when we want UI elements like a chat window
|
||||
}
|
||||
|
||||
void RespawnUI::RenderGUI() const
|
||||
{
|
||||
// TODO: We need?
|
||||
}
|
||||
|
||||
void RespawnUI::RenderText() const
|
||||
{
|
||||
// TODO: Text countdown somewhere on screen would be nice
|
||||
}
|
||||
|
||||
bool RespawnUI::Release()
|
||||
{
|
||||
// TODO: Release UI components here.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef DANBIAS_CLIENT_RESPAWN_UI_H
|
||||
#define DANBIAS_CLIENT_RESPAWN_UI_H
|
||||
|
||||
#include "GameStateUI.h"
|
||||
|
||||
namespace DanBias { namespace Client
|
||||
{
|
||||
class RespawnUI : public GameStateUI
|
||||
{
|
||||
public:
|
||||
RespawnUI( ::Oyster::Network::NetworkClient *connection, float delay );
|
||||
virtual ~RespawnUI();
|
||||
|
||||
UIState Update( float deltaTime );
|
||||
bool HaveGUIRender() const;
|
||||
bool HaveTextRender() const;
|
||||
void RenderGUI() const;
|
||||
void RenderText() const;
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
::Oyster::Network::NetworkClient *netClient;
|
||||
float countDown;
|
||||
|
||||
RespawnUI();
|
||||
};
|
||||
} }
|
||||
|
||||
#endif
|
|
@ -13,6 +13,7 @@
|
|||
#include "C_Object.h"
|
||||
#include "C_obj\C_StaticObj.h"
|
||||
#include "C_obj\C_DynamicObj.h"
|
||||
#include "C_Light.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "L_inputClass.h"
|
||||
|
||||
|
@ -23,6 +24,7 @@ namespace DanBias { namespace Client
|
|||
public:
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> staticObjects;
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> dynamicObjects;
|
||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> lights;
|
||||
::Oyster::Network::NetworkClient *network;
|
||||
InputClass* input;
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ using namespace GameLogic;
|
|||
break;
|
||||
|
||||
case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
|
||||
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision());
|
||||
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->GetExtraDamageOnCollision());
|
||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||
break;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ using namespace GameLogic;
|
|||
}
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
|
|
|
@ -68,12 +68,33 @@ void Game::GetAllPlayerPositions() const
|
|||
Game::PlayerData* Game::CreatePlayer()
|
||||
{
|
||||
// Find a free space in array or insert at end
|
||||
int i = InsertObject(this->players, (PlayerData*)0);
|
||||
int insert = InsertObject(this->players, (PlayerData*)0);
|
||||
int freeID = 0;
|
||||
bool found = false;
|
||||
|
||||
this->players[i] = new PlayerData();
|
||||
this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
found = true;
|
||||
freeID = i;
|
||||
|
||||
return this->players[i];
|
||||
for(int j = 0; j < players.Size(); j++)
|
||||
{
|
||||
|
||||
if(this->players[j] && this->players[j]->GetID() == freeID)
|
||||
{
|
||||
found = false;
|
||||
}
|
||||
|
||||
if(!found) break;
|
||||
}
|
||||
|
||||
if(found) break;
|
||||
}
|
||||
|
||||
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
|
||||
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||
|
||||
return this->players[insert];
|
||||
}
|
||||
|
||||
Game::LevelData* Game::CreateLevel(const wchar_t mapName[255])
|
||||
|
@ -95,21 +116,16 @@ bool Game::NewFrame()
|
|||
{
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||
if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||
}
|
||||
|
||||
API::Instance().UpdateWorld();
|
||||
|
||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||
{
|
||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||
gameInstance.onMoveFnc(this->players[i]);
|
||||
this->onMoveFnc(this->players[i]);
|
||||
if(this->players[i] && this->players[i]->player) this->players[i]->player->EndFrame();
|
||||
}
|
||||
for (unsigned int i = 0; i < this->level->level->dynamicObjects.Size(); i++)
|
||||
{
|
||||
gameInstance.onMoveFnc(this->level->level->dynamicObjects[i]);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ namespace GameLogic
|
|||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
int GetID() const override;
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override;
|
||||
void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right) override;
|
||||
void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
|
||||
ObjectSpecialType GetObjectType() const override;
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,12 @@ namespace GameLogic
|
|||
* @param x: The relative x axis
|
||||
* @param y: The relative y axis
|
||||
**/
|
||||
virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0;
|
||||
virtual void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right) = 0;
|
||||
|
||||
/** Relative rotation around given axis
|
||||
* @param leftRadians: The relative amount of radians to turn
|
||||
**/
|
||||
virtual void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Uses the chosen players weapon based on input
|
||||
|
|
|
@ -21,13 +21,23 @@ Game::PlayerData::PlayerData()
|
|||
rigidBody->SetAngularFactor(0.0f);
|
||||
//create player with this rigid body
|
||||
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
||||
|
||||
//this->player->GetRigidBody()->SetCustomTag(this);
|
||||
player->EndFrame();
|
||||
}
|
||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||
{
|
||||
this->player = new Player();
|
||||
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0);
|
||||
|
||||
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||
Oyster::Math::Float mass = 60;
|
||||
Oyster::Math::Float restitutionCoeff = 0.5f;
|
||||
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
||||
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
||||
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||
|
||||
//create rigid body
|
||||
Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f );
|
||||
rigidBody->SetAngularFactor(0.0f);
|
||||
//create player with this rigid body
|
||||
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID);
|
||||
}
|
||||
Game::PlayerData::~PlayerData()
|
||||
{
|
||||
|
@ -75,7 +85,11 @@ ObjectSpecialType Game::PlayerData::GetObjectType() const
|
|||
{
|
||||
return this->player->GetObjectType();
|
||||
}
|
||||
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right)
|
||||
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right)
|
||||
{
|
||||
this->player->Rotate(lookDir, right);
|
||||
}
|
||||
void Game::PlayerData::TurnLeft(Oyster::Math3D::Float deltaLeftRadians )
|
||||
{
|
||||
this->player->TurnLeft(deltaLeftRadians);
|
||||
}
|
|
@ -30,14 +30,14 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
{
|
||||
case ObjectSpecialType_None:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Sky:
|
||||
{
|
||||
float skySize = ((SkyAttributes*)obj)->skySize;
|
||||
//gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
//gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_World:
|
||||
|
@ -48,21 +48,21 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
float worldSize = ((WorldAttributes*)obj)->worldSize;
|
||||
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize;
|
||||
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Building:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
case ObjectSpecialType_Stone:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_StandardBox:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_RedExplosiveBox:
|
||||
|
@ -79,24 +79,24 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
// break;
|
||||
case ObjectSpecialType_SpikeBox:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_Spike:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_CrystalFormation:
|
||||
{
|
||||
int dmg = 50;
|
||||
//gameObj = new Crystal(rigidBody);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_CrystalShard:
|
||||
{
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
case ObjectSpecialType_JumpPad:
|
||||
|
@ -126,12 +126,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
|||
break;
|
||||
case ObjectSpecialType_Generic:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -242,34 +242,8 @@ bool Level::InitiateLevel(std::wstring levelPath)
|
|||
|
||||
ICustomBody* rigidBody_Static = NULL;
|
||||
|
||||
// HACK: untill the world is right in lvl format
|
||||
if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_World)
|
||||
{
|
||||
Oyster::Math::Float3 rigidWorldPos;
|
||||
Oyster::Math::Float4 rigidWorldRotation;
|
||||
float rigidBodyMass;
|
||||
float rigidBodyRadius;
|
||||
|
||||
//offset the rigidPosition from modelspace to worldspace;
|
||||
rigidWorldPos = Oyster::Math::Float3(0,0,0);
|
||||
//scales the position so the collision geomentry is in the right place
|
||||
|
||||
//offset the rigidRotation from modelspace to worldspace;
|
||||
|
||||
rigidWorldRotation = Oyster::Math::Float4(0,0,0,1);
|
||||
|
||||
//mass scaled
|
||||
rigidBodyMass = 0;
|
||||
|
||||
//Radius scaled
|
||||
rigidBodyRadius = 150;
|
||||
|
||||
//create the rigid body
|
||||
rigidBody_Static = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, 1,1,1);
|
||||
|
||||
}
|
||||
// collision shape
|
||||
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
|
||||
{
|
||||
rigidBody_Static = InitRigidBodySphere(staticObjData);
|
||||
}
|
||||
|
@ -368,14 +342,14 @@ bool Level::InitiateLevel(float radius)
|
|||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||
}
|
||||
/*offset += nrOfBoxex;
|
||||
for(int i =0; i< nrOfBoxex; i ++)
|
||||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
||||
|
||||
}
|
||||
|
@ -384,7 +358,7 @@ bool Level::InitiateLevel(float radius)
|
|||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(200, 620 + ( i*7), 0), 5);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
|
||||
}
|
||||
offset += nrOfBoxex;
|
||||
|
@ -392,18 +366,18 @@ bool Level::InitiateLevel(float radius)
|
|||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(5, 605 + i*5, 0), 5);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultOnCollision, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
||||
|
||||
}*/
|
||||
|
||||
// add crystal
|
||||
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||
|
||||
// add house
|
||||
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f);
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++));
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
|
||||
|
||||
// add jumppad
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
|
|||
|
||||
Object::Object()
|
||||
{
|
||||
|
||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->type = ObjectSpecialType_Unknown;
|
||||
this->objectID = -1;
|
||||
this->scale = Float3(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID)
|
||||
|
@ -48,39 +48,12 @@ Object::~Object(void)
|
|||
|
||||
}
|
||||
|
||||
ObjectSpecialType Object::GetObjectType() const
|
||||
|
||||
void Object::SetOnCollision(OnCollisionCallback func)
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
int Object::GetID() const
|
||||
{
|
||||
return this->objectID;
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody* Object::GetRigidBody()
|
||||
{
|
||||
return this->rigidBody;
|
||||
}
|
||||
|
||||
|
||||
void Object::BeginFrame()
|
||||
{
|
||||
|
||||
}
|
||||
// update physic
|
||||
void Object::EndFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
|
||||
{
|
||||
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
|
||||
}
|
||||
void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss))
|
||||
{
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
}
|
||||
|
||||
Oyster::Math::Float3 Object::GetPosition()
|
||||
{
|
||||
|
@ -94,21 +67,9 @@ Oyster::Math::Quaternion Object::GetRotation()
|
|||
state = this->rigidBody->GetState();
|
||||
return state.quaternion;
|
||||
}
|
||||
Oyster::Math::Float3 Object::GetScale()
|
||||
{
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
state = this->rigidBody->GetState();
|
||||
return Float3();
|
||||
}
|
||||
Oyster::Math::Float4x4 Object::GetOrientation()
|
||||
{
|
||||
Oyster::Physics::ICustomBody::State state;
|
||||
state = this->rigidBody->GetState();
|
||||
return state.GetOrientation();
|
||||
}
|
||||
|
||||
|
||||
Oyster::Math::Float Object::getExtraDamageOnCollision()
|
||||
{
|
||||
return this->extraDamageOnCollision;
|
||||
}
|
|
@ -17,46 +17,38 @@ namespace GameLogic
|
|||
class Object :public IObjectData
|
||||
{
|
||||
public:
|
||||
Object();
|
||||
typedef Oyster::Physics::ICustomBody::SubscriptMessage (*OnCollisionCallback)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
public:
|
||||
Object();
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, void (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID);
|
||||
~Object(void);
|
||||
|
||||
ObjectSpecialType GetObjectType() const override;
|
||||
int GetID() const override;
|
||||
void setID(int id);
|
||||
Oyster::Math::Float3 GetPosition() override;
|
||||
Oyster::Math::Quaternion GetRotation() override;
|
||||
Oyster::Math::Float3 GetScale() override;
|
||||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
inline ObjectSpecialType GetObjectType() const override { return this->type; }
|
||||
inline int GetID() const override { return this->objectID; }
|
||||
inline Oyster::Math::Float3 GetScale() override { return this->scale; }
|
||||
inline Oyster::Math::Float3 GetPosition() override;
|
||||
inline Oyster::Math::Quaternion GetRotation() override;
|
||||
inline Oyster::Math::Float4x4 GetOrientation() override;
|
||||
inline Oyster::Physics::ICustomBody* GetRigidBody() { return this->rigidBody; }
|
||||
inline Oyster::Math::Float GetExtraDamageOnCollision() { return this->extraDamageOnCollision; }
|
||||
|
||||
Oyster::Math::Float getExtraDamageOnCollision();
|
||||
virtual void BeginFrame() { };
|
||||
virtual void EndFrame() { };
|
||||
|
||||
// API overrides
|
||||
|
||||
|
||||
|
||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||
|
||||
virtual void BeginFrame();
|
||||
virtual void EndFrame();
|
||||
|
||||
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
||||
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
||||
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
||||
public: //TODO: Hax This should be private when level is dynamic
|
||||
void SetOnCollision(OnCollisionCallback func);
|
||||
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
protected:
|
||||
Oyster::Physics::ICustomBody *rigidBody;
|
||||
|
||||
static const Game* gameInstance;
|
||||
Oyster::Math::Float3 currLook;
|
||||
Oyster::Math::Float3 newLook;
|
||||
|
||||
Oyster::Math::Float3 lookDirection; //The look direction for the camera
|
||||
Oyster::Math::Float3 forwardDirection; //The forward direction of the rigid body
|
||||
Oyster::Math::Float3 scale; //The scale of both rigid body and the mesh
|
||||
|
||||
ObjectSpecialType type;
|
||||
int objectID;
|
||||
|
|
|
@ -33,6 +33,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
|
|||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||
this->moveSpeed = 100;
|
||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
||||
|
||||
this->rotationUp = 0;
|
||||
}
|
||||
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
|
||||
|
@ -53,6 +55,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
|
|||
this->moveDir = Oyster::Math::Float3(0,0,0);
|
||||
this->moveSpeed = 20;
|
||||
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
|
||||
|
||||
this->rotationUp = 0;
|
||||
}
|
||||
|
||||
Player::~Player(void)
|
||||
|
@ -160,7 +164,6 @@ void Player::EndFrame()
|
|||
|
||||
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
|
||||
|
||||
|
||||
Object::EndFrame();
|
||||
}
|
||||
|
||||
|
@ -220,7 +223,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
|||
this->rigidBody->SetPosition(spawnPoint);
|
||||
}
|
||||
|
||||
void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right)
|
||||
void Player::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right)
|
||||
{
|
||||
// this is the camera right vector
|
||||
this->lookDir = lookDir;
|
||||
|
@ -228,6 +231,11 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::
|
|||
//Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
|
||||
//this->rigidBody->SetUpAndRight(up, right);
|
||||
}
|
||||
void Player::TurnLeft(Oyster::Math3D::Float deltaRadians)
|
||||
{
|
||||
this->rotationUp += deltaRadians;
|
||||
this->rigidBody->SetRotationAsAngularAxis(Oyster::Math3D::Float4(this->rigidBody->GetState().centerPos.GetNormalized(), this->rotationUp));
|
||||
}
|
||||
|
||||
void Player::Jump()
|
||||
{
|
||||
|
|
|
@ -46,7 +46,9 @@ namespace GameLogic
|
|||
void Respawn(Oyster::Math::Float3 spawnPoint);
|
||||
|
||||
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right);
|
||||
void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right);
|
||||
|
||||
void TurnLeft(Oyster::Math3D::Float deltaRadians);
|
||||
|
||||
/********************************************************
|
||||
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||
|
@ -94,6 +96,8 @@ namespace GameLogic
|
|||
Oyster::Math::Float moveSpeed;
|
||||
Oyster::Math::Float3 previousMoveSpeed;
|
||||
|
||||
Oyster::Math::Float rotationUp;
|
||||
|
||||
|
||||
bool hasTakenDamage;
|
||||
float invincibleCooldown;
|
||||
|
|
|
@ -561,11 +561,11 @@ namespace GameLogic
|
|||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
//PLAYER_ID
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
//TEAM_ID
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||
//OWNER
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
|
||||
//PLAYER-NAME
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||
//MESH-NAME
|
||||
|
@ -585,9 +585,10 @@ namespace GameLogic
|
|||
}
|
||||
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
this->object_ID = p[1].value.netInt;
|
||||
this->teamId = this->protocol[2].value.netInt;
|
||||
this->owner = this->protocol[3].value.netBool;
|
||||
this->owner = p[1].value.netBool;
|
||||
this->object_ID = p[2].value.netInt;
|
||||
this->teamId = p[3].value.netInt;
|
||||
|
||||
this->name.assign(p[4].value.netCharPtr);
|
||||
this->meshName.assign(p[5].value.netCharPtr);
|
||||
|
||||
|
@ -610,11 +611,11 @@ namespace GameLogic
|
|||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
//PLAYER_ID
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
//TEAM_ID
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||
//OWNER
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
|
||||
//PLAYER-NAME
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||
//MESH-NAME
|
||||
|
@ -644,10 +645,10 @@ namespace GameLogic
|
|||
}
|
||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = this->owner;
|
||||
this->protocol[2].value = this->object_ID;
|
||||
this->protocol[3].value = this->teamId;
|
||||
|
||||
this->protocol[1].value = this->object_ID;
|
||||
this->protocol[2].value = this->teamId;
|
||||
this->protocol[3].value = this->owner;
|
||||
this->protocol.Set(4, this->name);
|
||||
this->protocol.Set(5, this->meshName);
|
||||
|
||||
|
|
|
@ -74,69 +74,40 @@ namespace GameLogic
|
|||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
|
||||
//protocol_Gameplay_PlayerLeftTurn
|
||||
struct Protocol_PlayerLeftTurn : public ::Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
// can be swapped to a quaternion later
|
||||
float lookDir[3];
|
||||
float right[3];
|
||||
public:
|
||||
float deltaRadian;
|
||||
|
||||
Protocol_PlayerLook()
|
||||
Protocol_PlayerLeftTurn()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
// LookDir
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
// Right
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
memset(&this->lookDir[0], 0, sizeof(float) * 3);
|
||||
memset(&this->right[0], 0, sizeof(float) * 3);
|
||||
}
|
||||
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
this->lookDir[0] = p[1].value.netFloat;
|
||||
this->lookDir[1] = p[2].value.netFloat;
|
||||
this->lookDir[2] = p[3].value.netFloat;
|
||||
|
||||
this->right[0] = p[4].value.netFloat;
|
||||
this->right[1] = p[5].value.netFloat;
|
||||
this->right[2] = p[6].value.netFloat;
|
||||
}
|
||||
Protocol_PlayerLook(float l[3], float r[3])
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3);
|
||||
memcpy(&this->right[0], &r[0], sizeof(float) * 3);
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
|
||||
this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
|
||||
// deltaRadian
|
||||
this->protocol[1].type = ::Oyster::Network::NetAttributeType_Float;
|
||||
}
|
||||
|
||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||
Protocol_PlayerLeftTurn( const ::Oyster::Network::CustomNetProtocol &p )
|
||||
{
|
||||
this->protocol[1].value = this->lookDir[0];
|
||||
this->protocol[2].value = this->lookDir[1];
|
||||
this->protocol[3].value = this->lookDir[2];
|
||||
this->protocol[4].value = this->right[0];
|
||||
this->protocol[5].value = this->right[1];
|
||||
this->protocol[6].value = this->right[2];
|
||||
this->deltaRadian = p[1].value.netFloat;
|
||||
}
|
||||
|
||||
Protocol_PlayerLeftTurn( float deltaRadian )
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
|
||||
this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
|
||||
this->deltaRadian = deltaRadian;
|
||||
}
|
||||
|
||||
::Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = this->deltaRadian;
|
||||
return protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
::Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#define protocol_Gameplay_PlayerMovementLeft 301
|
||||
#define protocol_Gameplay_PlayerMovementForward 302
|
||||
#define protocol_Gameplay_PlayerMovementBackward 303
|
||||
#define protocol_Gameplay_PlayerLookDir 304
|
||||
#define protocol_Gameplay_PlayerLeftTurn 304
|
||||
#define protocol_Gameplay_PlayerChangeWeapon 305
|
||||
#define protocol_Gameplay_PlayerShot 306
|
||||
#define protocol_Gameplay_PlayerJump 307
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace DanBias
|
|||
void Gameplay_PlayerMovementBack ( DanBias::GameClient* c );
|
||||
void Gameplay_PlayerMovementForth ( DanBias::GameClient* c );
|
||||
void Gameplay_PlayerJump ( DanBias::GameClient* c );
|
||||
void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c );
|
||||
void Gameplay_PlayerLeftTurn ( GameLogic::Protocol_PlayerLeftTurn& p, DanBias::GameClient* c );
|
||||
void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
|
||||
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
|
||||
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );
|
||||
|
|
|
@ -17,7 +17,7 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::Net
|
|||
this->client = nwClient;
|
||||
this->player = 0;
|
||||
isReady = false;
|
||||
this->character = L"Unknown";
|
||||
this->character = L"crate_colonists.dan";
|
||||
this->alias = L"Unknown";
|
||||
this->secondsSinceLastResponse = 0.0f;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ GameClient::~GameClient()
|
|||
{
|
||||
this->player = 0;
|
||||
this->isReady = false;
|
||||
this->character = L"Unknown";
|
||||
this->character = L"crate_colonists.dan";
|
||||
this->alias = L"Unknown";
|
||||
this->secondsSinceLastResponse = 0.0f;
|
||||
}
|
||||
|
|
|
@ -66,10 +66,10 @@ using namespace DanBias;
|
|||
break;
|
||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||
this->Detach(e.sender);
|
||||
//this->Detach(e.sender);
|
||||
break;
|
||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||
//printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||
this->ParseProtocol(e.args.data.protocol, cl);
|
||||
break;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ using namespace DanBias;
|
|||
break;
|
||||
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c );
|
||||
break;
|
||||
case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c );
|
||||
case protocol_Gameplay_PlayerLeftTurn: this->Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn (p), c );
|
||||
break;
|
||||
case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c );
|
||||
break;
|
||||
|
@ -203,12 +203,9 @@ using namespace DanBias;
|
|||
{
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
|
||||
}
|
||||
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
|
||||
void GameSession::Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn& p, DanBias::GameClient* c )
|
||||
{
|
||||
Oyster::Math3D::Float3 lookDir = p.lookDir;
|
||||
Oyster::Math3D::Float3 right = p.right;
|
||||
|
||||
c->GetPlayer()->Rotate(lookDir, right);
|
||||
c->GetPlayer()->TurnLeft( p.deltaRadian );
|
||||
}
|
||||
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
|
||||
{
|
||||
|
|
|
@ -165,7 +165,8 @@ void GameSession::ThreadEntry( )
|
|||
IPlayerData* pl = this->gClients[k]->GetPlayer();
|
||||
Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(),
|
||||
pl->GetID(), true, this->gClients[k]->GetPlayer()->GetTeamID(),
|
||||
/*nwClient->GetAlias()*/"", /*playerData->GetMesh()*/"char_white.dan");
|
||||
Utility::String::WStringToString(this->gClients[k]->GetAlias(), std::string()),
|
||||
Utility::String::WStringToString(this->gClients[k]->GetCharacter(), std::string()));
|
||||
readyList[i]->GetClient()->Send(p);
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +205,8 @@ bool GameSession::Join(gClient gameClient)
|
|||
{
|
||||
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
|
||||
playerData->GetID(), true, playerData->GetTeamID(),
|
||||
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||
Utility::String::WStringToString(gameClient->GetAlias(), std::string()),
|
||||
Utility::String::WStringToString(gameClient->GetCharacter(), std::string()));
|
||||
nwClient->Send(oc);
|
||||
}
|
||||
|
||||
|
@ -217,7 +219,8 @@ bool GameSession::Join(gClient gameClient)
|
|||
IPlayerData* temp = this->gClients[i]->GetPlayer();
|
||||
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
|
||||
temp->GetID(), false, temp->GetTeamID(),
|
||||
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||
Utility::String::WStringToString(this->gClients[i]->GetAlias(), std::string()),
|
||||
Utility::String::WStringToString(this->gClients[i]->GetCharacter(), std::string()));
|
||||
nwClient->Send(oc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef _INPUTCLASS_H_
|
||||
#define _INPUTCLASS_H_
|
||||
|
||||
#define NOMINMAX
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#pragma comment(lib, "dinput8.lib")
|
||||
|
|
|
@ -49,7 +49,16 @@ namespace LinearAlgebra
|
|||
Quaternion<ScalarType> operator - ( const Quaternion<ScalarType> &quaternion ) const;
|
||||
Quaternion<ScalarType> operator - ( ) const;
|
||||
|
||||
Quaternion<ScalarType> & Conjugate( );
|
||||
Quaternion<ScalarType> & Normalize( );
|
||||
Quaternion<ScalarType> & Inverse( );
|
||||
|
||||
Quaternion<ScalarType> GetConjugate( ) const;
|
||||
Quaternion<ScalarType> GetNormalized( ) const;
|
||||
Quaternion<ScalarType> GetInversed( ) const;
|
||||
ScalarType GetNorm( ) const;
|
||||
ScalarType GetModulus( ) const;
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -205,11 +214,54 @@ namespace LinearAlgebra
|
|||
return Quaternion<ScalarType>(-this->imaginary, -this->real);
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> & Quaternion<ScalarType>::Conjugate( )
|
||||
{
|
||||
this->imaginary = -this->imaginary;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> & Quaternion<ScalarType>::Normalize( )
|
||||
{
|
||||
return *this /= this->GetModulus();
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> & Quaternion<ScalarType>::Inverse( )
|
||||
{
|
||||
return this->Conjugate() /= this->GetNorm();
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> Quaternion<ScalarType>::GetConjugate( ) const
|
||||
{
|
||||
return Quaternion<ScalarType>(-this->imaginary, this->real );
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> Quaternion<ScalarType>::GetNormalized( ) const
|
||||
{
|
||||
return *this / this->GetModulus();
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline Quaternion<ScalarType> Quaternion<ScalarType>::GetInversed( ) const
|
||||
{
|
||||
return this->GetConjugate() /= this->GetNorm();
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline ScalarType Quaternion<ScalarType>::GetNorm( ) const
|
||||
{
|
||||
return this->imaginary.Dot(this->imaginary) + this->real * this->real;
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
inline ScalarType Quaternion<ScalarType>::GetModulus( ) const
|
||||
{
|
||||
return (ScalarType)::std::sqrt( this->GetNorm() );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -337,11 +337,7 @@ namespace Utility
|
|||
|
||||
template<typename ValueType>
|
||||
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
|
||||
{
|
||||
if( value < min ) return min;
|
||||
if( value > max ) return max;
|
||||
return value;
|
||||
}
|
||||
{ return value < min ? Max( value, max ) : min; }
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType Average( const ValueType &valueA, const ValueType &valueB )
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace Oyster
|
|||
Model::Model* sphere;
|
||||
|
||||
ID3D11RasterizerState* wire;
|
||||
|
||||
ID3D11ShaderResourceView* debugSRV;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -50,8 +52,15 @@ namespace Oyster
|
|||
Render::Preparations::Basic::SetViewPort();
|
||||
#ifdef _DEBUG
|
||||
//fix load model
|
||||
cube = CreateModel(L"debug_cube.dan");
|
||||
sphere = CreateModel(L"debug_sphere.dan");
|
||||
|
||||
debugSRV = (ID3D11ShaderResourceView*)API::CreateTexture(L"color_white.png");
|
||||
debugSRV = (ID3D11ShaderResourceView*)API::CreateTexture(L"color_white.png");
|
||||
|
||||
cube = CreateModel(L"generic_cube.dan");
|
||||
cube->Tint = Math::Float3(0.0f,0.0f,1.0f);
|
||||
sphere = CreateModel(L"generic_sphere.dan");
|
||||
sphere->Tint = Math::Float3(1.0f,0.5f,182/255.0f);
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC desc;
|
||||
desc.CullMode = D3D11_CULL_BACK;
|
||||
|
@ -196,6 +205,7 @@ namespace Oyster
|
|||
|
||||
void API::StartRenderWireFrame()
|
||||
{
|
||||
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
|
||||
Core::deviceContext->RSSetState(wire);
|
||||
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice,
|
|||
return hr;
|
||||
}
|
||||
//todo check calc
|
||||
int TexSize = twidth * theight * bpp;
|
||||
int TexSize = twidth * theight * (int)bpp;
|
||||
Oyster::Graphics::Core::UsedMem += TexSize;
|
||||
|
||||
if ( autogen )
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue