GameClient - merged with all new things

This commit is contained in:
lindaandersson 2014-02-19 11:31:05 +01:00
commit 77ad199cf6
11 changed files with 263 additions and 64 deletions

View File

@ -204,6 +204,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" />
@ -231,6 +232,7 @@
<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" />

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()
{ {
@ -104,6 +108,7 @@ bool C_Object::InitRB(RBInitData RBInit)
RBposition = RBInit.position; RBposition = RBInit.position;
RBrotation = RBInit.rotation; RBrotation = RBInit.rotation;
RBscale = RBInit.scale; RBscale = RBInit.scale;
type = RBInit.type;
return true; return true;
} }
Oyster::Math::Float4x4 C_Object::getRBWorld() const Oyster::Math::Float4x4 C_Object::getRBWorld() const
@ -143,3 +148,4 @@ RB_Type C_Object::getBRtype()const
{ {
return this->type; return this->type;
} }
// !RB DEBUG

View File

@ -5,11 +5,22 @@ namespace DanBias
{ {
namespace Client namespace Client
{ {
// RB DEBUG
enum RB_Type enum RB_Type
{ {
RB_Type_Cube, RB_Type_Cube,
RB_Type_Sphere 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
{ {
int id; int id;
@ -19,13 +30,6 @@ namespace DanBias
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
bool visible; bool visible;
}; };
struct RBInitData
{
Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale;
RB_Type type;
};
class C_Object class C_Object
{ {
@ -40,6 +44,7 @@ namespace DanBias
Oyster::Math::Quaternion RBrotation; Oyster::Math::Quaternion RBrotation;
Oyster::Math::Float3 RBscale; Oyster::Math::Float3 RBscale;
RB_Type type; RB_Type type;
// !RB DEBUG
int id; int id;
@ -71,6 +76,8 @@ namespace DanBias
void setRBScale(Oyster::Math::Float3 newScale); void setRBScale(Oyster::Math::Float3 newScale);
Oyster::Math::Float3 getRBScale() const; Oyster::Math::Float3 getRBScale() const;
RB_Type getBRtype()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

@ -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,31 @@ 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) );
// Debugg hack
this->InitiatePlayer( 0, "crate_generic.dan",Float3( 0,132, 10), Quaternion::identity, Float3(1), true );
// end debug hack
// 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;
} }
@ -104,7 +125,8 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
RBInitData RBData; RBInitData RBData;
RBData.position = position; RBData.position = position;
RBData.rotation = ArrayToQuaternion( rotation ); RBData.rotation = ArrayToQuaternion( rotation );
RBData.scale = Float3( 3 ); RBData.scale = Float3( 1 );
// !RB DEBUG
if( isMyPlayer ) if( isMyPlayer )
{ {
@ -112,6 +134,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
{ {
// RB DEBUG // RB DEBUG
this->privData->player.InitRB( RBData ); 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() );
@ -128,6 +151,7 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
{ {
// RB DEBUG // RB DEBUG
this->privData->player.InitRB( RBData ); this->privData->player.InitRB( RBData );
// !RB DEBUG
(*this->privData->dynamicObjects)[id] = p; (*this->privData->dynamicObjects)[id] = p;
} }
@ -162,17 +186,25 @@ 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 // RB DEBUG render wire frame
if(this->privData->renderWhireframe)
{
Oyster::Graphics::API::StartRenderWireFrame(); Oyster::Graphics::API::StartRenderWireFrame();
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 2, 2, 2)); Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
Oyster::Math3D::Float4x4 world = translation * scale; Oyster::Math3D::Float4x4 world = translation * scale;
Oyster::Graphics::API::RenderDebugCube( world ); Oyster::Graphics::API::RenderDebugCube( world );
Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
staticObject = this->privData->staticObjects->begin();
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
{ {
if( staticObject->second->getBRtype() == RB_Type_Cube) if( staticObject->second->getBRtype() == RB_Type_Cube)
@ -185,7 +217,7 @@ bool GameState::Render()
} }
} }
dynamicObject = this->privData->dynamicObjects->begin();
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
{ {
if( dynamicObject->second->getBRtype() == RB_Type_Cube) if( dynamicObject->second->getBRtype() == RB_Type_Cube)
@ -197,6 +229,9 @@ bool GameState::Render()
Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld());
} }
} }
}
// !RB DEBUG
Oyster::Graphics::API::EndFrame(); Oyster::Graphics::API::EndFrame();
return true; return true;
} }
@ -217,8 +252,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;
} }
@ -276,21 +318,6 @@ 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 ); this->privData->camera.YawRight( this->privData->input->GetYaw() * 0.017f );
@ -356,6 +383,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
} }
@ -389,12 +445,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:
@ -407,6 +469,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:
@ -425,10 +490,15 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
} }
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;
@ -453,7 +523,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;
@ -461,6 +531,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

@ -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,8 +144,6 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
desc.scale = oh->scale; desc.scale = oh->scale;
desc.visible = true; desc.visible = true;
<<<<<<< HEAD
=======
// HACK: untill the world is right in lvl format // HACK: untill the world is right in lvl format
if( oh->specialTypeID == ObjectSpecialType_World) if( oh->specialTypeID == ObjectSpecialType_World)
{ {
@ -151,7 +152,6 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
desc.scale = Float3(300,300,300); desc.scale = Float3(300,300,300);
} }
>>>>>>> ed6825a40888474eb1b4a803085fbe4e073812f2
C_StaticObj *staticObject = new C_StaticObj(); C_StaticObj *staticObject = new C_StaticObj();
if( staticObject->Init( desc ) ) if( staticObject->Init( desc ) )
{ {
@ -163,6 +163,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
RBData.type = RB_Type_Cube;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
@ -171,8 +172,10 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
RBData.type = RB_Type_Sphere;
staticObject->InitRB( RBData ); staticObject->InitRB( RBData );
} }
// !RB DEBUG
(*this->privData->staticObjects)[objectID] = staticObject; (*this->privData->staticObjects)[objectID] = staticObject;
} }
@ -204,6 +207,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size;
RBData.type = RB_Type_Cube;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }
@ -212,8 +216,10 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position;
RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation
RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius;
RBData.type = RB_Type_Sphere;
dynamicObject->InitRB( RBData ); dynamicObject->InitRB( RBData );
} }
// !RB DEBUG
(*this->privData->dynamicObjects)[objectID] = dynamicObject; (*this->privData->dynamicObjects)[objectID] = dynamicObject;
} }
@ -225,12 +231,33 @@ 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;
} }
} }
// DEBUG added a static light for testing
Graphics::Definitions::Pointlight pointLight;
pointLight.Color = Float3(1,1,0);
pointLight.Pos = Float3( 0,132, 10);
pointLight.Bright = 2;
pointLight.Radius = 50;
C_Light *newLight = new C_Light( pointLight, objectID );
(*this->privData->lights)[objectID] = newLight;
this->privData->nextState = ClientState::ClientState_Game; this->privData->nextState = ClientState::ClientState_Game;
} }

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

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