Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic
Conflicts: Code/Game/GameLogic/Game.cpp
This commit is contained in:
commit
4c1be4d807
|
@ -0,0 +1,334 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<diagram program="umlet" version="12.1">
|
||||||
|
<zoom_level>10</zoom_level>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>390</x>
|
||||||
|
<y>120</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>/C_Object/
|
||||||
|
</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>320</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>C_Player</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>440</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>C_StaticObj</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>200</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>C_DynamicObj</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>240</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>200</w>
|
||||||
|
<h>140</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;30;30;120;180;120</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>370</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>50</w>
|
||||||
|
<h>140</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;30;30;120</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>450</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>50</w>
|
||||||
|
<h>140</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;30;30;120</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>210</x>
|
||||||
|
<y>220</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>100</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>GameState
|
||||||
|
--
|
||||||
|
C_Object*
|
||||||
|
GameState
|
||||||
|
Camera
|
||||||
|
Client*</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>360</x>
|
||||||
|
<y>330</y>
|
||||||
|
<w>160</w>
|
||||||
|
<h>50</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>/GameClientState/
|
||||||
|
Is eighter game or lobby </panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>570</x>
|
||||||
|
<y>220</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>100</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>LobbyState
|
||||||
|
--
|
||||||
|
C_Object*
|
||||||
|
Camera
|
||||||
|
Client*</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>380</x>
|
||||||
|
<y>440</y>
|
||||||
|
<w>120</w>
|
||||||
|
<h>120</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>DanBiasGame
|
||||||
|
--
|
||||||
|
Client
|
||||||
|
Input
|
||||||
|
GameClientState
|
||||||
|
Window</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>400</x>
|
||||||
|
<y>350</y>
|
||||||
|
<w>50</w>
|
||||||
|
<h>110</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;90;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>230</x>
|
||||||
|
<y>290</y>
|
||||||
|
<w>150</w>
|
||||||
|
<h>80</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;30;30;60;130;60</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>490</x>
|
||||||
|
<y>290</y>
|
||||||
|
<w>150</w>
|
||||||
|
<h>80</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>130;30;130;60;30;60</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>560</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>C_UiObject</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>410</x>
|
||||||
|
<y>0</y>
|
||||||
|
<w>210</w>
|
||||||
|
<h>140</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<-</panel_attributes>
|
||||||
|
<additional_attributes>190;30;190;120;30;120</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>410</x>
|
||||||
|
<y>120</y>
|
||||||
|
<w>180</w>
|
||||||
|
<h>120</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<<-</panel_attributes>
|
||||||
|
<additional_attributes>160;100;30;100;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>280</x>
|
||||||
|
<y>120</y>
|
||||||
|
<w>170</w>
|
||||||
|
<h>120</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<<-</panel_attributes>
|
||||||
|
<additional_attributes>30;100;150;100;150;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>620</x>
|
||||||
|
<y>120</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>30</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Light</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>340</x>
|
||||||
|
<y>640</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>NetworkAPI
|
||||||
|
--</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>230</x>
|
||||||
|
<y>640</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>GraphicsAPI
|
||||||
|
--
|
||||||
|
</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>230</x>
|
||||||
|
<y>530</y>
|
||||||
|
<w>170</w>
|
||||||
|
<h>130</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>30;110;30;30;150;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>360</x>
|
||||||
|
<y>530</y>
|
||||||
|
<w>50</w>
|
||||||
|
<h>130</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>30;110;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>460</x>
|
||||||
|
<y>640</y>
|
||||||
|
<w>100</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>Input
|
||||||
|
--</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>460</x>
|
||||||
|
<y>530</y>
|
||||||
|
<w>50</w>
|
||||||
|
<h>130</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>30;110;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>120</x>
|
||||||
|
<y>520</y>
|
||||||
|
<w>110</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>DanBiasLancher
|
||||||
|
--</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Class</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>580</x>
|
||||||
|
<y>640</y>
|
||||||
|
<w>110</w>
|
||||||
|
<h>40</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>WindowManager
|
||||||
|
--</panel_attributes>
|
||||||
|
<additional_attributes/>
|
||||||
|
</element>
|
||||||
|
<element>
|
||||||
|
<type>com.umlet.element.Relation</type>
|
||||||
|
<coordinates>
|
||||||
|
<x>470</x>
|
||||||
|
<y>530</y>
|
||||||
|
<w>190</w>
|
||||||
|
<h>130</h>
|
||||||
|
</coordinates>
|
||||||
|
<panel_attributes>lt=<<.</panel_attributes>
|
||||||
|
<additional_attributes>170;110;170;30;30;30</additional_attributes>
|
||||||
|
</element>
|
||||||
|
</diagram>
|
|
@ -142,6 +142,7 @@ namespace DanBias
|
||||||
|
|
||||||
|
|
||||||
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
|
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
|
||||||
|
float DanBiasGame::capFrame = 0;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Interface API functions
|
// Interface API functions
|
||||||
|
@ -186,10 +187,16 @@ namespace DanBias
|
||||||
float dt = (float)m_data->timer->getElapsedSeconds();
|
float dt = (float)m_data->timer->getElapsedSeconds();
|
||||||
m_data->timer->reset();
|
m_data->timer->reset();
|
||||||
|
|
||||||
if(Update(dt) != S_OK)
|
capFrame += dt;
|
||||||
return DanBiasClientReturn_Error;
|
if(capFrame > 0.03)
|
||||||
if(Render(dt) != S_OK)
|
{
|
||||||
return DanBiasClientReturn_Error;
|
if(Update(dt) != S_OK)
|
||||||
|
return DanBiasClientReturn_Error;
|
||||||
|
if(Render(dt) != S_OK)
|
||||||
|
return DanBiasClientReturn_Error;
|
||||||
|
capFrame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return DanBiasClientReturn_Sucess;
|
return DanBiasClientReturn_Sucess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,16 @@ struct GameState::myData
|
||||||
Oyster::Network::NetworkClient* nwClient;
|
Oyster::Network::NetworkClient* nwClient;
|
||||||
gameStateState state;
|
gameStateState state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
GameState::GameState(void)
|
GameState::GameState(void)
|
||||||
{
|
{
|
||||||
|
key_forward = false;
|
||||||
|
key_backward = false;
|
||||||
|
key_strafeRight = false;
|
||||||
|
key_strafeLeft = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +66,8 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
|
|
||||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||||
|
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
||||||
|
modelData.world = modelData.world * translate;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||||
modelData.id = 0;
|
modelData.id = 0;
|
||||||
|
@ -68,7 +76,7 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
privData->object.push_back(obj);
|
privData->object.push_back(obj);
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
|
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
|
||||||
modelData.world = modelData.world * translate;
|
modelData.world = modelData.world * translate;
|
||||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||||
modelData.id ++;
|
modelData.id ++;
|
||||||
|
@ -121,24 +129,53 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_W))
|
if(KeyInput->IsKeyPressed(DIK_W))
|
||||||
{
|
{
|
||||||
movePlayer.bForward = true;
|
|
||||||
send = true;
|
if(!key_forward)
|
||||||
|
{
|
||||||
|
movePlayer.bForward = true;
|
||||||
|
send = true;
|
||||||
|
key_forward = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
key_forward = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_S))
|
if(KeyInput->IsKeyPressed(DIK_S))
|
||||||
{
|
{
|
||||||
movePlayer.bBackward = true;
|
if(!key_backward)
|
||||||
send = true;
|
{
|
||||||
|
movePlayer.bBackward = true;
|
||||||
|
send = true;
|
||||||
|
key_backward = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
key_backward = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_A))
|
if(KeyInput->IsKeyPressed(DIK_A))
|
||||||
{
|
{
|
||||||
movePlayer.bStrafeLeft = true;
|
if(!key_strafeLeft)
|
||||||
send = true;
|
{
|
||||||
|
movePlayer.bStrafeLeft = true;
|
||||||
|
send = true;
|
||||||
|
key_strafeLeft = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
key_strafeLeft = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_D))
|
if(KeyInput->IsKeyPressed(DIK_D))
|
||||||
{
|
{
|
||||||
movePlayer.bStrafeRight = true;
|
if(!key_strafeRight)
|
||||||
send = true;
|
{
|
||||||
|
movePlayer.bStrafeRight = true;
|
||||||
|
send = true;
|
||||||
|
key_strafeRight = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
key_strafeRight = false;
|
||||||
|
|
||||||
|
|
||||||
if (privData->nwClient->IsConnected() && send)
|
if (privData->nwClient->IsConnected() && send)
|
||||||
{
|
{
|
||||||
|
@ -227,21 +264,21 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::Protocol( NewObj* pos )
|
void GameState::Protocol( NewObj* newObj )
|
||||||
{
|
{
|
||||||
|
|
||||||
Oyster::Math::Float4x4 world;
|
Oyster::Math::Float4x4 world;
|
||||||
for(int i = 0; i<16; i++)
|
for(int i = 0; i<16; i++)
|
||||||
{
|
{
|
||||||
world[i] = pos->worldPos[i];
|
world[i] = newObj->worldPos[i];
|
||||||
}
|
}
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
|
|
||||||
modelData.world = world;
|
modelData.world = world;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.id = pos->object_ID;
|
modelData.id = newObj->object_ID;
|
||||||
//not sure if this is good parsing rom char* to wstring
|
//not sure if this is good parsing rom char* to wstring
|
||||||
const char* path = pos->path;
|
const char* path = newObj->path;
|
||||||
modelData.modelPath = std::wstring(path, path + strlen(path));
|
modelData.modelPath = std::wstring(path, path + strlen(path));
|
||||||
// load models
|
// load models
|
||||||
C_Object* player = new C_Player();
|
C_Object* player = new C_Player();
|
||||||
|
|
|
@ -16,7 +16,12 @@ class GameState : public GameClientState
|
||||||
gameStateState_end,
|
gameStateState_end,
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool key_forward;
|
||||||
|
bool key_backward;
|
||||||
|
bool key_strafeRight;
|
||||||
|
bool key_strafeLeft;
|
||||||
|
|
||||||
struct myData;
|
struct myData;
|
||||||
myData* privData;
|
myData* privData;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace DanBias
|
||||||
static HRESULT Render(float deltaTime);
|
static HRESULT Render(float deltaTime);
|
||||||
static HRESULT CleanUp();
|
static HRESULT CleanUp();
|
||||||
|
|
||||||
|
static float capFrame;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static DanBiasGamePrivateData* m_data;
|
static DanBiasGamePrivateData* m_data;
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,13 @@ namespace DanBias
|
||||||
Send(p.GetProtocol());
|
Send(p.GetProtocol());
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
if(GetAsyncKeyState(VK_DOWN))
|
||||||
|
{
|
||||||
|
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||||
|
Protocol_CreateObject p(world, 2, "../Content/crate");
|
||||||
|
Send(p.GetProtocol());
|
||||||
|
Sleep(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void GameSession::ParseEvents()
|
void GameSession::ParseEvents()
|
||||||
{
|
{
|
||||||
|
@ -159,16 +166,16 @@ namespace DanBias
|
||||||
|
|
||||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||||
if(p[1].value.netBool) //bool bForward;
|
if(p[1].value.netBool) //bool bForward;
|
||||||
world.v[3].x = 2;
|
world.v[3].y = 2;
|
||||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||||
if(p[2].value.netBool) //bool bBackward;
|
if(p[2].value.netBool) //bool bBackward;
|
||||||
world.v[3].x = -2;
|
world.v[3].y = -2;
|
||||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||||
if(p[5].value.netBool) //bool bStrafeRight;
|
if(p[5].value.netBool) //bool bStrafeRight;
|
||||||
world.v[3].y = 2;
|
world.v[3].x = -2;
|
||||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||||
world.v[3].y = -2;
|
world.v[3].x = 2;
|
||||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||||
|
|
||||||
Protocol_ObjectPosition res(world, 0);
|
Protocol_ObjectPosition res(world, 0);
|
||||||
|
|
|
@ -55,9 +55,13 @@ void Game::GetAllPlayerPos()
|
||||||
|
|
||||||
Game::PlayerData Game::CreatePlayer()
|
Game::PlayerData Game::CreatePlayer()
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
SmartPointer<Player> newPlayer = new Player();
|
SmartPointer<Player> newPlayer = new Player();
|
||||||
|
|
||||||
myData->players.Push(newPlayer);
|
myData->players.Push(newPlayer);
|
||||||
|
=======
|
||||||
|
return PlayerData();
|
||||||
|
>>>>>>> eb6ed13cceff0ce4380699391759883acf487107
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::CreateTeam()
|
void Game::CreateTeam()
|
||||||
|
|
|
@ -28,27 +28,47 @@ namespace GameLogic
|
||||||
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Protocol_CreateObject(float m[16], int id, char *path)
|
||||||
|
{
|
||||||
|
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_CreateObject;
|
||||||
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
|
||||||
|
for (int i = 3; i <= 18; i++)
|
||||||
|
{
|
||||||
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
}
|
||||||
|
|
||||||
|
object_ID = id;
|
||||||
|
this->path = path;
|
||||||
|
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
|
||||||
|
}
|
||||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
{
|
{
|
||||||
|
|
||||||
this->protocol[1].value = object_ID;
|
this->protocol[1].value = object_ID;
|
||||||
this->protocol[2].value = path;
|
this->protocol[2].value = path;
|
||||||
this->protocol[3].value = worldMatrix[1];
|
this->protocol[3].value = worldMatrix[0];
|
||||||
this->protocol[4].value = worldMatrix[2];
|
this->protocol[4].value = worldMatrix[1];
|
||||||
this->protocol[5].value = worldMatrix[3];
|
this->protocol[5].value = worldMatrix[2];
|
||||||
this->protocol[6].value = worldMatrix[4];
|
this->protocol[6].value = worldMatrix[3];
|
||||||
this->protocol[7].value = worldMatrix[5];
|
this->protocol[7].value = worldMatrix[4];
|
||||||
this->protocol[8].value = worldMatrix[6];
|
this->protocol[8].value = worldMatrix[5];
|
||||||
this->protocol[9].value = worldMatrix[7];
|
this->protocol[9].value = worldMatrix[6];
|
||||||
this->protocol[10].value = worldMatrix[8];
|
this->protocol[10].value = worldMatrix[7];
|
||||||
this->protocol[11].value = worldMatrix[9];
|
this->protocol[11].value = worldMatrix[8];
|
||||||
this->protocol[12].value = worldMatrix[10];
|
this->protocol[12].value = worldMatrix[9];
|
||||||
this->protocol[13].value = worldMatrix[11];
|
this->protocol[13].value = worldMatrix[10];
|
||||||
this->protocol[14].value = worldMatrix[12];
|
this->protocol[14].value = worldMatrix[11];
|
||||||
this->protocol[15].value = worldMatrix[13];
|
this->protocol[15].value = worldMatrix[12];
|
||||||
this->protocol[16].value = worldMatrix[14];
|
this->protocol[16].value = worldMatrix[13];
|
||||||
this->protocol[17].value = worldMatrix[15];
|
this->protocol[17].value = worldMatrix[14];
|
||||||
this->protocol[18].value = worldMatrix[16];
|
this->protocol[18].value = worldMatrix[15];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return &protocol;
|
return &protocol;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@ struct CustomNetProtocol::PrivateData
|
||||||
size_t size = strlen(i->second.value.netCharPtr);
|
size_t size = strlen(i->second.value.netCharPtr);
|
||||||
if(size == 0) continue;
|
if(size == 0) continue;
|
||||||
|
|
||||||
attributes[i->first];
|
|
||||||
attributes[i->first].value.netCharPtr = new char[size + 1];
|
attributes[i->first].value.netCharPtr = new char[size + 1];
|
||||||
//strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr);
|
//strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr);
|
||||||
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
|
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
|
||||||
|
attributes[i->first].type = NetAttributeType_CharArray;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "Dx11Includes.h"
|
#include "Dx11Includes.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,8 +52,15 @@ namespace Oyster
|
||||||
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload);
|
data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload);
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
VSMap[name] = VS.size();
|
if(ForceReload && VSMap.count(name))
|
||||||
VS.push_back((ID3D11VertexShader*)data);
|
{
|
||||||
|
VS[VSMap[name]] = (ID3D11VertexShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VSMap[name] = VS.size();
|
||||||
|
VS.push_back((ID3D11VertexShader*)data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -63,8 +70,16 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(data!=0)
|
if(data!=0)
|
||||||
{
|
{
|
||||||
HSMap[name] = HS.size();
|
if(ForceReload && HSMap.count(name))
|
||||||
HS.push_back((ID3D11HullShader*)data);
|
{
|
||||||
|
HS[HSMap[name]] = (ID3D11HullShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HSMap[name] = HS.size();
|
||||||
|
HS.push_back((ID3D11HullShader*)data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -74,8 +89,15 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(data!=0)
|
if(data!=0)
|
||||||
{
|
{
|
||||||
DSMap[name] = DS.size();
|
if(ForceReload && DSMap.count(name))
|
||||||
DS.push_back((ID3D11DomainShader*)data);
|
{
|
||||||
|
DS[DSMap[name]] = (ID3D11DomainShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DSMap[name] = DS.size();
|
||||||
|
DS.push_back((ID3D11DomainShader*)data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -85,8 +107,15 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(data!=0)
|
if(data!=0)
|
||||||
{
|
{
|
||||||
GSMap[name] = GS.size();
|
if(ForceReload && GSMap.count(name))
|
||||||
GS.push_back((ID3D11GeometryShader*)data);
|
{
|
||||||
|
GS[GSMap[name]] = (ID3D11GeometryShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GSMap[name] = GS.size();
|
||||||
|
GS.push_back((ID3D11GeometryShader*)data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -96,8 +125,15 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(data!=0)
|
if(data!=0)
|
||||||
{
|
{
|
||||||
PSMap[name] = PS.size();
|
if(ForceReload && PSMap.count(name))
|
||||||
PS.push_back((ID3D11PixelShader*)data);
|
{
|
||||||
|
PS[PSMap[name]] = (ID3D11PixelShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PSMap[name] = PS.size();
|
||||||
|
PS.push_back((ID3D11PixelShader*)data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -107,8 +143,16 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
if(data!=0)
|
if(data!=0)
|
||||||
{
|
{
|
||||||
CSMap[name] = CS.size();
|
if(ForceReload && CSMap.count(name))
|
||||||
CS.push_back((ID3D11ComputeShader*)data);
|
{
|
||||||
|
CS[CSMap[name]] = (ID3D11ComputeShader*)data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CSMap[name] = CS.size();
|
||||||
|
CS.push_back((ID3D11ComputeShader*)data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -375,9 +419,9 @@ namespace Oyster
|
||||||
|
|
||||||
void Core::PipelineManager::CleanPipeline()
|
void Core::PipelineManager::CleanPipeline()
|
||||||
{
|
{
|
||||||
deviceContext->VSSetShaderResources(0,16,Core::srvNULL);
|
//deviceContext->VSSetShaderResources(0,16,Core::srvNULL);
|
||||||
deviceContext->GSSetShaderResources(0,16,Core::srvNULL);
|
//deviceContext->GSSetShaderResources(0,16,Core::srvNULL);
|
||||||
deviceContext->PSSetShaderResources(0,16,Core::srvNULL);
|
//deviceContext->PSSetShaderResources(0,16,Core::srvNULL);
|
||||||
deviceContext->CSSetShaderResources(0,16,Core::srvNULL);
|
deviceContext->CSSetShaderResources(0,16,Core::srvNULL);
|
||||||
deviceContext->CSSetUnorderedAccessViews(0,8,Core::uavNULL,NULL);
|
deviceContext->CSSetUnorderedAccessViews(0,8,Core::uavNULL,NULL);
|
||||||
deviceContext->OMSetRenderTargets(8,Core::rtvNULL, NULL);
|
deviceContext->OMSetRenderTargets(8,Core::rtvNULL, NULL);
|
||||||
|
|
|
@ -20,6 +20,12 @@ namespace Oyster
|
||||||
Oyster::Math::Matrix P;
|
Oyster::Math::Matrix P;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PerModel
|
||||||
|
{
|
||||||
|
Math::Matrix WV;
|
||||||
|
Math::Matrix WVP;
|
||||||
|
};
|
||||||
|
|
||||||
struct FinalVertex
|
struct FinalVertex
|
||||||
{
|
{
|
||||||
Oyster::Math::Float3 pos;
|
Oyster::Math::Float3 pos;
|
||||||
|
@ -34,9 +40,10 @@ namespace Oyster
|
||||||
struct LightConstants
|
struct LightConstants
|
||||||
{
|
{
|
||||||
Math::Float4x4 InvProj;
|
Math::Float4x4 InvProj;
|
||||||
|
Math::Float4x4 Proj;
|
||||||
Math::Float2 Pixels;
|
Math::Float2 Pixels;
|
||||||
int Lights;
|
int Lights;
|
||||||
float Pad;
|
float SSAORadius;
|
||||||
Oyster::Math::Float4x4 View;
|
Oyster::Math::Float4x4 View;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../FileLoader/ObjReader.h"
|
#include "../FileLoader/ObjReader.h"
|
||||||
#include "../../Misc/Resource/OysterResource.h"
|
#include "../../Misc/Resource/OysterResource.h"
|
||||||
#include "../FileLoader/GeneralLoader.h"
|
#include "../FileLoader/GeneralLoader.h"
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -26,12 +27,6 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
return API::Fail;
|
return API::Fail;
|
||||||
}
|
}
|
||||||
#ifdef _DEBUG
|
|
||||||
if(Render::Resources::Debug::Init() == Core::Init::Fail)
|
|
||||||
{
|
|
||||||
return API::Fail;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Render::Resources::Deffered::Init();
|
Render::Resources::Deffered::Init();
|
||||||
|
|
||||||
Render::Preparations::Basic::SetViewPort();
|
Render::Preparations::Basic::SetViewPort();
|
||||||
|
@ -62,12 +57,12 @@ namespace Oyster
|
||||||
|
|
||||||
void API::RenderScene(Model::Model models[], int count)
|
void API::RenderScene(Model::Model models[], int count)
|
||||||
{
|
{
|
||||||
Render::Rendering::Basic::RenderScene(models,count);
|
Render::Rendering::Basic::RenderScene(models,count, View, Projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderModel(Model::Model& m)
|
void API::RenderModel(Model::Model& m)
|
||||||
{
|
{
|
||||||
Render::Rendering::Basic::RenderScene(&m,1);
|
Render::Rendering::Basic::RenderScene(&m,1, View, Projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::EndFrame()
|
void API::EndFrame()
|
||||||
|
@ -103,10 +98,6 @@ namespace Oyster
|
||||||
SAFE_DELETE(Core::viewPort);
|
SAFE_DELETE(Core::viewPort);
|
||||||
Oyster::Resource::OysterResource::Clean();
|
Oyster::Resource::OysterResource::Clean();
|
||||||
Oyster::Graphics::Core::PipelineManager::Clean();
|
Oyster::Graphics::Core::PipelineManager::Clean();
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
Oyster::Graphics::Render::Resources::Debug::Clean();
|
|
||||||
#endif
|
|
||||||
Oyster::Graphics::Render::Resources::Deffered::Clean();
|
Oyster::Graphics::Render::Resources::Deffered::Clean();
|
||||||
|
|
||||||
SAFE_RELEASE(Core::depthStencil);
|
SAFE_RELEASE(Core::depthStencil);
|
||||||
|
@ -128,5 +119,13 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
Lights.clear();
|
Lights.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
API::State API::ReloadShaders()
|
||||||
|
{
|
||||||
|
Render::Resources::Deffered::InitShaders();
|
||||||
|
return State::Sucsess;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
#include "..\Model\Model.h"
|
#include "..\Model\Model.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
//#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
#ifdef GFX_DLL_EXPORT
|
#ifdef GFX_DLL_EXPORT
|
||||||
#define GFX_DLL_USAGE __declspec(dllexport)
|
#define GFX_DLL_USAGE __declspec(dllexport)
|
||||||
|
@ -29,23 +29,40 @@ namespace Oyster
|
||||||
};
|
};
|
||||||
|
|
||||||
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
|
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
|
||||||
|
#ifdef _DEBUG
|
||||||
|
static State ReloadShaders();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! @todo Memory Leaks
|
||||||
|
|
||||||
|
//! @brief Clean Resources and release all memory
|
||||||
static void Clean();
|
static void Clean();
|
||||||
|
|
||||||
|
//! @brief Sets the view matrix to use next frame
|
||||||
static void SetView(Oyster::Math::Float4x4& View);
|
static void SetView(Oyster::Math::Float4x4& View);
|
||||||
|
//! @brief Sets the projection matrix to use next frame
|
||||||
static void SetProjection(Oyster::Math::Float4x4& Projection);
|
static void SetProjection(Oyster::Math::Float4x4& Projection);
|
||||||
|
|
||||||
//! @brief will internally use last values from SetView and SetProjection
|
//! @brief will internally use last values from SetView and SetProjection
|
||||||
static void NewFrame();
|
static void NewFrame();
|
||||||
|
//! @brief Renders a list of models
|
||||||
static void RenderScene(Oyster::Graphics::Model::Model models[], int count);
|
static void RenderScene(Oyster::Graphics::Model::Model models[], int count);
|
||||||
|
//! @brief Renders a single model
|
||||||
static void RenderModel(Oyster::Graphics::Model::Model& model);
|
static void RenderModel(Oyster::Graphics::Model::Model& model);
|
||||||
|
//! @brief Performs light calculations, post effects and presents the scene
|
||||||
static void EndFrame();
|
static void EndFrame();
|
||||||
|
|
||||||
|
//! @brief Creates a model from the supplied file, note: do not include .obj
|
||||||
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
|
static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename);
|
||||||
|
//! @brief deletes a model and relases the models resources
|
||||||
static void DeleteModel(Oyster::Graphics::Model::Model* model);
|
static void DeleteModel(Oyster::Graphics::Model::Model* model);
|
||||||
|
|
||||||
|
//! @brief adds a light to the scene
|
||||||
static void AddLight(Definitions::Pointlight light);
|
static void AddLight(Definitions::Pointlight light);
|
||||||
|
//! @brief removes all lights from the scene
|
||||||
static void ClearLights();
|
static void ClearLights();
|
||||||
|
|
||||||
|
//! @brief Sets Options to the graphics, note: currently unused
|
||||||
static State SetOptions(Option);
|
static State SetOptions(Option);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,12 @@ void Oyster::Graphics::Loading::UnloadTexture(void* data)
|
||||||
|
|
||||||
void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out)
|
||||||
{
|
{
|
||||||
FileLoaders::ObjReader* obj = FileLoaders::ObjReader::LoadFile(filename);
|
FileLoaders::ObjReader obj;
|
||||||
|
obj.LoadFile(filename);
|
||||||
Model::ModelInfo* info = new Model::ModelInfo();
|
Model::ModelInfo* info = new Model::ModelInfo();
|
||||||
Oyster::FileLoaders::ObjReader::Vertex* vdata;
|
Oyster::FileLoaders::ObjReader::Vertex* vdata;
|
||||||
int count;
|
int count;
|
||||||
obj->GetVertexData(&vdata, count);
|
obj.GetVertexData(&vdata, count);
|
||||||
info->Vertices = new Core::Buffer();
|
info->Vertices = new Core::Buffer();
|
||||||
Core::Buffer::BUFFER_INIT_DESC desc;
|
Core::Buffer::BUFFER_INIT_DESC desc;
|
||||||
desc.ElementSize = sizeof(FileLoaders::ObjReader::Vertex);
|
desc.ElementSize = sizeof(FileLoaders::ObjReader::Vertex);
|
||||||
|
|
|
@ -3,31 +3,16 @@
|
||||||
#include "..\Core\Core.h"
|
#include "..\Core\Core.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Oyster::FileLoaders;
|
using namespace Oyster::FileLoaders;
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
using namespace Oyster::Math;
|
using namespace Oyster::Math;
|
||||||
|
|
||||||
ObjReader *ObjReader::LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform)
|
void ObjReader::LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform)
|
||||||
{
|
{
|
||||||
static std::map<std::wstring, ObjReader *> cache;
|
this->ParseFile(fileName + L".obj", transform);
|
||||||
|
|
||||||
ObjReader *reader = NULL;
|
|
||||||
|
|
||||||
if (cache.count(fileName))
|
|
||||||
{
|
|
||||||
reader = cache[fileName];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader = new ObjReader();
|
|
||||||
reader->ParseFile(fileName + L".obj", transform);
|
|
||||||
|
|
||||||
cache[fileName] = reader;
|
|
||||||
}
|
|
||||||
|
|
||||||
return reader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjReader::ObjReader(void)
|
ObjReader::ObjReader(void)
|
||||||
|
@ -37,6 +22,7 @@ ObjReader::ObjReader(void)
|
||||||
|
|
||||||
ObjReader::~ObjReader(void)
|
ObjReader::~ObjReader(void)
|
||||||
{
|
{
|
||||||
|
SAFE_DELETE_ARRAY(this->vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
|
void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
|
||||||
|
@ -50,7 +36,6 @@ void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
wstring path;
|
wstring path;
|
||||||
//Utility::String::ExtractDirPath(path,fileName,'\\');
|
|
||||||
|
|
||||||
std::vector<Vertex> VertexList;
|
std::vector<Vertex> VertexList;
|
||||||
std::vector<Float3> vList;
|
std::vector<Float3> vList;
|
||||||
|
@ -74,6 +59,7 @@ void ObjReader::ParseFile(std::wstring fileName, Float4x4 transform)
|
||||||
if(c==L"v")
|
if(c==L"v")
|
||||||
{
|
{
|
||||||
position = readVertex(offset,s);
|
position = readVertex(offset,s);
|
||||||
|
//position *= 0.001f;
|
||||||
vList.push_back(position);
|
vList.push_back(position);
|
||||||
}
|
}
|
||||||
else if(c==L"vt")
|
else if(c==L"vt")
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Oyster
|
||||||
Oyster::Math::Float3 Normal;
|
Oyster::Math::Float3 Normal;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ObjReader *LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
void LoadFile(std::wstring fileName, Oyster::Math::Float4x4 transform = Oyster::Math::Float4x4::identity);
|
||||||
|
|
||||||
ObjReader(void);
|
ObjReader(void);
|
||||||
~ObjReader(void);
|
~ObjReader(void);
|
||||||
|
|
|
@ -182,7 +182,6 @@
|
||||||
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
|
||||||
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
|
||||||
<ClCompile Include="Render\Resources\Deffered.cpp" />
|
<ClCompile Include="Render\Resources\Deffered.cpp" />
|
||||||
<ClCompile Include="Render\Resources\Debug.cpp" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Core\Core.h" />
|
<ClInclude Include="Core\Core.h" />
|
||||||
|
@ -196,7 +195,6 @@
|
||||||
<ClInclude Include="Render\Rendering\Render.h" />
|
<ClInclude Include="Render\Rendering\Render.h" />
|
||||||
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
<ClInclude Include="Definitions\GraphicalDefinition.h" />
|
||||||
<ClInclude Include="Render\Resources\Deffered.h" />
|
<ClInclude Include="Render\Resources\Deffered.h" />
|
||||||
<ClInclude Include="Render\Resources\Debug.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\Misc\Misc.vcxproj">
|
||||||
|
@ -219,6 +217,16 @@
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\PostPass.hlsl">
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">5.0</ShaderModel>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||||
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
|
||||||
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">5.0</ShaderModel>
|
||||||
|
</FxCompile>
|
||||||
<FxCompile Include="Shader\HLSL\Deffered Shaders\VertexGatherData.hlsl">
|
<FxCompile Include="Shader\HLSL\Deffered Shaders\VertexGatherData.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
|
||||||
|
@ -268,6 +276,7 @@
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\GBufferHeader.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\GBufferHeader.hlsli" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\LightCalc.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\LightCalc.hlsli" />
|
||||||
<None Include="Shader\HLSL\Deffered Shaders\PosManipulation.hlsli" />
|
<None Include="Shader\HLSL\Deffered Shaders\PosManipulation.hlsli" />
|
||||||
|
<None Include="Shader\HLSL\Deffered Shaders\SSAO.hlsli" />
|
||||||
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace Oyster
|
||||||
lc.Pixels = Core::resolution;
|
lc.Pixels = Core::resolution;
|
||||||
lc.Lights = numLights;
|
lc.Lights = numLights;
|
||||||
lc.View = View;
|
lc.View = View;
|
||||||
|
lc.Proj = Projection;
|
||||||
|
lc.SSAORadius = 3;
|
||||||
|
|
||||||
data = Resources::Deffered::LightConstantsData.Map();
|
data = Resources::Deffered::LightConstantsData.Map();
|
||||||
memcpy(data, &lc, sizeof(Definitions::LightConstants));
|
memcpy(data, &lc, sizeof(Definitions::LightConstants));
|
||||||
|
@ -44,14 +46,18 @@ namespace Oyster
|
||||||
Resources::Deffered::PointLightsData.Unmap();
|
Resources::Deffered::PointLightsData.Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basic::RenderScene(Model::Model* models, int count)
|
void Basic::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < count; ++i)
|
for(int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
if(models[i].Visible)
|
if(models[i].Visible)
|
||||||
{
|
{
|
||||||
|
Definitions::PerModel pm;
|
||||||
|
pm.WV = View * models[i].WorldMatrix;
|
||||||
|
pm.WVP = Projection * pm.WV;
|
||||||
|
|
||||||
void* data = Resources::Deffered::ModelData.Map();
|
void* data = Resources::Deffered::ModelData.Map();
|
||||||
memcpy(data,&(models[i].WorldMatrix),sizeof(Math::Float4x4));
|
memcpy(data,&(pm),sizeof(pm));
|
||||||
Resources::Deffered::ModelData.Unmap();
|
Resources::Deffered::ModelData.Unmap();
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +88,10 @@ namespace Oyster
|
||||||
|
|
||||||
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
|
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
|
||||||
|
|
||||||
|
Core::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
|
||||||
|
|
||||||
|
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
|
||||||
|
|
||||||
Core::swapChain->Present(0,0);
|
Core::swapChain->Present(0,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
|
static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights);
|
||||||
static void RenderScene(Model::Model* models, int count);
|
static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection);
|
||||||
static void EndFrame();
|
static void EndFrame();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ typedef Oyster::Graphics::Core::Buffer Buffer;
|
||||||
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\Deffered Shaders\\";
|
const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\Deffered Shaders\\";
|
||||||
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
|
const std::wstring PathToCSO = L"..\\Content\\Shaders\\";
|
||||||
|
|
||||||
|
const int KernelSize = 10;
|
||||||
|
const int SampleSpread = 8;
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
namespace Graphics
|
namespace Graphics
|
||||||
|
@ -20,12 +23,15 @@ namespace Oyster
|
||||||
namespace Resources
|
namespace Resources
|
||||||
{
|
{
|
||||||
|
|
||||||
ID3D11RenderTargetView* Deffered::GBufferRTV[2] = {0};
|
ID3D11RenderTargetView* Deffered::GBufferRTV[Deffered::GBufferSize] = {0};
|
||||||
ID3D11ShaderResourceView* Deffered::GBufferSRV[2] = {0};
|
ID3D11ShaderResourceView* Deffered::GBufferSRV[Deffered::GBufferSize] = {0};
|
||||||
|
|
||||||
|
ID3D11UnorderedAccessView* Deffered::LBufferUAV[Deffered::LBufferSize] = {0};
|
||||||
|
ID3D11ShaderResourceView* Deffered::LBufferSRV[Deffered::LBufferSize] = {0};
|
||||||
|
|
||||||
Shader::RenderPass Deffered::GeometryPass;
|
Shader::RenderPass Deffered::GeometryPass;
|
||||||
Shader::RenderPass Deffered::LightPass;
|
Shader::RenderPass Deffered::LightPass;
|
||||||
|
Shader::RenderPass Deffered::PostPass;
|
||||||
|
|
||||||
Buffer Deffered::ModelData = Buffer();
|
Buffer Deffered::ModelData = Buffer();
|
||||||
Buffer Deffered::VPData = Buffer();
|
Buffer Deffered::VPData = Buffer();
|
||||||
|
@ -34,9 +40,12 @@ namespace Oyster
|
||||||
Buffer Deffered::PointLightsData = Buffer();
|
Buffer Deffered::PointLightsData = Buffer();
|
||||||
ID3D11ShaderResourceView* Deffered::PointLightView = NULL;
|
ID3D11ShaderResourceView* Deffered::PointLightView = NULL;
|
||||||
|
|
||||||
Core::Init::State Deffered::Init()
|
ID3D11ShaderResourceView* Deffered::SSAOKernel = NULL;
|
||||||
|
ID3D11ShaderResourceView* Deffered::SSAORandom = NULL;
|
||||||
|
|
||||||
|
Core::Init::State Deffered::InitShaders()
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
std::wstring path = PathToHLSL;
|
std::wstring path = PathToHLSL;
|
||||||
std::wstring end = L".hlsl";
|
std::wstring end = L".hlsl";
|
||||||
#else
|
#else
|
||||||
|
@ -47,10 +56,17 @@ namespace Oyster
|
||||||
Core::PipelineManager::Init(path + L"PixelGatherData" + end, ShaderType::Pixel, L"Geometry");
|
Core::PipelineManager::Init(path + L"PixelGatherData" + end, ShaderType::Pixel, L"Geometry");
|
||||||
Core::PipelineManager::Init(path + L"VertexGatherData" + end, ShaderType::Vertex, L"Geometry");
|
Core::PipelineManager::Init(path + L"VertexGatherData" + end, ShaderType::Vertex, L"Geometry");
|
||||||
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
|
Core::PipelineManager::Init(path + L"LightPass" + end, ShaderType::Compute, L"LightPass");
|
||||||
|
Core::PipelineManager::Init(path + L"PostPass" + end, ShaderType::Compute, L"PostPass");
|
||||||
|
return Core::Init::State::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Init::State Deffered::Init()
|
||||||
|
{
|
||||||
|
InitShaders();
|
||||||
|
|
||||||
//Create Buffers
|
//Create Buffers
|
||||||
Buffer::BUFFER_INIT_DESC desc;
|
Buffer::BUFFER_INIT_DESC desc;
|
||||||
desc.ElementSize = sizeof(Oyster::Math::Matrix);
|
desc.ElementSize = sizeof(Definitions::PerModel);
|
||||||
desc.NumElements = 1;
|
desc.NumElements = 1;
|
||||||
desc.InitData = NULL;
|
desc.InitData = NULL;
|
||||||
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_VS;
|
||||||
|
@ -72,7 +88,7 @@ namespace Oyster
|
||||||
desc.Type = Buffer::STRUCTURED_BUFFER;
|
desc.Type = Buffer::STRUCTURED_BUFFER;
|
||||||
PointLightsData.Init(desc);
|
PointLightsData.Init(desc);
|
||||||
|
|
||||||
//Create States
|
////Create States
|
||||||
D3D11_RASTERIZER_DESC rdesc;
|
D3D11_RASTERIZER_DESC rdesc;
|
||||||
rdesc.CullMode = D3D11_CULL_BACK;
|
rdesc.CullMode = D3D11_CULL_BACK;
|
||||||
rdesc.FillMode = D3D11_FILL_SOLID;
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
||||||
|
@ -131,11 +147,82 @@ namespace Oyster
|
||||||
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
|
Core::Init::CreateLinkedShaderResourceFromTexture(&GBufferRTV[i],&GBufferSRV[i],NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < Resources::Deffered::LBufferSize; ++i)
|
||||||
|
{
|
||||||
|
Core::Init::CreateLinkedShaderResourceFromTexture(NULL,&LBufferSRV[i],&LBufferUAV[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Buffer* b = &PointLightsData;
|
Buffer* b = &PointLightsData;
|
||||||
|
|
||||||
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
|
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
|
||||||
|
srand(time(0));
|
||||||
|
//SSAO
|
||||||
|
Math::Vector3 kernel[KernelSize];
|
||||||
|
Math::Vector3 random[SampleSpread];
|
||||||
|
for(int i = 0;i < KernelSize; ++i)
|
||||||
|
{
|
||||||
|
kernel[i] = Oyster::Math::Vector3::null;
|
||||||
|
while( kernel[i] == Oyster::Math::Vector3::null )
|
||||||
|
{
|
||||||
|
kernel[i] = Oyster::Math::Vector3(
|
||||||
|
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
||||||
|
(float)rand() / (RAND_MAX + 1) * (1 - -1) + -1,
|
||||||
|
(float)rand() / (RAND_MAX + 1) * (1 - 0) + 0);
|
||||||
|
}
|
||||||
|
kernel[i].Normalize();
|
||||||
|
|
||||||
//Create ShaderEffects
|
float scale = float(i) / float(KernelSize);
|
||||||
|
|
||||||
|
scale = (0.1f*(1 - scale * scale) + 1.0f *( scale * scale));
|
||||||
|
kernel[i] *= scale;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for( int i = 0; i < SampleSpread; ++i)
|
||||||
|
{
|
||||||
|
random[i] = Oyster::Math::Vector3::null;
|
||||||
|
while( random[i] == Oyster::Math::Vector3::null )
|
||||||
|
{
|
||||||
|
random[i] = Oyster::Math::Vector3(
|
||||||
|
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
|
||||||
|
(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,
|
||||||
|
0.0f);
|
||||||
|
}
|
||||||
|
random[i].Normalize();
|
||||||
|
}
|
||||||
|
//kernel[0] = Math::Vector3(0,1,1);
|
||||||
|
//kernel[0].Normalize();
|
||||||
|
|
||||||
|
D3D11_TEXTURE1D_DESC T1desc;
|
||||||
|
T1desc.Width = KernelSize;
|
||||||
|
T1desc.MipLevels = T1desc.ArraySize = 1;
|
||||||
|
T1desc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
|
T1desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
T1desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
T1desc.CPUAccessFlags = 0;
|
||||||
|
T1desc.MiscFlags = 0;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA sphere;
|
||||||
|
sphere.pSysMem = kernel;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA rnd;
|
||||||
|
rnd.pSysMem = random;
|
||||||
|
|
||||||
|
ID3D11Texture1D *pTexture1[2];
|
||||||
|
|
||||||
|
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1[0] );
|
||||||
|
Core::device->CreateShaderResourceView( pTexture1[0], 0, &SSAOKernel );
|
||||||
|
pTexture1[0]->Release();
|
||||||
|
|
||||||
|
T1desc.Width = SampleSpread;
|
||||||
|
Core::device->CreateTexture1D( &T1desc, &rnd, &pTexture1[1] );
|
||||||
|
Core::device->CreateShaderResourceView( (pTexture1[1]), 0, &SSAORandom );
|
||||||
|
pTexture1[1]->Release();
|
||||||
|
|
||||||
|
////Create ShaderEffects
|
||||||
|
|
||||||
|
////---------------- Geometry Pass Setup ----------------------------
|
||||||
GeometryPass.Shaders.Pixel = GetShader::Pixel(L"Geometry");
|
GeometryPass.Shaders.Pixel = GetShader::Pixel(L"Geometry");
|
||||||
GeometryPass.Shaders.Vertex = GetShader::Vertex(L"Geometry");
|
GeometryPass.Shaders.Vertex = GetShader::Vertex(L"Geometry");
|
||||||
|
|
||||||
|
@ -161,8 +248,12 @@ namespace Oyster
|
||||||
}
|
}
|
||||||
GeometryPass.depth = Core::depthStencil;
|
GeometryPass.depth = Core::depthStencil;
|
||||||
|
|
||||||
|
////---------------- Light Pass Setup ----------------------------
|
||||||
LightPass.Shaders.Compute = GetShader::Compute(L"LightPass");
|
LightPass.Shaders.Compute = GetShader::Compute(L"LightPass");
|
||||||
LightPass.UAV.Compute.push_back(Core::backBufferUAV);
|
for(int i = 0; i<Deffered::LBufferSize;++i)
|
||||||
|
{
|
||||||
|
LightPass.UAV.Compute.push_back(LBufferUAV[i]);
|
||||||
|
}
|
||||||
for(int i = 0; i<Deffered::GBufferSize;++i)
|
for(int i = 0; i<Deffered::GBufferSize;++i)
|
||||||
{
|
{
|
||||||
LightPass.SRV.Compute.push_back(GBufferSRV[i]);
|
LightPass.SRV.Compute.push_back(GBufferSRV[i]);
|
||||||
|
@ -170,7 +261,16 @@ namespace Oyster
|
||||||
LightPass.SRV.Compute.push_back(Core::depthStencilUAV);
|
LightPass.SRV.Compute.push_back(Core::depthStencilUAV);
|
||||||
LightPass.CBuffers.Compute.push_back(LightConstantsData);
|
LightPass.CBuffers.Compute.push_back(LightConstantsData);
|
||||||
LightPass.SRV.Compute.push_back(PointLightView);
|
LightPass.SRV.Compute.push_back(PointLightView);
|
||||||
|
LightPass.SRV.Compute.push_back(SSAOKernel);
|
||||||
|
LightPass.SRV.Compute.push_back(SSAORandom);
|
||||||
|
|
||||||
|
////---------------- Post Pass Setup ----------------------------
|
||||||
|
PostPass.Shaders.Compute = GetShader::Compute(L"PostPass");
|
||||||
|
for(int i = 0; i<Deffered::LBufferSize;++i)
|
||||||
|
{
|
||||||
|
PostPass.SRV.Compute.push_back(LBufferSRV[i]);
|
||||||
|
}
|
||||||
|
PostPass.UAV.Compute.push_back(Core::backBufferUAV);
|
||||||
|
|
||||||
return Core::Init::State::Success;
|
return Core::Init::State::Success;
|
||||||
}
|
}
|
||||||
|
@ -181,6 +281,9 @@ namespace Oyster
|
||||||
Resources::Deffered::VPData.~Buffer();
|
Resources::Deffered::VPData.~Buffer();
|
||||||
Resources::Deffered::LightConstantsData.~Buffer();
|
Resources::Deffered::LightConstantsData.~Buffer();
|
||||||
Resources::Deffered::PointLightsData.~Buffer();
|
Resources::Deffered::PointLightsData.~Buffer();
|
||||||
|
SAFE_RELEASE(Resources::Deffered::PointLightView);
|
||||||
|
SAFE_RELEASE(Deffered::SSAOKernel);
|
||||||
|
SAFE_RELEASE(Deffered::SSAORandom);
|
||||||
|
|
||||||
for(int i = 0; i< GBufferSize; ++i)
|
for(int i = 0; i< GBufferSize; ++i)
|
||||||
{
|
{
|
||||||
|
@ -188,22 +291,10 @@ namespace Oyster
|
||||||
SAFE_RELEASE(GBufferSRV[i]);
|
SAFE_RELEASE(GBufferSRV[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i< LBufferSize; ++i)
|
||||||
for(int i = 0; i < (int)GeometryPass.CBuffers.Vertex.size(); ++i)
|
|
||||||
{
|
{
|
||||||
SAFE_RELEASE(GeometryPass.CBuffers.Vertex[i]);
|
SAFE_RELEASE(LBufferUAV[i]);
|
||||||
}
|
SAFE_RELEASE(LBufferSRV[i]);
|
||||||
for(int i = 0; i < (int)GeometryPass.CBuffers.Pixel.size(); ++i)
|
|
||||||
{
|
|
||||||
SAFE_RELEASE(GeometryPass.CBuffers.Pixel[i]);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < (int)GeometryPass.CBuffers.Geometry.size(); ++i)
|
|
||||||
{
|
|
||||||
SAFE_RELEASE(GeometryPass.CBuffers.Geometry[i]);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < (int)GeometryPass.CBuffers.Compute.size(); ++i)
|
|
||||||
{
|
|
||||||
SAFE_RELEASE(GeometryPass.CBuffers.Compute[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_RELEASE(GeometryPass.IAStage.Layout);
|
SAFE_RELEASE(GeometryPass.IAStage.Layout);
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const int GBufferSize = 2;
|
static const int GBufferSize = 2;
|
||||||
|
static const int LBufferSize = 3;
|
||||||
static const int MaxLightSize = 100;
|
static const int MaxLightSize = 100;
|
||||||
//! GBuffers
|
//! GBuffers
|
||||||
//! 0 = Diffuse + SpecKoeff
|
//! 0 = Diffuse + SpecKoeff
|
||||||
|
@ -22,8 +23,14 @@ namespace Oyster
|
||||||
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
|
static ID3D11RenderTargetView* GBufferRTV[GBufferSize];
|
||||||
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
|
static ID3D11ShaderResourceView* GBufferSRV[GBufferSize];
|
||||||
|
|
||||||
|
|
||||||
|
static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize];
|
||||||
|
static ID3D11ShaderResourceView* LBufferSRV[LBufferSize];
|
||||||
|
|
||||||
static Core::PipelineManager::RenderPass GeometryPass;
|
static Core::PipelineManager::RenderPass GeometryPass;
|
||||||
static Core::PipelineManager::RenderPass LightPass;
|
static Core::PipelineManager::RenderPass LightPass;
|
||||||
|
static Core::PipelineManager::RenderPass PostPass;
|
||||||
|
|
||||||
|
|
||||||
static Core::Buffer ModelData;
|
static Core::Buffer ModelData;
|
||||||
static Core::Buffer VPData;
|
static Core::Buffer VPData;
|
||||||
|
@ -33,7 +40,12 @@ namespace Oyster
|
||||||
static Core::Buffer PointLightsData;
|
static Core::Buffer PointLightsData;
|
||||||
static ID3D11ShaderResourceView* PointLightView;
|
static ID3D11ShaderResourceView* PointLightView;
|
||||||
|
|
||||||
|
static ID3D11ShaderResourceView* SSAOKernel;
|
||||||
|
|
||||||
|
static ID3D11ShaderResourceView* SSAORandom;
|
||||||
|
|
||||||
static Core::Init::State Init();
|
static Core::Init::State Init();
|
||||||
|
static Core::Init::State InitShaders();
|
||||||
static void Clean();
|
static void Clean();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,22 +15,27 @@ struct DiffSpec
|
||||||
float3 Specular;
|
float3 Specular;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer LightConstants : register(b0)
|
cbuffer LightConstants : register(b0)
|
||||||
{
|
{
|
||||||
float4x4 InvProj;
|
float4x4 InvProj;
|
||||||
|
float4x4 Proj;
|
||||||
float2 Pixels;
|
float2 Pixels;
|
||||||
int Lights;
|
int Lights;
|
||||||
float Pad;
|
float SSAORadius;
|
||||||
float4x4 View;
|
float4x4 View;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D DiffuseGlow : register(t0);
|
Texture2D DiffuseGlow : register(t0);
|
||||||
Texture2D NormalSpec : register(t1);
|
Texture2D NormalSpec : register(t1);
|
||||||
Texture2D DepthTexture : register(t2);
|
Texture2D DepthTexture : register(t2);
|
||||||
|
|
||||||
|
StructuredBuffer<PointLight> Points : register(t3);
|
||||||
|
|
||||||
StructuredBuffer<PointLight> Points : register(t3);
|
Texture1D SSAOKernel : register(t4);
|
||||||
|
Texture1D SSAORand : register(t5);
|
||||||
|
|
||||||
RWTexture2D<float4> Output : register(u0);
|
RWTexture2D<float4> Diffuse : register(u0);
|
||||||
|
RWTexture2D<float4> Specular : register(u1);
|
||||||
|
RWTexture2D<float> Ambient : register(u2);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -39,5 +39,6 @@ cbuffer PerFrame : register(b0)
|
||||||
|
|
||||||
cbuffer PerModel : register(b1)
|
cbuffer PerModel : register(b1)
|
||||||
{
|
{
|
||||||
matrix World;
|
matrix WV;
|
||||||
|
matrix WVP;
|
||||||
}
|
}
|
|
@ -14,9 +14,8 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
|
||||||
float specFactor = pow(max(dot(v,normalize(-pos)), 0.0f),normalSpec.w);
|
float specFactor = pow(max(dot(v,normalize(-pos)), 0.0f),normalSpec.w);
|
||||||
//Check att later
|
//Check att later
|
||||||
float att = max( 0, 1 - (d / pl.Radius));
|
float att = max( 0, 1 - (d / pl.Radius));
|
||||||
//att = 1;
|
|
||||||
//fix Ilum calcs instead of PhongBlinn
|
//fix Ilum calcs instead of PhongBlinn
|
||||||
output.Diffuse = pl.Bright * att * diffFactor * pl.Color;
|
output.Diffuse = pl.Bright * att * diffFactor * pl.Color;
|
||||||
output.Specular = pl.Bright * att * specFactor * pl.Color;
|
output.Specular = pl.Bright * att * specFactor * pl.Color;
|
||||||
if(diffFactor == 0)
|
if(diffFactor == 0)
|
||||||
output.Specular * 0;
|
output.Specular * 0;
|
||||||
|
|
|
@ -1,31 +1,40 @@
|
||||||
#include "Defines.hlsli"
|
#include "Defines.hlsli"
|
||||||
#include "LightCalc.hlsli"
|
#include "LightCalc.hlsli"
|
||||||
#include "PosManipulation.hlsli"
|
#include "PosManipulation.hlsli"
|
||||||
|
#include "SSAO.hlsli"
|
||||||
//todo
|
//todo
|
||||||
//LightCulling
|
//LightCulling
|
||||||
//Calc Diff + Spec
|
//Calc Diff + Spec Done
|
||||||
//Calc Ambience
|
//Calc Ambience Done
|
||||||
//Write Glow
|
//Write Glow
|
||||||
|
|
||||||
|
|
||||||
[numthreads(16, 16, 1)]
|
[numthreads(16, 16, 1)]
|
||||||
void main( uint3 DTid : SV_DispatchThreadID )
|
void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
|
||||||
{
|
{
|
||||||
float3 ViewPos = ToVpos(DTid.xy);
|
float2 UV = DTid / Pixels;
|
||||||
|
UV.x = UV.x * 2 - 1;
|
||||||
|
UV.y = 1 - 2 * UV.y;
|
||||||
|
float3 ViewPos = ToVpos(DTid.xy, UV);
|
||||||
DiffSpec Shaded;
|
DiffSpec Shaded;
|
||||||
Shaded.Diffuse = float4(0,0,0,0);
|
Shaded.Diffuse = float4(0,0,0,0);
|
||||||
Shaded.Specular = float4(0,0,0,0);
|
Shaded.Specular = float4(0,0,0,0);
|
||||||
|
|
||||||
for(int i = 0; i < Lights; ++i)
|
for(int i = 0; i < Lights; ++i)
|
||||||
{
|
{
|
||||||
DiffSpec light = LightCalc(Points[i], ViewPos, DTid.xy);
|
DiffSpec light = LightCalc(Points[i], ViewPos, DTid.xy);
|
||||||
Shaded.Diffuse = light.Diffuse;
|
Shaded.Diffuse += light.Diffuse;
|
||||||
Shaded.Specular = light.Specular;
|
Shaded.Specular += light.Specular;
|
||||||
}
|
}
|
||||||
//Output[DTid.xy] = float4(ViewPos,1);
|
|
||||||
//Output[DTid.xy] = DepthTexture[DTid.xy].x;
|
Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1);
|
||||||
//Output[DTid.xy] = float4(DTid.xy/ Pixels,1,1);
|
Specular[DTid.xy] = float4(Shaded.Specular, 1);
|
||||||
//Output[DTid.xy] = NormalSpec[DTid.xy];
|
|
||||||
//Output[DTid.xy] = float4(light.Diffuse, 1);
|
|
||||||
//Output[DTid.xy] = float4(light.Specular, 1);
|
if((DTid.x + DTid.y) %4 == 0 )
|
||||||
Output[DTid.xy] = float4( Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz + Shaded.Specular + DiffuseGlow[DTid.xy].xyz * 0.2f, 1);
|
{
|
||||||
|
float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy);
|
||||||
|
Ambient[DTid.xy/4] = AmbValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,22 +1,23 @@
|
||||||
|
#ifndef PosHelper
|
||||||
|
#define PosHelper
|
||||||
#include "Defines.hlsli"
|
#include "Defines.hlsli"
|
||||||
|
|
||||||
//assumes ProperfloatTexCoords
|
//assumes ProperfloatTexCoords
|
||||||
float3 ToVpos(float2 texCoord)
|
float3 ToVpos(int2 texCoord, float2 UV)
|
||||||
{
|
{
|
||||||
//Get proper UV
|
|
||||||
float2 UV = texCoord / Pixels;
|
|
||||||
|
|
||||||
float4 ViewPos = float4(0,0,0,0);
|
float4 ViewPos = float4(0,0,0,0);
|
||||||
// Get the depth value for this pixel
|
// Get the depth value for this pixel
|
||||||
ViewPos.z= DepthTexture[texCoord].x;
|
ViewPos.z= DepthTexture[texCoord].x;
|
||||||
//Get X/w
|
//Get X/w
|
||||||
ViewPos.x = UV.x * 2 - 1;
|
ViewPos.x = UV.x;
|
||||||
//Get Y/w
|
//Get Y/w
|
||||||
//ViewPos.y = -(UV.y * 2) + 1;
|
//ViewPos.y = -(UV.y * 2) + 1;
|
||||||
ViewPos.y = 1 - 2 * UV.y;
|
ViewPos.y = UV.y;
|
||||||
ViewPos.w = 1;
|
ViewPos.w = 1;
|
||||||
|
|
||||||
//Un project
|
//Un project
|
||||||
ViewPos = mul(InvProj, ViewPos);
|
ViewPos = mul(InvProj, ViewPos);
|
||||||
return ViewPos.xyz / ViewPos.w;
|
return ViewPos.xyz / ViewPos.w;
|
||||||
}
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,12 @@
|
||||||
|
Texture2D Diffuse : register(t0);
|
||||||
|
Texture2D Specular : register(t1);
|
||||||
|
Texture2D Ambient : register(t2);
|
||||||
|
|
||||||
|
RWTexture2D<float4> Output;
|
||||||
|
|
||||||
|
[numthreads(16, 16, 1)]
|
||||||
|
void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
|
{
|
||||||
|
//Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW
|
||||||
|
Output[DTid.xy] = Diffuse[DTid.xy];
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include "Defines.hlsli"
|
||||||
|
#include "PosManipulation.hlsli"
|
||||||
|
|
||||||
|
static float Radius =5;
|
||||||
|
|
||||||
|
float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID)
|
||||||
|
{
|
||||||
|
|
||||||
|
float occlusion = 0.0f;
|
||||||
|
//create sample coordinate system
|
||||||
|
float4 rnd = float4( SSAORand[(rndID.x + rndID.y) % SSAORand.Length.x].xyz, 0.0f );
|
||||||
|
rnd = normalize(rnd);
|
||||||
|
float3 normal = NormalSpec[uv].xyz;
|
||||||
|
float4 tangent = float4( normalize(rnd.xyz - (normal * dot(rnd.xyz, normal))), 0.0f );
|
||||||
|
float4 biTangent = float4( cross(tangent.xyz, normal), 0.0f );
|
||||||
|
|
||||||
|
float4x4 tbn = float4x4(tangent, biTangent, float4(normal,0), float4(pos*Radius,1));
|
||||||
|
|
||||||
|
for( uint i = 0; i < SSAOKernel.Length.x; ++i )
|
||||||
|
{
|
||||||
|
//take sample from localspace to viewspace
|
||||||
|
float4 sampled = mul(tbn, float4(SSAOKernel[i].xyz,1));
|
||||||
|
//project sample to get uv.xy
|
||||||
|
float4 ProjOffset = sampled;
|
||||||
|
ProjOffset = mul(Proj, ProjOffset);
|
||||||
|
float4 offset = ProjOffset;
|
||||||
|
float2 UV = offset;
|
||||||
|
offset /= offset.w;
|
||||||
|
offset.xyz = offset.xyz * 0.5f + 0.5f;
|
||||||
|
//extra invert y axis, DX11
|
||||||
|
offset.y = 1.0f - offset.y;
|
||||||
|
|
||||||
|
// get depth from that point in screenspace
|
||||||
|
uint2 texCoord;
|
||||||
|
texCoord = (uint2)(offset.xy * Pixels);
|
||||||
|
float3 ViewPos = ToVpos(texCoord, UV);
|
||||||
|
|
||||||
|
float sampleDepth = ViewPos.z;
|
||||||
|
|
||||||
|
//compare to depth from sample
|
||||||
|
float rangeCheck = (abs(pos.z - sampleDepth) < Radius) ? 1.0f : 0.0f;
|
||||||
|
occlusion += (sampleDepth >= sampled.z ? 1.0f : 0.0f) * rangeCheck;
|
||||||
|
}
|
||||||
|
occlusion /= (float)(SSAOKernel.Length.x);
|
||||||
|
occlusion = 1.0f - occlusion;
|
||||||
|
|
||||||
|
return occlusion;
|
||||||
|
}
|
||||||
|
|
|
@ -3,15 +3,8 @@
|
||||||
VertexOut main( VertexIn input )
|
VertexOut main( VertexIn input )
|
||||||
{
|
{
|
||||||
VertexOut output;
|
VertexOut output;
|
||||||
float4 WorldPos = mul(World, float4(input.pos,1));
|
output.pos = mul(WVP, float4(input.pos,1));
|
||||||
float4 ViewPos = mul(View, WorldPos);
|
output.normal = mul(WV, float4(input.normal,0));
|
||||||
output.pos = mul(Projection, ViewPos);
|
|
||||||
float4 WorldNor = mul(World, float4(input.normal,0));
|
|
||||||
float4 ViewNor = mul(View, WorldNor);
|
|
||||||
output.normal = ViewNor;
|
|
||||||
//output.normal.z *= -1;
|
|
||||||
|
|
||||||
output.UV = input.UV;
|
output.UV = input.UV;
|
||||||
//output.normal = ViewNor;
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
|
@ -70,8 +70,11 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
|
||||||
__int64 prevTimeStamp = 0;
|
__int64 prevTimeStamp = 0;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||||
|
|
||||||
|
std::string fps = "FPS:";
|
||||||
|
char count[100];
|
||||||
// Main message loop
|
// Main message loop
|
||||||
MSG msg = {0};
|
MSG msg = {0};
|
||||||
|
float fpsCounter = 0;
|
||||||
while(WM_QUIT != msg.message)
|
while(WM_QUIT != msg.message)
|
||||||
{
|
{
|
||||||
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
||||||
|
@ -88,13 +91,20 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
|
||||||
//render
|
//render
|
||||||
Update(dt);
|
Update(dt);
|
||||||
Render(dt);
|
Render(dt);
|
||||||
|
fpsCounter += dt;
|
||||||
|
if(fpsCounter>0.1f)
|
||||||
|
{
|
||||||
|
sprintf_s(count, "%f",1/dt);
|
||||||
|
SetWindowTextA(g_hWnd, (fps + count).c_str());
|
||||||
|
fpsCounter = 0;
|
||||||
|
}
|
||||||
prevTimeStamp = currTimeStamp;
|
prevTimeStamp = currTimeStamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Graphics::API::DeleteModel(m);
|
Oyster::Graphics::API::DeleteModel(m);
|
||||||
Oyster::Graphics::API::DeleteModel(m2);
|
Oyster::Graphics::API::DeleteModel(m2);
|
||||||
|
Oyster::Graphics::API::DeleteModel(m3);
|
||||||
Oyster::Graphics::API::Clean();
|
Oyster::Graphics::API::Clean();
|
||||||
return (int) msg.wParam;
|
return (int) msg.wParam;
|
||||||
}
|
}
|
||||||
|
@ -160,57 +170,25 @@ HRESULT InitDirect3D()
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Triangle
|
|
||||||
//Oyster::Graphics::Definitions::ObjVertex mesh[] =
|
|
||||||
//{
|
|
||||||
// {Oyster::Math::Vector3(-1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
|
||||||
// {Oyster::Math::Vector3(1,-1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
|
||||||
// {Oyster::Math::Vector3(1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
|
|
||||||
//};
|
|
||||||
|
|
||||||
//Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
|
|
||||||
//desc.ElementSize= sizeof(Oyster::Graphics::Definitions::ObjVertex);
|
|
||||||
//desc.NumElements = 3;
|
|
||||||
//desc.InitData=mesh;
|
|
||||||
//desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
|
|
||||||
//desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
|
|
||||||
|
|
||||||
//Oyster::Graphics::Buffer *b = new Oyster::Graphics::Buffer();;
|
|
||||||
//b->Init(desc);
|
|
||||||
|
|
||||||
////b.Apply(0);
|
|
||||||
//Oyster::Graphics::Render::ModelInfo* mi = new Oyster::Graphics::Render::ModelInfo();
|
|
||||||
//mi->Indexed = false;
|
|
||||||
//mi->VertexCount = 3;
|
|
||||||
//mi->Vertices = b;
|
|
||||||
|
|
||||||
//m->info = mi;
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
#pragma region Obj
|
|
||||||
m = Oyster::Graphics::API::CreateModel(L"orca_dummy");
|
m = Oyster::Graphics::API::CreateModel(L"orca_dummy");
|
||||||
m2 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
m2 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
||||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
||||||
m3 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
m3 = Oyster::Graphics::API::CreateModel(L"worldDummy");
|
||||||
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
|
|
||||||
P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
|
P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,100);
|
||||||
Oyster::Graphics::API::SetProjection(P);
|
Oyster::Graphics::API::SetProjection(P);
|
||||||
P.Invert();
|
|
||||||
|
|
||||||
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f));
|
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,15.4f));
|
||||||
//V = Oyster::Math3D::OrientationMatrix_LookAtPos(Oyster::Math::Float3(0,0,0), Oyster::Math::Float3(0,1,0), Oyster::Math::Float3(0,0,-5.4f));
|
|
||||||
//V.v[3][2] *= -1;
|
|
||||||
V = V.GetInverse();
|
V = V.GetInverse();
|
||||||
|
|
||||||
|
|
||||||
Oyster::Graphics::Definitions::Pointlight pl;
|
Oyster::Graphics::Definitions::Pointlight pl;
|
||||||
pl.Color = Oyster::Math::Float3(1,1,1);
|
pl.Color = Oyster::Math::Float3(1,1,1);
|
||||||
pl.Bright = 1;
|
pl.Bright = 1;
|
||||||
pl.Pos = Oyster::Math::Float3(0,0,5.4f);
|
pl.Pos = Oyster::Math::Float3(0,5,5.4f);
|
||||||
pl.Radius = 15;
|
pl.Radius = 15;
|
||||||
|
|
||||||
Oyster::Graphics::API::AddLight(pl);
|
Oyster::Graphics::API::AddLight(pl);
|
||||||
|
@ -222,7 +200,7 @@ float angle = 0;
|
||||||
HRESULT Update(float deltaTime)
|
HRESULT Update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
|
||||||
angle += Oyster::Math::pi/10000;
|
angle += Oyster::Math::pi/8 * deltaTime;
|
||||||
m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle);
|
m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle);
|
||||||
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-angle,Oyster::Math::Float3(0,-4,0),Oyster::Math::Float3::null);
|
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-angle,Oyster::Math::Float3(0,-4,0),Oyster::Math::Float3::null);
|
||||||
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null);
|
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null);
|
||||||
|
@ -269,6 +247,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
|
||||||
case VK_ESCAPE:
|
case VK_ESCAPE:
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
|
//R
|
||||||
|
case 0x52:
|
||||||
|
#ifdef _DEBUG
|
||||||
|
Oyster::Graphics::API::ReloadShaders();
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue