Skip to content

Commit 37d55e9

Browse files
committed
More terrain work and added demo scene.
* Separated SceneBase with a new DemoSponza scene. * Terrain logic almost done. Shaders are soon.
1 parent 1d88b42 commit 37d55e9

File tree

16 files changed

+405
-147
lines changed

16 files changed

+405
-147
lines changed

MP-APS/.vs/MP-APS/v15/.suo

-6 KB
Binary file not shown.

MP-APS/.vs/MP-APS/v15/Browse.VC.db

32 KB
Binary file not shown.

MP-APS/Demos/DemoCrytekSponza.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "DemoCrytekSponza.h"
2+
3+
#include "../ResourceManager.h"
4+
5+
6+
/***********************************************************************************/
7+
DemoCrytekSponza::DemoCrytekSponza(const std::size_t width, const std::size_t height) : SceneBase(width, height) {
8+
}
9+
10+
/***********************************************************************************/
11+
void DemoCrytekSponza::Init(const std::string_view sceneName) {
12+
SceneBase::Init(sceneName);
13+
14+
auto model = ResourceManager::GetInstance().GetModel("Sponza", "Data/Models/crytek-sponza/sponza.obj");
15+
model->Translate(glm::vec3(0.0f));
16+
model->Scale(glm::vec3(0.01f));
17+
m_sceneModels.push_back(model);
18+
19+
// Sun
20+
m_staticDirectionalLights.emplace_back(StaticDirectionalLight(glm::vec3(5.0f, 5.0f, 4.5f), { 25.0f, 50.0f, 10.0f }));
21+
}
22+

MP-APS/Demos/DemoCrytekSponza.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include "../SceneBase.h"
4+
5+
class DemoCrytekSponza : public SceneBase {
6+
7+
public:
8+
DemoCrytekSponza(const std::size_t width, const std::size_t height);
9+
~DemoCrytekSponza() = default;
10+
11+
void Init(const std::string_view sceneName) override;
12+
};

MP-APS/Engine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Engine::Engine(const std::string_view configPath) : m_mainWindow{},
4343
}
4444

4545
/***********************************************************************************/
46-
void Engine::AddScene(const SceneBase& scene) {
47-
m_scenes.try_emplace(scene.GetName(), scene);
46+
void Engine::AddScene(const std::shared_ptr<SceneBase>& scene) {
47+
m_scenes.try_emplace(scene->GetName(), scene);
4848
}
4949

5050
/***********************************************************************************/
@@ -56,7 +56,7 @@ void Engine::SetActiveScene(const std::string_view sceneName) {
5656
return;
5757
}
5858

59-
m_activeScene = &scene->second;
59+
m_activeScene = scene->second.get();
6060
m_renderer.InitView(m_activeScene->GetCamera());
6161
}
6262

MP-APS/Engine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Engine {
2121

2222
~Engine() = default;
2323

24-
void AddScene(const SceneBase& scene);
24+
void AddScene(const std::shared_ptr<SceneBase>& scene);
2525
void SetActiveScene(const std::string_view sceneName);
2626

2727
void Execute();
@@ -38,7 +38,7 @@ class Engine {
3838
GUISystem m_guiSystem;
3939

4040
// All loaded scenes stored in memory
41-
std::unordered_map<std::string, SceneBase> m_scenes;
41+
std::unordered_map<std::string, std::shared_ptr<SceneBase>> m_scenes;
4242
// Current scene being processed by renderer
4343
SceneBase* m_activeScene;
4444
};

MP-APS/SceneBase.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#include "Input.h"
44
#include "ViewFrustum.h"
5-
#include "ResourceManager.h"
65

76
#include <ppl.h> // Concurrency library
7+
#include <iostream>
88

99
/***********************************************************************************/
1010
SceneBase::SceneBase(const std::size_t width, const std::size_t height) : m_width(width),
@@ -16,13 +16,7 @@ void SceneBase::Init(const std::string_view sceneName) {
1616

1717
m_sceneName = sceneName;
1818

19-
auto model = ResourceManager::GetInstance().GetModel("Sponza", "Data/Models/crytek-sponza/sponza.obj");
20-
model->Translate(glm::vec3(0.0f));
21-
model->Scale(glm::vec3(0.01f));
22-
m_sceneModels.push_back(model);
23-
24-
// Sun
25-
m_staticDirectionalLights.emplace_back(StaticDirectionalLight(glm::vec3(5.0f, 5.0f, 4.5f), {25.0f, 50.0f, 10.0f}));
19+
std::cout << "Loading scene: " << sceneName << std::endl;
2620
}
2721

2822
/***********************************************************************************/

MP-APS/SceneBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#include "Graphics/StaticPointLight.h"
88
#include "Graphics/StaticSpotLight.h"
99

10+
/***********************************************************************************/
11+
// Forward Declarations
1012
class RenderSystem;
13+
1114
/***********************************************************************************/
1215
class SceneBase {
1316
friend class RenderSystem;

MP-APS/ShaderViewer.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
<ClCompile Include="Core\GUISystem.cpp" />
273273
<ClCompile Include="Core\RenderSystem.cpp" />
274274
<ClCompile Include="Core\WindowSystem.cpp" />
275+
<ClCompile Include="Demos\DemoCrytekSponza.cpp" />
275276
<ClCompile Include="Engine.cpp" />
276277
<ClCompile Include="Graphics\GLFramebuffer.cpp" />
277278
<ClCompile Include="Graphics\GLShader.cpp" />
@@ -285,7 +286,6 @@
285286
<ClCompile Include="SceneBase.cpp" />
286287
<ClCompile Include="Skybox.cpp" />
287288
<ClCompile Include="Terrain\Terrain.cpp" />
288-
<ClCompile Include="Terrain\TerrainRenderer.cpp" />
289289
<ClCompile Include="Timer.cpp" />
290290
<ClCompile Include="ViewFrustum.cpp" />
291291
</ItemGroup>
@@ -298,6 +298,7 @@
298298
<ClInclude Include="Core\GUISystem.h" />
299299
<ClInclude Include="Core\RenderSystem.h" />
300300
<ClInclude Include="Core\WindowSystem.h" />
301+
<ClInclude Include="Demos\DemoCrytekSponza.h" />
301302
<ClInclude Include="Engine.h" />
302303
<ClInclude Include="Graphics\StaticDirectionalLight.h" />
303304
<ClInclude Include="Graphics\GLFramebuffer.h" />
@@ -313,7 +314,7 @@
313314
<ClInclude Include="ResourceManager.h" />
314315
<ClInclude Include="SceneBase.h" />
315316
<ClInclude Include="Skybox.h" />
316-
<ClInclude Include="Terrain\TerrainRenderer.h" />
317+
<ClInclude Include="Terrain\Terrain.h" />
317318
<ClInclude Include="Terrain\TerrainNode.h" />
318319
<ClInclude Include="Timer.h" />
319320
<ClInclude Include="ViewFrustum.h" />

MP-APS/ShaderViewer.vcxproj.filters

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<Filter Include="AI">
2222
<UniqueIdentifier>{0d636b6d-aaa3-4bc1-9375-8b5a52311ed6}</UniqueIdentifier>
2323
</Filter>
24+
<Filter Include="Demos">
25+
<UniqueIdentifier>{eefd2842-47fc-4817-9cac-65f6078fc562}</UniqueIdentifier>
26+
</Filter>
2427
</ItemGroup>
2528
<ItemGroup>
2629
<ClCompile Include="Mesh.cpp">
@@ -80,17 +83,17 @@
8083
<ClCompile Include="PBRMaterial.cpp">
8184
<Filter>Source Files</Filter>
8285
</ClCompile>
83-
<ClCompile Include="Terrain\Terrain.cpp">
84-
<Filter>Terrain</Filter>
85-
</ClCompile>
8686
<ClCompile Include="Core\GUISystem.cpp">
8787
<Filter>Core</Filter>
8888
</ClCompile>
8989
<ClCompile Include="AI\AISystem.cpp">
9090
<Filter>AI</Filter>
9191
</ClCompile>
92-
<ClCompile Include="Terrain\TerrainRenderer.cpp">
93-
<Filter>Source Files</Filter>
92+
<ClCompile Include="Terrain\Terrain.cpp">
93+
<Filter>Terrain</Filter>
94+
</ClCompile>
95+
<ClCompile Include="Demos\DemoCrytekSponza.cpp">
96+
<Filter>Demos</Filter>
9497
</ClCompile>
9598
</ItemGroup>
9699
<ItemGroup>
@@ -172,9 +175,12 @@
172175
<ClInclude Include="AI\AISystem.h">
173176
<Filter>AI</Filter>
174177
</ClInclude>
175-
<ClInclude Include="Terrain\TerrainRenderer.h">
178+
<ClInclude Include="Terrain\Terrain.h">
176179
<Filter>Terrain</Filter>
177180
</ClInclude>
181+
<ClInclude Include="Demos\DemoCrytekSponza.h">
182+
<Filter>Demos</Filter>
183+
</ClInclude>
178184
</ItemGroup>
179185
<ItemGroup>
180186
<None Include="..\README.md" />

0 commit comments

Comments
 (0)