Compare commits
6 Commits
feature/ob
...
feature/sc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f2258bc01 | ||
|
|
ad4075a826 | ||
|
|
e50cd92a35 | ||
|
|
ff79c1525c | ||
|
|
5b4d9b624f | ||
|
|
01571d191f |
0
gameoverScene.cpp
Normal file
0
gameoverScene.cpp
Normal file
0
gameoverScene.h
Normal file
0
gameoverScene.h
Normal file
24
src/main.cpp
24
src/main.cpp
@@ -4,6 +4,11 @@
|
|||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <opencv2/core.hpp>
|
||||||
|
#include <opencv2/videoio.hpp>
|
||||||
|
#include <opencv2/video.hpp>
|
||||||
|
|
||||||
#include "models/model.h"
|
#include "models/model.h"
|
||||||
#include "renderEngine/loader.h"
|
#include "renderEngine/loader.h"
|
||||||
@@ -12,6 +17,10 @@
|
|||||||
#include "shaders/static_shader.h"
|
#include "shaders/static_shader.h"
|
||||||
#include "toolbox/toolbox.h"
|
#include "toolbox/toolbox.h"
|
||||||
|
|
||||||
|
#include "scenes/scene.h"
|
||||||
|
#include "scenes/startupScene.h"
|
||||||
|
#include "scenes/inGameScene.h"
|
||||||
|
|
||||||
#include "computervision/ObjectDetection.h"
|
#include "computervision/ObjectDetection.h"
|
||||||
|
|
||||||
#pragma comment(lib, "glfw3.lib")
|
#pragma comment(lib, "glfw3.lib")
|
||||||
@@ -22,6 +31,10 @@ static double UpdateDelta();
|
|||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
|
|
||||||
|
//Scene management variables
|
||||||
|
std::map<Scenes, Scene*> scenes;
|
||||||
|
Scene* current_scene = nullptr;
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -41,10 +54,13 @@ int main(void)
|
|||||||
|
|
||||||
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods)
|
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
|
current_scene->onKey(key, scancode, action, mods);
|
||||||
if (key == GLFW_KEY_ESCAPE)
|
if (key == GLFW_KEY_ESCAPE)
|
||||||
glfwSetWindowShouldClose(window, true);
|
glfwSetWindowShouldClose(window, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scenes[Scenes::STARTUP] = new StartupScene();
|
||||||
|
scenes[Scenes::INGAME] = new InGameScene();
|
||||||
|
|
||||||
models::RawModel raw_model = LoadObjModel("res/Tree.obj");
|
models::RawModel raw_model = LoadObjModel("res/Tree.obj");
|
||||||
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") };
|
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") };
|
||||||
@@ -64,6 +80,7 @@ int main(void)
|
|||||||
// set up object detection
|
// set up object detection
|
||||||
//objDetect.setup();
|
//objDetect.setup();
|
||||||
|
|
||||||
|
current_scene->start();
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
@@ -71,15 +88,17 @@ int main(void)
|
|||||||
const double delta = UpdateDelta();
|
const double delta = UpdateDelta();
|
||||||
entity.IncreaseRotation(glm::vec3(0, 1, 0));
|
entity.IncreaseRotation(glm::vec3(0, 1, 0));
|
||||||
camera.Move(window);
|
camera.Move(window);
|
||||||
|
current_scene->update(window);
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
render_engine::renderer::Prepare();
|
render_engine::renderer::Prepare();
|
||||||
shader.Start();
|
shader.Start();
|
||||||
shader.LoadViewMatrix(camera);
|
shader.LoadViewMatrix(camera);
|
||||||
|
current_scene->render();
|
||||||
render_engine::renderer::Render(entity, shader);
|
render_engine::renderer::Render(entity, shader);
|
||||||
|
|
||||||
objDetect.setup();
|
//objDetect.setup();
|
||||||
|
objDetect.calculateDifference();
|
||||||
|
|
||||||
// Finish up
|
// Finish up
|
||||||
shader.Stop();
|
shader.Stop();
|
||||||
@@ -90,6 +109,7 @@ int main(void)
|
|||||||
// Clean up
|
// Clean up
|
||||||
shader.CleanUp();
|
shader.CleanUp();
|
||||||
render_engine::loader::CleanUp();
|
render_engine::loader::CleanUp();
|
||||||
|
current_scene->stop();
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/scenes/inGameScene.cpp
Normal file
30
src/scenes/inGameScene.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "inGameScene.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onKey(int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* misschien iets van als niet in settings dan hoeft alleen escape een knop zijn als reserve optie. Als wel in settings, dan heb je hetzelfde hoe je in het in het begin scherm hebt.
|
||||||
|
**/
|
||||||
|
}
|
||||||
|
|
||||||
15
src/scenes/inGameScene.h
Normal file
15
src/scenes/inGameScene.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "scene.h"
|
||||||
|
class InGameScene : public Scene
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void start() override;
|
||||||
|
virtual void stop() override;
|
||||||
|
virtual void render() override;
|
||||||
|
virtual void update(GLFWwindow* window) override;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) override;
|
||||||
|
};
|
||||||
|
|
||||||
1
src/scenes/scene.cpp
Normal file
1
src/scenes/scene.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "scene.h"
|
||||||
23
src/scenes/scene.h
Normal file
23
src/scenes/scene.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
class Scene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void start() = 0;
|
||||||
|
virtual void stop() = 0;
|
||||||
|
virtual void render() = 0;
|
||||||
|
virtual void update(GLFWwindow* window) = 0;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) {};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum class Scenes
|
||||||
|
{
|
||||||
|
STARTUP,
|
||||||
|
INGAME,
|
||||||
|
GAMEOVER,
|
||||||
|
SETTINGS,
|
||||||
|
CALIBRATION
|
||||||
|
};
|
||||||
31
src/scenes/startupScene.cpp
Normal file
31
src/scenes/startupScene.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "startupScene.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void render()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(GLFWwindow* window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void onKey(int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_DOWN && action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
//ideetje voor het scrollen door het menu heen
|
||||||
|
menuIndex = (menuIndex + 1) % 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/scenes/startupScene.h
Normal file
15
src/scenes/startupScene.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "scene.h"
|
||||||
|
class StartupScene : public Scene
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int menuIndex;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void start() override;
|
||||||
|
virtual void stop() override;
|
||||||
|
virtual void render() override;
|
||||||
|
virtual void update(GLFWwindow* window) override;
|
||||||
|
virtual void onKey(int key, int scancode, int action, int mods) override;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace toolbox
|
namespace toolbox
|
||||||
{
|
{
|
||||||
#define WINDOW_WIDTH 1400.0f
|
#define WINDOW_WIDTH 1400
|
||||||
#define WINDOW_HEIGT 800.0f
|
#define WINDOW_HEIGT 800
|
||||||
|
|
||||||
glm::mat4 CreateModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale);
|
glm::mat4 CreateModelMatrix(glm::vec3 translation, glm::vec3 rotation, float scale);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\scenes\inGameScene.cpp" />
|
||||||
|
<ClCompile Include="src\scenes\scene.cpp" />
|
||||||
<ClCompile Include="src\computervision\FaceDetector.cpp" />
|
<ClCompile Include="src\computervision\FaceDetector.cpp" />
|
||||||
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
||||||
<ClCompile Include="src\computervision\SkinDetector.cpp" />
|
<ClCompile Include="src\computervision\SkinDetector.cpp" />
|
||||||
@@ -33,8 +35,11 @@
|
|||||||
<ClCompile Include="src\shaders\shader_program.cpp" />
|
<ClCompile Include="src\shaders\shader_program.cpp" />
|
||||||
<ClCompile Include="src\shaders\static_shader.cpp" />
|
<ClCompile Include="src\shaders\static_shader.cpp" />
|
||||||
<ClCompile Include="src\toolbox\toolbox.cpp" />
|
<ClCompile Include="src\toolbox\toolbox.cpp" />
|
||||||
|
<ClCompile Include="src\scenes\startupScene.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="src\scenes\inGameScene.h" />
|
||||||
|
<ClInclude Include="src\scenes\scene.h" />
|
||||||
<ClInclude Include="src\computervision\FaceDetector.h" />
|
<ClInclude Include="src\computervision\FaceDetector.h" />
|
||||||
<ClInclude Include="src\computervision\FingerCount.h" />
|
<ClInclude Include="src\computervision\FingerCount.h" />
|
||||||
<ClInclude Include="src\computervision\BackgroundRemover.h" />
|
<ClInclude Include="src\computervision\BackgroundRemover.h" />
|
||||||
@@ -50,6 +55,7 @@
|
|||||||
<ClInclude Include="src\shaders\static_shader.h" />
|
<ClInclude Include="src\shaders\static_shader.h" />
|
||||||
<ClInclude Include="src\stb_image.h" />
|
<ClInclude Include="src\stb_image.h" />
|
||||||
<ClInclude Include="src\toolbox\toolbox.h" />
|
<ClInclude Include="src\toolbox\toolbox.h" />
|
||||||
|
<ClInclude Include="src\scenes\startupScene.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||||
@@ -112,14 +118,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>C:\opencv\build\include;$(IncludePath)</IncludePath>
|
<IncludePath>C:\opencv\build\include;$(IncludePath);C:\opencv\opencv\build\include</IncludePath>
|
||||||
<LibraryPath>C:\opencv\build\x64\vc15\lib;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\opencv\build\x64\vc15\lib;$(LibraryPath);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\opencv\opencv\build\include</IncludePath>
|
||||||
|
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);C:\opencv\opencv\build\x64\vc15\lib</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
@@ -151,7 +159,7 @@
|
|||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>opencv_world452d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>opencv_world452d.lib;%(AdditionalDependencies); opencv_world452.lib</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
@@ -192,6 +200,7 @@
|
|||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)lib\glfw-3.3.2\$(Platform);$(SolutionDir)lib\glew-2.1.0\lib\Release\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies); opencv_world452.lib</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -57,6 +57,15 @@
|
|||||||
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\scene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\startupScene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\scenes\inGameScene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\entities\Camera.h">
|
<ClInclude Include="src\entities\Camera.h">
|
||||||
@@ -104,6 +113,15 @@
|
|||||||
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\scene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\startupScene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\scenes\inGameScene.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||||
|
|||||||
Reference in New Issue
Block a user