diff --git a/Code/Game/GameClient/GameClient.vcxproj b/Code/Game/GameClient/GameClient.vcxproj
index 3daafff3..7a962975 100644
--- a/Code/Game/GameClient/GameClient.vcxproj
+++ b/Code/Game/GameClient/GameClient.vcxproj
@@ -202,6 +202,7 @@
+
@@ -227,6 +228,7 @@
+
diff --git a/Code/Game/GameClient/GameClientState/C_Light.cpp b/Code/Game/GameClient/GameClientState/C_Light.cpp
new file mode 100644
index 00000000..17016ae5
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/C_Light.cpp
@@ -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);
+}
diff --git a/Code/Game/GameClient/GameClientState/C_Light.h b/Code/Game/GameClient/GameClientState/C_Light.h
new file mode 100644
index 00000000..4802339d
--- /dev/null
+++ b/Code/Game/GameClient/GameClientState/C_Light.h
@@ -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
diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp
index 66b8fc61..59a16f6b 100644
--- a/Code/Game/GameClient/GameClientState/GameState.cpp
+++ b/Code/Game/GameClient/GameClientState/GameState.cpp
@@ -4,7 +4,7 @@
#include "NetworkClient.h"
#include "Camera_FPS.h"
#include
-
+#include "C_Light.h"
#include "C_obj/C_Player.h"
#include "C_obj/C_DynamicObj.h"
#include "C_obj/C_StaticObj.h"
@@ -28,6 +28,7 @@ struct GameState::MyData
::std::map> *staticObjects;
::std::map> *dynamicObjects;
+ ::std::map> *lights;
bool key_forward;
bool key_backward;
@@ -82,10 +83,11 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->input = shared.input;
this->privData->staticObjects = &shared.staticObjects;
this->privData->dynamicObjects = &shared.dynamicObjects;
+ this->privData->lights = &shared.lights;
Graphics::API::Option gfxOp = Graphics::API::GetOption();
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
- this->privData->camera.SetPerspectiveProjection( Math::pi/2, aspectRatio, 0.1f, 1000.0f );
+ this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
//tell server ready
@@ -100,6 +102,11 @@ bool GameState::Init( SharedStateContent &shared )
this->privData->renderWhireframe = false;
// !DEGUG KEYS
+ auto light = this->privData->lights->begin();
+ for( ; light != this->privData->lights->end(); ++light )
+ {
+ light->second->Render();
+ }
return true;
}
@@ -177,6 +184,13 @@ bool GameState::Render()
dynamicObject->second->Render();
}
+
+ /*auto light = this->privData->lights->begin();
+ for( ; light != this->privData->lights->end(); ++light )
+ {
+ light->second->Render();
+ }*/
+
// RB DEBUG render wire frame
if(this->privData->renderWhireframe)
{
@@ -236,8 +250,15 @@ bool GameState::Release()
dynamicObject->second = nullptr;
}
+ auto light = this->privData->lights->begin();
+ for( ; light != this->privData->lights->end(); ++light )
+ {
+ light->second->Render();
+ }
+
this->privData->staticObjects->clear();
this->privData->dynamicObjects->clear();
+ this->privData->lights->clear();
privData = NULL;
}
diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp
index 2fe143d6..2f8fbe6c 100644
--- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp
+++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp
@@ -6,6 +6,7 @@
#include "Utilities.h"
#include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h"
+#include "C_Light.h"
using namespace ::DanBias::Client;
using namespace ::Oyster;
@@ -23,6 +24,7 @@ struct NetLoadState::MyData
Graphics::API::Texture background;
::std::map> *staticObjects;
::std::map> *dynamicObjects;
+ ::std::map> *lights;
bool loading;
};
@@ -49,6 +51,7 @@ bool NetLoadState::Init( SharedStateContent &shared )
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
this->privData->dynamicObjects = &shared.dynamicObjects;
this->privData->staticObjects = &shared.staticObjects;
+ this->privData->lights = &shared.lights;
this->privData->loading = false;
@@ -214,12 +217,33 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
break;
case ObjectType::ObjectType_Light:
{
- /* TODO: implement light into the leveformat */
+ BasicLight *light = (BasicLight*)oth;
+ Graphics::Definitions::Pointlight pointLight;
+
+ pointLight.Color = light->color;
+ pointLight.Pos = light->position;
+ pointLight.Bright = light->intensity;
+ pointLight.Radius = light->raduis;
+
+ C_Light *newLight = new C_Light( pointLight, objectID );
+
+ (*this->privData->lights)[objectID] = newLight;
}
break;
default: break;
}
}
+ // 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;
}
diff --git a/Code/Game/GameClient/GameClientState/SharedStateContent.h b/Code/Game/GameClient/GameClientState/SharedStateContent.h
index da9dc759..49d01775 100644
--- a/Code/Game/GameClient/GameClientState/SharedStateContent.h
+++ b/Code/Game/GameClient/GameClientState/SharedStateContent.h
@@ -13,6 +13,7 @@
#include "C_Object.h"
#include "C_obj\C_StaticObj.h"
#include "C_obj\C_DynamicObj.h"
+#include "C_Light.h"
#include "NetworkClient.h"
#include "L_inputClass.h"
@@ -23,6 +24,7 @@ namespace DanBias { namespace Client
public:
::std::map> staticObjects;
::std::map> dynamicObjects;
+ ::std::map> lights;
::Oyster::Network::NetworkClient *network;
InputClass* input;
};
diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.user b/Code/OysterGraphics/OysterGraphics.vcxproj.user
index 3f030911..9a0b0ae0 100644
--- a/Code/OysterGraphics/OysterGraphics.vcxproj.user
+++ b/Code/OysterGraphics/OysterGraphics.vcxproj.user
@@ -1,6 +1,6 @@
- false
+ true
\ No newline at end of file