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

This commit is contained in:
Pontus Fransson 2014-02-19 14:52:24 +01:00
commit da94d7d827
39 changed files with 973 additions and 296 deletions

View File

@ -207,6 +207,7 @@
<ClCompile Include="GameClientState\Camera_BasicV2.cpp" /> <ClCompile Include="GameClientState\Camera_BasicV2.cpp" />
<ClCompile Include="GameClientState\Camera_FPS.cpp" /> <ClCompile Include="GameClientState\Camera_FPS.cpp" />
<ClCompile Include="GameClientState\Camera_FPSV2.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_DynamicObj.cpp" />
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" /> <ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" /> <ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
@ -214,12 +215,15 @@
<ClCompile Include="DLLMain.cpp" /> <ClCompile Include="DLLMain.cpp" />
<ClCompile Include="GameClientState\GameClientState.cpp" /> <ClCompile Include="GameClientState\GameClientState.cpp" />
<ClCompile Include="GameClientState\GameState.cpp" /> <ClCompile Include="GameClientState\GameState.cpp" />
<ClCompile Include="GameClientState\GameStateUI.cpp" />
<ClCompile Include="GameClientState\GamingUI.cpp" />
<ClCompile Include="GameClientState\LanMenuState.cpp" /> <ClCompile Include="GameClientState\LanMenuState.cpp" />
<ClCompile Include="GameClientState\LobbyAdminState.cpp" /> <ClCompile Include="GameClientState\LobbyAdminState.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" /> <ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" /> <ClCompile Include="GameClientState\C_Object.cpp" />
<ClCompile Include="GameClientState\MainState.cpp" /> <ClCompile Include="GameClientState\MainState.cpp" />
<ClCompile Include="GameClientState\NetLoadState.cpp" /> <ClCompile Include="GameClientState\NetLoadState.cpp" />
<ClCompile Include="GameClientState\RespawnUI.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GameClientState\Camera_Basic.h" /> <ClInclude Include="GameClientState\Camera_Basic.h" />
@ -230,16 +234,20 @@
<ClInclude Include="GameClientState\Camera_BasicV2.h" /> <ClInclude Include="GameClientState\Camera_BasicV2.h" />
<ClInclude Include="GameClientState\Camera_FPS.h" /> <ClInclude Include="GameClientState\Camera_FPS.h" />
<ClInclude Include="GameClientState\Camera_FPSV2.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_DynamicObj.h" />
<ClInclude Include="GameClientState\C_obj\C_Player.h" /> <ClInclude Include="GameClientState\C_obj\C_Player.h" />
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" /> <ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
<ClInclude Include="GameClientState\C_obj\C_UIobject.h" /> <ClInclude Include="GameClientState\C_obj\C_UIobject.h" />
<ClInclude Include="GameClientState\GameClientState.h" /> <ClInclude Include="GameClientState\GameClientState.h" />
<ClInclude Include="GameClientState\GameState.h" /> <ClInclude Include="GameClientState\GameState.h" />
<ClInclude Include="GameClientState\GameStateUI.h" />
<ClInclude Include="GameClientState\GamingUI.h" />
<ClInclude Include="GameClientState\LanMenuState.h" /> <ClInclude Include="GameClientState\LanMenuState.h" />
<ClInclude Include="GameClientState\LobbyAdminState.h" /> <ClInclude Include="GameClientState\LobbyAdminState.h" />
<ClInclude Include="GameClientState\MainState.h" /> <ClInclude Include="GameClientState\MainState.h" />
<ClInclude Include="GameClientState\NetLoadState.h" /> <ClInclude Include="GameClientState\NetLoadState.h" />
<ClInclude Include="GameClientState\RespawnUI.h" />
<ClInclude Include="GameClientState\SharedStateContent.h" /> <ClInclude Include="GameClientState\SharedStateContent.h" />
<ClInclude Include="Include\GameClient.h" /> <ClInclude Include="Include\GameClient.h" />
<ClInclude Include="GameClientState\LobbyState.h" /> <ClInclude Include="GameClientState\LobbyState.h" />

View File

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

View File

@ -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);
}

View File

@ -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

View File

@ -9,6 +9,10 @@ C_Object::C_Object()
id = 0; id = 0;
model = NULL; model = NULL;
// RB DEBUG
type = RB_Type_None;
// !RB DEBUG
} }
C_Object::~C_Object() C_Object::~C_Object()
{ {
@ -31,32 +35,27 @@ void C_Object::updateWorld()
{ {
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position); Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(this->position);
Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation); Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(this->rotation);
//Oyster::Math3D::Float4x4 scale = Oyster::Math3D::; Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(this->scale);
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];
world = translation * rot * scale; world = translation * rot * scale;
model->WorldMatrix = world; model->WorldMatrix = world;
} }
void C_Object::setWorld(Oyster::Math::Float4x4 world)
{
model->WorldMatrix = world;
}
Oyster::Math::Float4x4 C_Object::getWorld() const 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; return world;
} }
void C_Object::setPos(Oyster::Math::Float3 newPos) void C_Object::setPos(Oyster::Math::Float3 newPos)
{ {
this->position = newPos; this->position = newPos;
updateWorld();
} }
void C_Object::addPos(Oyster::Math::Float3 deltaPos) void C_Object::addPos(Oyster::Math::Float3 deltaPos)
{ {
this->position += deltaPos; this->position += deltaPos;
updateWorld();
} }
Oyster::Math::Float3 C_Object::getPos() const 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) void C_Object::setRot(Oyster::Math::Quaternion newRot)
{ {
this->rotation = newRot; this->rotation = newRot;
updateWorld();
}
void C_Object::addRot(Oyster::Math::Quaternion deltaRot)
{
this->rotation += deltaRot;
updateWorld();
} }
Oyster::Math::Quaternion C_Object::getRotation() const 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) void C_Object::setScale(Oyster::Math::Float3 newScale)
{ {
this->scale = newScale; this->scale = newScale;
updateWorld();
} }
void C_Object::addScale(Oyster::Math::Float3 deltaScale) void C_Object::addScale(Oyster::Math::Float3 deltaScale)
{ {
this->scale += deltaScale; this->scale += deltaScale;
updateWorld();
} }
Oyster::Math::Float3 C_Object::getScale() const Oyster::Math::Float3 C_Object::getScale() const
{ {
@ -106,3 +97,55 @@ void C_Object::Release()
this->model = nullptr; 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

View File

@ -5,6 +5,21 @@ namespace DanBias
{ {
namespace Client 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 struct ModelInitData
{ {
@ -24,27 +39,45 @@ namespace DanBias
Oyster::Math::Quaternion rotation; Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale; 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; int id;
void updateWorld();
protected: protected:
Oyster::Graphics::Model::Model *model; Oyster::Graphics::Model::Model *model;
public: public:
C_Object(); C_Object();
virtual ~C_Object(); virtual ~C_Object();
virtual bool Init(ModelInitData modelInit); virtual bool Init(ModelInitData modelInit);
void updateWorld();
void setWorld(Oyster::Math::Float4x4 world); //void setWorld(Oyster::Math::Float4x4 world);
Oyster::Math::Float4x4 getWorld() const; Oyster::Math::Float4x4 getWorld() const;
void setPos(Oyster::Math::Float3 newPos); void setPos(Oyster::Math::Float3 newPos);
Oyster::Math::Float3 getPos() const; Oyster::Math::Float3 getPos() const;
void addPos(Oyster::Math::Float3 deltaPos); void addPos(Oyster::Math::Float3 deltaPos);
void setRot(Oyster::Math::Quaternion newRot); void setRot(Oyster::Math::Quaternion newRot);
Oyster::Math::Quaternion getRotation() const; Oyster::Math::Quaternion getRotation() const;
void addRot(Oyster::Math::Quaternion deltaRot);
void setScale(Oyster::Math::Float3 newScale); void setScale(Oyster::Math::Float3 newScale);
void addScale(Oyster::Math::Float3 deltaScale); void addScale(Oyster::Math::Float3 deltaScale);
Oyster::Math::Float3 getScale() const; 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 Render();
virtual void Release(); virtual void Release();
virtual int GetId() const; virtual int GetId() const;

View File

@ -35,7 +35,7 @@ namespace DanBias { namespace Client
/****************************************************************** /******************************************************************
* @param message of the event * @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 ); virtual const NetEvent & DataRecieved( const NetEvent &message );
}; };

View File

@ -4,7 +4,7 @@
#include "NetworkClient.h" #include "NetworkClient.h"
#include "Camera_FPSV2.h" #include "Camera_FPSV2.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
#include "C_Light.h"
#include "C_obj/C_Player.h" #include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h" #include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.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_StaticObj>> *staticObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
bool key_forward; bool key_forward;
bool key_backward; bool key_backward;
@ -36,7 +37,11 @@ struct GameState::MyData
bool key_Shoot; bool key_Shoot;
bool key_Jump; bool key_Jump;
// DEGUG KEYS
bool key_Reload_Shaders; bool key_Reload_Shaders;
bool key_Wireframe_Toggle;
bool renderWhireframe;
// !DEGUG KEYS
C_Player player; C_Player player;
Camera_FPSV2 camera; Camera_FPSV2 camera;
@ -78,15 +83,28 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->input = shared.input; this->privData->input = shared.input;
this->privData->staticObjects = &shared.staticObjects; this->privData->staticObjects = &shared.staticObjects;
this->privData->dynamicObjects = &shared.dynamicObjects; this->privData->dynamicObjects = &shared.dynamicObjects;
this->privData->lights = &shared.lights;
Graphics::API::Option gfxOp = Graphics::API::GetOption(); Graphics::API::Option gfxOp = Graphics::API::GetOption();
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; 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() ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
//tell server ready //tell server ready
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) ); this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
// DEGUG KEYS
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; return true;
} }
@ -100,10 +118,20 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
StringToWstring( modelName, modelData.modelPath ); StringToWstring( modelName, modelData.modelPath );
modelData.id = id; modelData.id = id;
// RB DEBUG
RBInitData RBData;
RBData.position = position;
RBData.rotation = ArrayToQuaternion( rotation );
RBData.scale = scale;
// !RB DEBUG
if( isMyPlayer ) if( isMyPlayer )
{ {
if( this->privData->player.Init(modelData) ) if( this->privData->player.Init(modelData) )
{ {
// RB DEBUG
this->privData->player.InitRB( RBData );
// !RB DEBUG
this->privData->myId = id; this->privData->myId = id;
this->privData->camera.SetPosition( this->privData->player.getPos() ); this->privData->camera.SetPosition( this->privData->player.getPos() );
Float3 offset = Float3( 0.0f ); Float3 offset = Float3( 0.0f );
@ -117,6 +145,10 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
C_DynamicObj *p = new C_DynamicObj(); C_DynamicObj *p = new C_DynamicObj();
if( p->Init(modelData) ) if( p->Init(modelData) )
{ {
// RB DEBUG
this->privData->player.InitRB( RBData );
// !RB DEBUG
(*this->privData->dynamicObjects)[id] = p; (*this->privData->dynamicObjects)[id] = p;
} }
} }
@ -150,6 +182,55 @@ bool GameState::Render()
dynamicObject->second->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(); Oyster::Graphics::API::EndFrame();
return true; return true;
} }
@ -170,8 +251,15 @@ bool GameState::Release()
dynamicObject->second = nullptr; 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->staticObjects->clear();
this->privData->dynamicObjects->clear(); this->privData->dynamicObjects->clear();
this->privData->lights->clear();
privData = NULL; privData = NULL;
} }
@ -229,28 +317,11 @@ void GameState::ReadKeyInput()
else else
this->privData->key_strafeRight = false; 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 //send delta mouse movement
{ {
this->privData->camera.YawRight( this->privData->input->GetYaw() * 0.017f ); static const float mouseSensitivity = Radian( 1.0f );
this->privData->camera.PitchDown( this->privData->input->GetPitch() * 0.017f ); this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity );
this->privData->camera.UpdateOrientation(); this->privData->nwClient->Send( Protocol_PlayerLeftTurn(this->privData->input->GetYaw() * mouseSensitivity) );
privData->nwClient->Send( Protocol_PlayerLook(this->privData->camera.GetLook(), this->privData->camera.GetRight()) );
} }
// shoot // shoot
@ -309,6 +380,35 @@ void GameState::ReadKeyInput()
else else
this->privData->key_Jump = false; 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 // TODO: implement sub-menu
} }
@ -342,12 +442,18 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
this->privData->camera.SetPosition( decoded.position ); this->privData->camera.SetPosition( decoded.position );
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( 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; return GameClientState::event_processed;
case protocol_Gameplay_ObjectScale: case protocol_Gameplay_ObjectScale:
{ {
Protocol_ObjectScale decoded(data); Protocol_ObjectScale decoded(data);
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale ); (*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; return GameClientState::event_processed;
case protocol_Gameplay_ObjectRotation: case protocol_Gameplay_ObjectRotation:
@ -360,6 +466,9 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
this->privData->camera.SetRotation( rotation ); this->privData->camera.SetRotation( rotation );
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( 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; return GameClientState::event_processed;
case protocol_Gameplay_ObjectPositionRotation: case protocol_Gameplay_ObjectPositionRotation:
@ -372,16 +481,21 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
if( this->privData->myId == decoded.object_ID ) if( this->privData->myId == decoded.object_ID )
{ {
this->privData->camera.SetPosition( position ); this->privData->camera.SetPosition( position );
//this->privData->camera.SetRotation( rotation ); this->privData->camera.SetRotation( rotation );
this->privData->player.setPos( position ); this->privData->player.setPos( position );
//this->privData->player.setRot( rotation ); this->privData->player.setRot( rotation );
} }
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
if( object ) if( object )
{ {
object->setPos( position ); object->setPos( position );
object->setRot( rotation ); object->setRot( rotation );
// RB DEBUG
object->setRBPos ( position );
object->setRBRot ( rotation );
// !RB DEBUG
} }
} }
return GameClientState::event_processed; return GameClientState::event_processed;
@ -406,7 +520,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
ModelInitData modelData; ModelInitData modelData;
{ {
modelData.position = Float3( decoded.position ); 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.scale = Float3( decoded.scale );
modelData.visible = true; modelData.visible = true;
modelData.id = decoded.object_ID; modelData.id = decoded.object_ID;
@ -414,6 +528,15 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
::Utility::String::StringToWstring( decoded.name, modelData.modelPath ); ::Utility::String::StringToWstring( decoded.name, modelData.modelPath );
} }
object->Init(modelData); 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; (*this->privData->dynamicObjects)[decoded.object_ID] = object;

View File

@ -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;
}

View File

@ -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

View File

@ -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() );
}
}

View File

@ -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

View File

@ -6,6 +6,7 @@
#include "Utilities.h" #include "Utilities.h"
#include "C_obj\C_StaticObj.h" #include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h" #include "C_obj\C_DynamicObj.h"
#include "C_Light.h"
using namespace ::DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster; using namespace ::Oyster;
@ -23,6 +24,7 @@ struct NetLoadState::MyData
Graphics::API::Texture background; Graphics::API::Texture background;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects; ::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
bool loading; bool loading;
}; };
@ -49,6 +51,7 @@ bool NetLoadState::Init( SharedStateContent &shared )
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" ); this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
this->privData->dynamicObjects = &shared.dynamicObjects; this->privData->dynamicObjects = &shared.dynamicObjects;
this->privData->staticObjects = &shared.staticObjects; this->privData->staticObjects = &shared.staticObjects;
this->privData->lights = &shared.lights;
this->privData->loading = false; this->privData->loading = false;
@ -141,17 +144,31 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
desc.scale = oh->scale; desc.scale = oh->scale;
desc.visible = true; 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(); C_StaticObj *staticObject = new C_StaticObj();
if( staticObject->Init( desc ) ) 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; (*this->privData->staticObjects)[objectID] = staticObject;
} }
else else
@ -175,6 +192,27 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
C_DynamicObj *dynamicObject = new C_DynamicObj(); C_DynamicObj *dynamicObject = new C_DynamicObj();
if( dynamicObject->Init( desc ) ) 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; (*this->privData->dynamicObjects)[objectID] = dynamicObject;
} }
else else
@ -185,7 +223,17 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
break; break;
case ObjectType::ObjectType_Light: 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; break;
default: break; default: break;

View File

@ -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;
}

View File

@ -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

View File

@ -13,6 +13,7 @@
#include "C_Object.h" #include "C_Object.h"
#include "C_obj\C_StaticObj.h" #include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h" #include "C_obj\C_DynamicObj.h"
#include "C_Light.h"
#include "NetworkClient.h" #include "NetworkClient.h"
#include "L_inputClass.h" #include "L_inputClass.h"
@ -23,6 +24,7 @@ namespace DanBias { namespace Client
public: public:
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> staticObjects; ::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_DynamicObj>> dynamicObjects;
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> lights;
::Oyster::Network::NetworkClient *network; ::Oyster::Network::NetworkClient *network;
InputClass* input; InputClass* input;
}; };

View File

@ -46,7 +46,7 @@ using namespace GameLogic;
break; break;
case ObjectSpecialType::ObjectSpecialType_CrystalFormation: case ObjectSpecialType::ObjectSpecialType_CrystalFormation:
PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->getExtraDamageOnCollision()); PlayerVLethalObject(*player,*realObj, kineticEnergyLoss,realObj->GetExtraDamageOnCollision());
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break; 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; return Physics::ICustomBody::SubscriptMessage_none;
} }

View File

@ -68,12 +68,33 @@ void Game::GetAllPlayerPositions() const
Game::PlayerData* Game::CreatePlayer() Game::PlayerData* Game::CreatePlayer()
{ {
// Find a free space in array or insert at end // 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(); for(int i = 0; i < 100; i++)
this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove); {
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]) 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++) 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(); API::Instance().UpdateWorld();
for (unsigned int i = 0; i < this->players.Size(); i++) for (unsigned int i = 0; i < this->players.Size(); i++)
{ {
if(this->players[i]->player) this->players[i]->player->EndFrame(); this->onMoveFnc(this->players[i]);
gameInstance.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; return true;
} }

View File

@ -31,17 +31,18 @@ namespace GameLogic
PlayerData(int playerID,int teamID); PlayerData(int playerID,int teamID);
~PlayerData(); ~PlayerData();
void Move(const PLAYER_MOVEMENT &movement) override; void Move(const PLAYER_MOVEMENT &movement) override;
void UseWeapon(const WEAPON_FIRE &usage) override; void UseWeapon(const WEAPON_FIRE &usage) override;
int GetTeamID() const override; int GetTeamID() const override;
PLAYER_STATE GetState() const override; PLAYER_STATE GetState() const override;
Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override; Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override; Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override; Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const 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;
ObjectSpecialType GetObjectType() const override; void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
ObjectSpecialType GetObjectType() const override;

View File

@ -85,7 +85,12 @@ namespace GameLogic
* @param x: The relative x axis * @param x: The relative x axis
* @param y: The relative y 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 * Uses the chosen players weapon based on input

View File

@ -21,13 +21,23 @@ Game::PlayerData::PlayerData()
rigidBody->SetAngularFactor(0.0f); rigidBody->SetAngularFactor(0.0f);
//create player with this rigid body //create player with this rigid body
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0); 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) 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() Game::PlayerData::~PlayerData()
{ {
@ -75,7 +85,11 @@ ObjectSpecialType Game::PlayerData::GetObjectType() const
{ {
return this->player->GetObjectType(); 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); this->player->Rotate(lookDir, right);
} }
void Game::PlayerData::TurnLeft(Oyster::Math3D::Float deltaLeftRadians )
{
this->player->TurnLeft(deltaLeftRadians);
}

View File

@ -30,14 +30,14 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
{ {
case ObjectSpecialType_None: case ObjectSpecialType_None:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_Sky: case ObjectSpecialType_Sky:
{ {
float skySize = ((SkyAttributes*)obj)->skySize; 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; break;
case ObjectSpecialType_World: case ObjectSpecialType_World:
@ -48,21 +48,21 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
float worldSize = ((WorldAttributes*)obj)->worldSize; float worldSize = ((WorldAttributes*)obj)->worldSize;
float atmosphereSize = ((WorldAttributes*)obj)->atmoSphereSize; 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; break;
case ObjectSpecialType_Building: 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: case ObjectSpecialType_Stone:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_StandardBox: case ObjectSpecialType_StandardBox:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_RedExplosiveBox: case ObjectSpecialType_RedExplosiveBox:
@ -79,24 +79,24 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
// break; // break;
case ObjectSpecialType_SpikeBox: case ObjectSpecialType_SpikeBox:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_Spike: case ObjectSpecialType_Spike:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_CrystalFormation: case ObjectSpecialType_CrystalFormation:
{ {
int dmg = 50; int dmg = 50;
//gameObj = new Crystal(rigidBody); //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; break;
case ObjectSpecialType_CrystalShard: case ObjectSpecialType_CrystalShard:
{ {
gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
case ObjectSpecialType_JumpPad: case ObjectSpecialType_JumpPad:
@ -126,12 +126,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
break; break;
case ObjectSpecialType_Generic: case ObjectSpecialType_Generic:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
default: default:
{ {
gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID); gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID);
} }
break; break;
} }
@ -242,34 +242,8 @@ bool Level::InitiateLevel(std::wstring levelPath)
ICustomBody* rigidBody_Static = NULL; 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 // collision shape
else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere) if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Sphere)
{ {
rigidBody_Static = InitRigidBodySphere(staticObjData); 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); 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; /*offset += nrOfBoxex;
for(int i =0; i< nrOfBoxex; i ++) 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); 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]); 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); 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]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i+offset]);
} }
offset += nrOfBoxex; 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); 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]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
}*/ }*/
// add crystal // 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); 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 // 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); 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 // add jumppad

View File

@ -15,11 +15,11 @@ const Game *Object::gameInstance = (Game*)(&Game::Instance());
Object::Object() 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->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->type = ObjectSpecialType_Unknown;
this->objectID = -1; 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) 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; this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(func));
}
int Object::GetID() const
{
return this->objectID;
} }
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() Oyster::Math::Float3 Object::GetPosition()
{ {
@ -94,21 +67,9 @@ Oyster::Math::Quaternion Object::GetRotation()
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.quaternion; 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::Math::Float4x4 Object::GetOrientation()
{ {
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.GetOrientation(); return state.GetOrientation();
} }
Oyster::Math::Float Object::getExtraDamageOnCollision()
{
return this->extraDamageOnCollision;
}

View File

@ -17,46 +17,38 @@ namespace GameLogic
class Object :public IObjectData class Object :public IObjectData
{ {
public: 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, 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(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); ~Object(void);
ObjectSpecialType GetObjectType() const override; inline ObjectSpecialType GetObjectType() const override { return this->type; }
int GetID() const override; inline int GetID() const override { return this->objectID; }
void setID(int id); inline Oyster::Math::Float3 GetScale() override { return this->scale; }
Oyster::Math::Float3 GetPosition() override; inline Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override; inline Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override; inline Oyster::Math::Float4x4 GetOrientation() override;
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 void SetOnCollision(OnCollisionCallback func);
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
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultOnCollision(Oyster::Physics::ICustomBody *rigidBodyObject, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
protected: protected:
Oyster::Physics::ICustomBody *rigidBody; Oyster::Physics::ICustomBody *rigidBody;
static const Game* gameInstance; 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; ObjectSpecialType type;
int objectID; int objectID;

View File

@ -33,6 +33,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
this->moveDir = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0);
this->moveSpeed = 100; this->moveSpeed = 100;
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); 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) 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->moveDir = Oyster::Math::Float3(0,0,0);
this->moveSpeed = 20; this->moveSpeed = 20;
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
this->rotationUp = 0;
} }
Player::~Player(void) Player::~Player(void)
@ -160,7 +164,6 @@ void Player::EndFrame()
this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized());
Object::EndFrame(); Object::EndFrame();
} }
@ -220,7 +223,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->rigidBody->SetPosition(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 is the camera right vector
this->lookDir = lookDir; 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]; //Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
//this->rigidBody->SetUpAndRight(up, right); //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() void Player::Jump()
{ {

View File

@ -46,7 +46,9 @@ namespace GameLogic
void Respawn(Oyster::Math::Float3 spawnPoint); 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 * 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::Float moveSpeed;
Oyster::Math::Float3 previousMoveSpeed; Oyster::Math::Float3 previousMoveSpeed;
Oyster::Math::Float rotationUp;
bool hasTakenDamage; bool hasTakenDamage;
float invincibleCooldown; float invincibleCooldown;

View File

@ -561,11 +561,11 @@ namespace GameLogic
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
//PLAYER_ID //PLAYER_ID
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
//TEAM_ID //TEAM_ID
this->protocol[2].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
//OWNER //OWNER
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
//PLAYER-NAME //PLAYER-NAME
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray; this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
//MESH-NAME //MESH-NAME
@ -585,9 +585,10 @@ namespace GameLogic
} }
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p) Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
{ {
this->object_ID = p[1].value.netInt; this->owner = p[1].value.netBool;
this->teamId = this->protocol[2].value.netInt; this->object_ID = p[2].value.netInt;
this->owner = this->protocol[3].value.netBool; this->teamId = p[3].value.netInt;
this->name.assign(p[4].value.netCharPtr); this->name.assign(p[4].value.netCharPtr);
this->meshName.assign(p[5].value.netCharPtr); this->meshName.assign(p[5].value.netCharPtr);
@ -610,11 +611,11 @@ namespace GameLogic
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
//PLAYER_ID //PLAYER_ID
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
//TEAM_ID //TEAM_ID
this->protocol[2].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
//OWNER //OWNER
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; this->protocol[3].type = Oyster::Network::NetAttributeType_Int;
//PLAYER-NAME //PLAYER-NAME
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray; this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
//MESH-NAME //MESH-NAME
@ -644,10 +645,10 @@ namespace GameLogic
} }
Oyster::Network::CustomNetProtocol GetProtocol() override 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(4, this->name);
this->protocol.Set(5, this->meshName); this->protocol.Set(5, this->meshName);

View File

@ -74,69 +74,40 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; 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 public:
float lookDir[3]; float deltaRadian;
float right[3];
Protocol_PlayerLook() Protocol_PlayerLeftTurn()
{ {
this->protocol[0].value = protocol_Gameplay_PlayerLookDir; this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
// LookDir // deltaRadian
this->protocol[1].type = Oyster::Network::NetAttributeType_Float; 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);
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Protocol_PlayerLeftTurn( const ::Oyster::Network::CustomNetProtocol &p )
{ {
this->protocol[1].value = this->lookDir[0]; this->deltaRadian = p[1].value.netFloat;
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];
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; return protocol;
} }
private: private:
Oyster::Network::CustomNetProtocol protocol; ::Oyster::Network::CustomNetProtocol protocol;
}; };
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject

View File

@ -47,7 +47,7 @@
#define protocol_Gameplay_PlayerMovementLeft 301 #define protocol_Gameplay_PlayerMovementLeft 301
#define protocol_Gameplay_PlayerMovementForward 302 #define protocol_Gameplay_PlayerMovementForward 302
#define protocol_Gameplay_PlayerMovementBackward 303 #define protocol_Gameplay_PlayerMovementBackward 303
#define protocol_Gameplay_PlayerLookDir 304 #define protocol_Gameplay_PlayerLeftTurn 304
#define protocol_Gameplay_PlayerChangeWeapon 305 #define protocol_Gameplay_PlayerChangeWeapon 305
#define protocol_Gameplay_PlayerShot 306 #define protocol_Gameplay_PlayerShot 306
#define protocol_Gameplay_PlayerJump 307 #define protocol_Gameplay_PlayerJump 307

View File

@ -84,7 +84,7 @@ namespace DanBias
void Gameplay_PlayerMovementBack ( DanBias::GameClient* c ); void Gameplay_PlayerMovementBack ( DanBias::GameClient* c );
void Gameplay_PlayerMovementForth ( DanBias::GameClient* c ); void Gameplay_PlayerMovementForth ( DanBias::GameClient* c );
void Gameplay_PlayerJump ( 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_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c ); void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c ); void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );

View File

@ -17,7 +17,7 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::Net
this->client = nwClient; this->client = nwClient;
this->player = 0; this->player = 0;
isReady = false; isReady = false;
this->character = L"Unknown"; this->character = L"crate_colonists.dan";
this->alias = L"Unknown"; this->alias = L"Unknown";
this->secondsSinceLastResponse = 0.0f; this->secondsSinceLastResponse = 0.0f;
} }
@ -25,7 +25,7 @@ GameClient::~GameClient()
{ {
this->player = 0; this->player = 0;
this->isReady = false; this->isReady = false;
this->character = L"Unknown"; this->character = L"crate_colonists.dan";
this->alias = L"Unknown"; this->alias = L"Unknown";
this->secondsSinceLastResponse = 0.0f; this->secondsSinceLastResponse = 0.0f;
} }

View File

@ -66,10 +66,10 @@ using namespace DanBias;
break; break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend: case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
this->Detach(e.sender); //this->Detach(e.sender);
break; break;
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved: 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); this->ParseProtocol(e.args.data.protocol, cl);
break; break;
} }
@ -156,7 +156,7 @@ using namespace DanBias;
break; break;
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c ); case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c );
break; break;
case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c ); case protocol_Gameplay_PlayerLeftTurn: this->Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn (p), c );
break; break;
case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c ); case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c );
break; break;
@ -203,12 +203,9 @@ using namespace DanBias;
{ {
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP); 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; c->GetPlayer()->TurnLeft( p.deltaRadian );
Oyster::Math3D::Float3 right = p.right;
c->GetPlayer()->Rotate(lookDir, right);
} }
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
{ {

View File

@ -165,7 +165,8 @@ void GameSession::ThreadEntry( )
IPlayerData* pl = this->gClients[k]->GetPlayer(); IPlayerData* pl = this->gClients[k]->GetPlayer();
Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(), Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(),
pl->GetID(), true, this->gClients[k]->GetPlayer()->GetTeamID(), 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); readyList[i]->GetClient()->Send(p);
} }
} }
@ -204,7 +205,8 @@ bool GameSession::Join(gClient gameClient)
{ {
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(), Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
playerData->GetID(), true, playerData->GetTeamID(), 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); nwClient->Send(oc);
} }
@ -217,7 +219,8 @@ bool GameSession::Join(gClient gameClient)
IPlayerData* temp = this->gClients[i]->GetPlayer(); IPlayerData* temp = this->gClients[i]->GetPlayer();
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(), Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
temp->GetID(), false, temp->GetTeamID(), 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); nwClient->Send(oc);
} }
} }

View File

@ -7,6 +7,7 @@
#ifndef _INPUTCLASS_H_ #ifndef _INPUTCLASS_H_
#define _INPUTCLASS_H_ #define _INPUTCLASS_H_
#define NOMINMAX
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
#pragma comment(lib, "dinput8.lib") #pragma comment(lib, "dinput8.lib")

View File

@ -49,7 +49,16 @@ namespace LinearAlgebra
Quaternion<ScalarType> operator - ( const Quaternion<ScalarType> &quaternion ) const; Quaternion<ScalarType> operator - ( const Quaternion<ScalarType> &quaternion ) const;
Quaternion<ScalarType> operator - ( ) const; Quaternion<ScalarType> operator - ( ) const;
Quaternion<ScalarType> & Conjugate( );
Quaternion<ScalarType> & Normalize( );
Quaternion<ScalarType> & Inverse( );
Quaternion<ScalarType> GetConjugate( ) const; 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); 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> template<typename ScalarType>
inline Quaternion<ScalarType> Quaternion<ScalarType>::GetConjugate( ) const inline Quaternion<ScalarType> Quaternion<ScalarType>::GetConjugate( ) const
{ {
return Quaternion<ScalarType>(-this->imaginary, this->real ); 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 #endif

View File

@ -337,11 +337,7 @@ namespace Utility
template<typename ValueType> template<typename ValueType>
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max ) inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max )
{ { return value < min ? Max( value, max ) : min; }
if( value < min ) return min;
if( value > max ) return max;
return value;
}
template<typename ValueType> template<typename ValueType>
inline ValueType Average( const ValueType &valueA, const ValueType &valueB ) inline ValueType Average( const ValueType &valueA, const ValueType &valueB )

View File

@ -24,6 +24,8 @@ namespace Oyster
Model::Model* sphere; Model::Model* sphere;
ID3D11RasterizerState* wire; ID3D11RasterizerState* wire;
ID3D11ShaderResourceView* debugSRV;
#endif #endif
} }
@ -50,8 +52,15 @@ namespace Oyster
Render::Preparations::Basic::SetViewPort(); Render::Preparations::Basic::SetViewPort();
#ifdef _DEBUG #ifdef _DEBUG
//fix load model //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; D3D11_RASTERIZER_DESC desc;
desc.CullMode = D3D11_CULL_BACK; desc.CullMode = D3D11_CULL_BACK;
@ -196,6 +205,7 @@ namespace Oyster
void API::StartRenderWireFrame() 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->RSSetState(wire);
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
} }

View File

@ -700,7 +700,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice,
return hr; return hr;
} }
//todo check calc //todo check calc
int TexSize = twidth * theight * bpp; int TexSize = twidth * theight * (int)bpp;
Oyster::Graphics::Core::UsedMem += TexSize; Oyster::Graphics::Core::UsedMem += TexSize;
if ( autogen ) if ( autogen )

View File

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