10 Commits

Author SHA1 Message Date
Jasper
1558ee298b [ADD] added comments to startup_scene.h 2021-06-08 11:49:57 +02:00
Jasper
e7a9cda9dd [ADD] added a on/off for hand detection in menu
you can switch between mouse and hand detection now
2021-06-08 11:14:07 +02:00
Jasper
c94f798a9d [ADD] added comments and deleted cout's 2021-06-04 16:45:11 +02:00
Jasper
aa4860eb48 [FIX] only clicks ones when you close hand now 2021-06-04 16:41:16 +02:00
Jasper
b3412e414e [ADD] menu now works
menu switches to next item when hand is closed and calls OnClick() when hand is closed
2021-06-04 16:32:26 +02:00
Jasper
7cc918fdf8 [MERGE] merged feature/improve-hand-detection into feature/Start-scene correctly 2021-06-04 10:51:53 +02:00
Jasper
f76c0fcf1b Merge remote-tracking branch 'origin/feature/improve-hand-detection' into feature/menu 2021-06-04 10:03:08 +02:00
Jasper
7679555059 [ADD] added the menu buttons with correct textures to the scene 2021-06-01 15:10:23 +02:00
Kim
623003a4f7 [ADD] gitignore change 2021-06-01 14:40:26 +02:00
Kim
27e99dd2eb [ADD] Looping through array depending on open or closed hand 2021-06-01 14:37:57 +02:00
26 changed files with 344 additions and 114 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
res/menu_item_quit1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
res/menu_item_start.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
res/menu_item_start1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,25 @@
#include "MenuTest.h"
#include <iostream>
namespace computervision
{
int menu_item_array[4] = { 1, 2, 3, 4 };
float item_number = 0;
MenuTest::MenuTest(void) {
}
int MenuTest::GetMenuItem(bool hand_state) {
item_number += 0.20f;
int temp_item_number = item_number;
//If temp_item_number is equal to the size of the array, set item_number bac to zero to loop through the array again
if (temp_item_number == sizeof(menu_item_array) / sizeof(menu_item_array[0])) {
item_number = 0;
}
return menu_item_array[temp_item_number];
}
}

View File

@@ -0,0 +1,18 @@
namespace computervision
{
class MenuTest {
public:
/**
* @brief Constructor for the class MenuTest, loads in array with menu items
*
*/
MenuTest(void);
/**
* @brief Returns the itemnumber in an array
*
* @param input_bool is either true or false, depending on the recognized hand gesture
*/
int GetMenuItem(bool input_bool);
};
}

View File

@@ -59,10 +59,10 @@ namespace computervision
putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3); putText(cameraFrame,hand_text, Point(10, 75), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 0, 255),3);
imshow("camera", cameraFrame); imshow("camera", cameraFrame);
/* imshow("output", frameOut); //imshow("output", frameOut);
imshow("foreground", foreground); //imshow("foreground", foreground);
imshow("handMask", handMask); //imshow("handMask", handMask);
imshow("handDetection", fingerCountDebug);*/ //imshow("handDetection", fingerCountDebug);
int key = waitKey(1); int key = waitKey(1);

View File

@@ -5,6 +5,11 @@
namespace gui namespace gui
{ {
//Represents the type of the entitie
enum class GuiType{
LABEL, BUTTON
};
/* /*
* Structure for representing a gui item to display on the screen * Structure for representing a gui item to display on the screen
* *
@@ -18,9 +23,12 @@ namespace gui
glm::vec2 position; glm::vec2 position;
glm::vec2 scale; glm::vec2 scale;
virtual GuiType GetType() {
return GuiType::LABEL;
}
GuiTexture(int texture, glm::vec2 position, glm::vec2 scale): texture(texture), position(position), scale(scale) GuiTexture(int texture, glm::vec2 position, glm::vec2 scale): texture(texture), position(position), scale(scale)
{ {
scale.x /= (WINDOW_WIDTH / WINDOW_HEIGT); scale.x /= (WINDOW_WIDTH / WINDOW_HEIGHT);
} }
}; };
} }

View File

@@ -2,6 +2,8 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "gui_interactable.h" #include "gui_interactable.h"
#include <iostream>
namespace gui namespace gui
{ {
InteractableGui::InteractableGui(int default_texture, glm::vec2 position, glm::vec2 scale) InteractableGui::InteractableGui(int default_texture, glm::vec2 position, glm::vec2 scale)
@@ -41,14 +43,47 @@ namespace gui
} }
} }
void InteractableGui::ForceClick( int mouseButton)
{
if(mouseButton == GLFW_MOUSE_BUTTON_LEFT)
{
if (clicked_texture != 0)
{
texture = clicked_texture;
}
else
{
texture = default_texture;
}
if (!is_clicking)
{
OnClick();
is_clicking = true;
}
}
else
{
if (is_clicking)
{
is_clicking = false;
}
}
}
bool InteractableGui::IsHoveringAbove(GLFWwindow* window) bool InteractableGui::IsHoveringAbove(GLFWwindow* window)
{ {
double x_pos, y_pos; double x_pos, y_pos;
glfwGetCursorPos(window, &x_pos, &y_pos); glfwGetCursorPos(window, &x_pos, &y_pos);
//std::cout << "Cursor pos in method: " << x_pos <<"::" << y_pos << std::endl;
const float x_rel = (x_pos / SCALED_WIDTH / DEFAULT_WIDTH) * 2.0f - 1.0f; const float x_rel = (x_pos / SCALED_WIDTH / DEFAULT_WIDTH) * 2.0f - 1.0f;
const float y_rel = -((y_pos / SCALED_HEIGHT / DEFAULT_HEIGHT) * 2.0f - 1.0f); const float y_rel = -((y_pos / SCALED_HEIGHT / DEFAULT_HEIGHT) * 2.0f - 1.0f);
//std::cout << "x_rel And y_rel in method: " << x_rel << "::" << y_rel << std::endl;
if (x_rel >= minXY.x && x_rel <= maxXY.x && if (x_rel >= minXY.x && x_rel <= maxXY.x &&
y_rel >= minXY.y && y_rel <= maxXY.y) y_rel >= minXY.y && y_rel <= maxXY.y)
{ {

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include <iostream>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include "../toolbox/toolbox.h" #include "../toolbox/toolbox.h"
#include "gui_element.h" #include "gui_element.h"
@@ -32,6 +33,14 @@ namespace gui
*/ */
void Update(GLFWwindow* window); void Update(GLFWwindow* window);
/*
* @brief: Call this function when you want to perform a mouseclick
*
* @param mousebutton: mouseButton you want to perform the click on
*/
void ForceClick(int mouseButton);
/* /*
* @brief: This function gets called when the InteractabeGui is clicked * @brief: This function gets called when the InteractabeGui is clicked
*/ */
@@ -50,7 +59,10 @@ namespace gui
/* /*
* @brief: This function sets the texture of the InteractableGUI for when the InteractableGUI is clicked * @brief: This function sets the texture of the InteractableGUI for when the InteractableGUI is clicked
*/ */
void SetClickedTexture(int texture) { clicked_texture = texture; } void SetClickedTexture(int texture)
{
clicked_texture = texture;
}
/* /*
* @brief: This function sets the texture of the InteractableGUI for when the mouse is hovering above the InteractableGUI * @brief: This function sets the texture of the InteractableGUI for when the mouse is hovering above the InteractableGUI
@@ -104,6 +116,10 @@ namespace gui
*/ */
void SetOnExitAction(void (*fun)()) { on_exit_action = fun; } void SetOnExitAction(void (*fun)()) { on_exit_action = fun; }
GuiType GetType() override {
return GuiType::BUTTON;
}
protected: protected:
void OnClick() override { if (on_click_action != nullptr) on_click_action(); } void OnClick() override { if (on_click_action != nullptr) on_click_action(); }
void OnEnter() override { if (on_enter_action != nullptr) on_enter_action(); } void OnEnter() override { if (on_enter_action != nullptr) on_enter_action(); }

View File

@@ -7,6 +7,8 @@
#include "stb_image.h" #include "stb_image.h"
#include <ostream> #include <ostream>
#include <stdlib.h>
#include <iostream>
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/videoio.hpp> #include <opencv2/videoio.hpp>
@@ -23,8 +25,6 @@
#include "scenes/in_Game_Scene.h" #include "scenes/in_Game_Scene.h"
#include "scenes/startup_Scene.h" #include "scenes/startup_Scene.h"
#include "computervision/ObjectDetection.h"
#pragma comment(lib, "glfw3.lib") #pragma comment(lib, "glfw3.lib")
#pragma comment(lib, "glew32s.lib") #pragma comment(lib, "glew32s.lib")
#pragma comment(lib, "opengl32.lib") #pragma comment(lib, "opengl32.lib")
@@ -32,6 +32,7 @@
static double UpdateDelta(); static double UpdateDelta();
static GLFWwindow* window; static GLFWwindow* window;
scene::Scene* current_scene; scene::Scene* current_scene;
int main(void) int main(void)
@@ -39,7 +40,7 @@ int main(void)
#pragma region OPENGL_SETTINGS #pragma region OPENGL_SETTINGS
if (!glfwInit()) if (!glfwInit())
throw "Could not inditialize glwf"; throw "Could not inditialize glwf";
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGT, "SDBA", NULL, NULL); window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "SDBA", NULL, NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();
@@ -64,6 +65,9 @@ int main(void)
}); });
bool window_open = true; bool window_open = true;
// Main game loop // Main game loop
while (!glfwWindowShouldClose(window) && window_open) while (!glfwWindowShouldClose(window) && window_open)
{ {
@@ -82,6 +86,7 @@ int main(void)
current_scene = new scene::Startup_Scene(); current_scene = new scene::Startup_Scene();
break; break;
case scene::Scenes::INGAME: case scene::Scenes::INGAME:
current_scene = new scene::In_Game_Scene(); current_scene = new scene::In_Game_Scene();
break; break;
@@ -90,6 +95,12 @@ int main(void)
std::cout << "Wrong return value!!! ->" << std::endl; std::cout << "Wrong return value!!! ->" << std::endl;
break; break;
} }
// Finish up
//shader.Stop();
glfwSwapBuffers(window);
glfwPollEvents();
} }
// Clean up -> preventing memory leaks!!! // Clean up -> preventing memory leaks!!!

View File

@@ -26,7 +26,7 @@ namespace render_engine
glCullFace(GL_BACK); glCullFace(GL_BACK);
const glm::mat4 projectionMatrix = const glm::mat4 projectionMatrix =
glm::perspective(glm::radians(FOV), (WINDOW_WIDTH / WINDOW_HEIGT), NEAR_PLANE, FAR_PLANE); glm::perspective(glm::radians(FOV), (WINDOW_WIDTH / WINDOW_HEIGHT), NEAR_PLANE, FAR_PLANE);
// Load the projectionmatrix into the shader // Load the projectionmatrix into the shader
shader.Start(); shader.Start();

View File

@@ -10,18 +10,12 @@
#include "../renderEngine/renderer.h" #include "../renderEngine/renderer.h"
#include "../shaders/entity_shader.h" #include "../shaders/entity_shader.h"
#include "../toolbox/toolbox.h" #include "../toolbox/toolbox.h"
#include <deque>
#define MAX_MODEL_DEQUE_SIZE 6 // max amount of models to load at the same time
#define UPCOMING_MODEL_AMOUNT 4 // how much models should be loaded in front of us
namespace scene namespace scene
{ {
std::deque<entities::Entity> house_models; std::vector<entities::Entity> entities;
std::deque<entities::Light> lights; std::vector<entities::Light> lights;
std::deque<entities::Entity> trees;
models::RawModel raw_model; models::RawModel raw_model;
models::ModelTexture texture; models::ModelTexture texture;
shaders::EntityShader *shader; shaders::EntityShader *shader;
@@ -29,9 +23,6 @@ namespace scene
entities::Camera camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0)); entities::Camera camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
std::vector<gui::GuiTexture*> guis; std::vector<gui::GuiTexture*> guis;
models::TexturedModel model;
models::TexturedModel tree;
In_Game_Scene::In_Game_Scene() In_Game_Scene::In_Game_Scene()
{ {
@@ -43,47 +34,22 @@ namespace scene
gui_shader->Init(); gui_shader->Init();
} }
/**
* @brief loads a new chunk in front of the camera, and deletes the chunk behind the camera.
*
* @param model_pos the amount of models the camera has passed already. This is the rounded result of (z position of camera) / (size of model)
*
*/
void load_chunk(int model_pos)
{
std::cout << "loading model chunk" << std::endl;
if (house_models.size() >= MAX_MODEL_DEQUE_SIZE)
{
house_models.pop_back();
trees.pop_back();
}
int z_offset = model_pos * (model.raw_model.model_size.x * 20); // how much "in the distance" we should load the model
house_models.push_front(entities::Entity(model, glm::vec3(0, -50, -50 - z_offset), glm::vec3(0, 90, 0), 20));
trees.push_front(entities::Entity(tree, glm::vec3(0, 0, -50 - z_offset), glm::vec3(0, 90, 0), 3));
}
scene::Scenes scene::In_Game_Scene::start(GLFWwindow* window) scene::Scenes scene::In_Game_Scene::start(GLFWwindow* window)
{ {
raw_model = render_engine::LoadObjModel("res/House.obj"); raw_model = render_engine::LoadObjModel("res/House.obj");
texture = { render_engine::loader::LoadTexture("res/Texture.png") }; texture = { render_engine::loader::LoadTexture("res/Texture.png") };
texture.shine_damper = 10; texture.shine_damper = 10;
texture.reflectivity = 0; texture.reflectivity = 0;
model = { raw_model, texture }; models::TexturedModel model = { raw_model, texture };
models::RawModel raw_tree_model = render_engine::LoadObjModel("res/Tree.obj"); int z = 0;
models::ModelTexture tree_texture = { render_engine::loader::LoadTexture("res/TreeTexture.png") }; for (int i = 0; i < 5; ++i)
tree = { raw_tree_model, tree_texture };
// load the first few house models
for (int i = 0; i <= UPCOMING_MODEL_AMOUNT; i++)
{ {
load_chunk(i); entities.push_back(entities::Entity(model, glm::vec3(0, -50, -50 - z), glm::vec3(0, 90, 0), 20));
z += (raw_model.model_size.x * 20);
} }
lights.push_back(entities::Light(glm::vec3(0, 1000, -7000), glm::vec3(5, 5, 5))); // sun lights.push_back(entities::Light(glm::vec3(0, 1000, -7000), glm::vec3(5, 5, 5)));
lights.push_back(entities::Light(glm::vec3(0, 0, -30), glm::vec3(2, 0, 2), glm::vec3(0.0001f, 0.0001f, 0.0001f))); lights.push_back(entities::Light(glm::vec3(0, 0, -30), glm::vec3(2, 0, 2), glm::vec3(0.0001f, 0.0001f, 0.0001f)));
lights.push_back(entities::Light(glm::vec3(0, 0, -200), glm::vec3(0, 2, 0), glm::vec3(0.0001f, 0.0001f, 0.0001f))); lights.push_back(entities::Light(glm::vec3(0, 0, -200), glm::vec3(0, 2, 0), glm::vec3(0.0001f, 0.0001f, 0.0001f)));
@@ -120,17 +86,13 @@ namespace scene
shader->Start(); shader->Start();
shader->LoadSkyColor(render_engine::renderer::SKY_COLOR); shader->LoadSkyColor(render_engine::renderer::SKY_COLOR);
shader->LoadLightsDeque(lights); shader->LoadLights(lights);
shader->LoadViewMatrix(camera); shader->LoadViewMatrix(camera);
for (entities::Entity& model_entity : house_models) // Renders each entity in the entities list
for (entities::Entity& entity : entities)
{ {
render_engine::renderer::Render(model_entity, *shader); render_engine::renderer::Render(entity, *shader);
}
for (entities::Entity& tree_entity : trees)
{
render_engine::renderer::Render(tree_entity, *shader);
} }
// Render GUI items // Render GUI items
@@ -143,18 +105,6 @@ namespace scene
void scene::In_Game_Scene::update(GLFWwindow* window) void scene::In_Game_Scene::update(GLFWwindow* window)
{ {
camera.Move(window); camera.Move(window);
// calculate where the next house model should be loaded
static int last_model_pos = 0;
int model_pos = -round(camera.GetPosition().z / (model.raw_model.model_size.x * 20)); // how much models we have passed, minus because we are moving in the negative z axis
// if we have passed a model, load a new one and delete the one behind us
if (last_model_pos != model_pos)
{
load_chunk(model_pos + UPCOMING_MODEL_AMOUNT);
}
// remember the position at which the new model was added
last_model_pos = model_pos;
} }
void scene::In_Game_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods) void scene::In_Game_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)

View File

@@ -2,32 +2,183 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <map> #include <map>
#include "startup_Scene.h" #include "startup_Scene.h"
#include <iostream>
#include <opencv2/core/mat.hpp>
#include "../models/model.h"
#include "../renderEngine/loader.h"
#include "../renderEngine/obj_loader.h"
#include "../renderEngine/renderer.h"
#include "../shaders/entity_shader.h"
#include "../gui/gui_interactable.h"
#include "../toolbox/toolbox.h"
#include "../computervision/MenuTest.h"
#include "../computervision/ObjectDetection.h"
namespace scene namespace scene
{ {
shaders::GuiShader* gui_shader1;
std::vector<gui::GuiTexture*> guis1;
float item_number = 0;
bool hand_mode = false;
Startup_Scene::Startup_Scene() {
shaders::EntityShader shader;
shader.Init();
render_engine::renderer::Init(shader);
shader.CleanUp();
gui_shader1 = new shaders::GuiShader();
gui_shader1->Init();
}
gui::Button* ConvertGuiTextureToButton(gui::GuiTexture* texture) {
if (texture != NULL)
if (texture->GetType() == gui::GuiType::BUTTON) {
gui::Button* button = (gui::Button*)texture;
return button;
}
else {
return NULL;
}
}
/*gui::InteractableGui* ConvertGuiTextureToInteractableGui(gui::GuiTexture* texture) {
if (texture != NULL)
if (texture->GetType() == gui::GuiType::BUTTON) {
return (gui::InteractableGui*)texture;
}
else {
return NULL;
}
}*/
gui::GuiTexture* GetMenuItem(bool hand_state) {
if(hand_state)
item_number += 0.20f;
int temp_item_number = item_number;
//If temp_item_number is equal to the size of the array, set item_number bac to zero to loop through the array again
if (temp_item_number == guis1.size()) {
item_number = 0;
temp_item_number = 0;
}
std::cout << guis1[temp_item_number]->texture << std::endl;
return guis1[temp_item_number];
}
scene::Scenes scene::Startup_Scene::start(GLFWwindow *window) scene::Scenes scene::Startup_Scene::start(GLFWwindow *window)
{ {
// GUI stuff
gui::Button button_start(render_engine::loader::LoadTexture("res/menu_item_start1.png"), glm::vec2(0.0f, 0.6f), glm::vec2(0.25f, 0.25f));
button_start.SetHoverTexture(render_engine::loader::LoadTexture("res/menu_item_start1_hover.png"));
button_start.SetClickedTexture(render_engine::loader::LoadTexture("res/menu_item_start1_click.png"));
button_start.SetOnClickAction([]()
{
std::cout << "Clicked on button: Start!" << std::endl;
});
guis1.push_back(&button_start);
gui::Button button_calibrate(render_engine::loader::LoadTexture("res/menu_item_calibrate1.png"), glm::vec2(0.0f, 0.0f), glm::vec2(0.25f, 0.25f));
button_calibrate.SetHoverTexture(render_engine::loader::LoadTexture("res/menu_item_calibrate1_hover.png"));
button_calibrate.SetClickedTexture(render_engine::loader::LoadTexture("res/menu_item_calibrate1_click.png"));
button_calibrate.SetOnClickAction([]()
{
std::cout << "Clicked on button: Calibrate!" << std::endl;
});
guis1.push_back(&button_calibrate);
gui::Button button_quit(render_engine::loader::LoadTexture("res/menu_item_quit1.png"), glm::vec2(0.0f, -0.6f), glm::vec2(0.25f, 0.25f));
button_quit.SetHoverTexture(render_engine::loader::LoadTexture("res/menu_item_quit1_hover.png"));
button_quit.SetClickedTexture(render_engine::loader::LoadTexture("res/menu_item_quit1_click.png"));
button_quit.SetOnClickAction([]()
{
std::cout << "Clicked on button: Quit!" << std::endl;
});
guis1.push_back(&button_quit);
computervision::ObjectDetection objDetect;
cv::Mat cameraFrame;
gui::GuiTexture* chosen_item = NULL; //This is the selected menu_item
bool hand_closed = false; //Flag to prevent multiple button presses
while (return_value == scene::Scenes::STARTUP) while (return_value == scene::Scenes::STARTUP)
{ {
render(); render();
update(window); update(window);
if (hand_mode) {
cameraFrame = objDetect.readCamera();
//Get hand state from camera
bool hand_detection = objDetect.detectHand(cameraFrame);
if (hand_detection)
{
hand_closed = false;
std::cout << "hand is opened" << std::endl;
//Loop through menu items
chosen_item = GetMenuItem(true);
gui::Button* new_button = ConvertGuiTextureToButton(chosen_item);
if (new_button != NULL) {
const float x_pos = (chosen_item->position.x + 1.0) * WINDOW_WIDTH / 2;
const float y_pos = (1.0 - chosen_item->position.y) * WINDOW_HEIGHT / 2;
//Set cursor to location of selected menu_item
glfwSetCursorPos(window, x_pos, y_pos);
}
}
else if (!hand_detection)
{
std::cout << "hand is closed" << std::endl;
//Gets selected menu_item
chosen_item = GetMenuItem(false);
gui::Button* new_button = ConvertGuiTextureToButton(chosen_item);
if (new_button != NULL && !hand_closed) {
//Run function click
new_button->ForceClick(GLFW_MOUSE_BUTTON_LEFT);
hand_closed = true;
}
}
}
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }
gui_shader1->CleanUp();
render_engine::loader::CleanUp();
return return_value; return return_value;
} }
void scene::Startup_Scene::render() void scene::Startup_Scene::render()
{ {
render_engine::renderer::Prepare();
// Render GUI items
render_engine::renderer::Render(guis1, *gui_shader1);
} }
void scene::Startup_Scene::update(GLFWwindow* window) void scene::Startup_Scene::update(GLFWwindow* window)
{ {
for (gui::GuiTexture* button : guis1) {
gui::Button* new_button = ConvertGuiTextureToButton(button);
if (new_button != NULL)
new_button->Update(window);
}
} }
void scene::Startup_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods) void scene::Startup_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
@@ -36,5 +187,8 @@ namespace scene
{ {
return_value = scene::Scenes::INGAME; return_value = scene::Scenes::INGAME;
} }
else if (glfwGetKey(window, GLFW_KEY_BACKSPACE) == GLFW_PRESS) {
hand_mode = !hand_mode;
}
} }
} }

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "scene.h" #include "scene.h"
#include <map> #include "../gui/gui_element.h"
namespace scene namespace scene
{ {
@@ -12,9 +12,42 @@ namespace scene
scene::Scenes return_value = scene::Scenes::STARTUP; scene::Scenes return_value = scene::Scenes::STARTUP;
public: public:
/**
* @brief Constructor of the class Startup_Scene
*
*/
Startup_Scene();
/**
* @brief
*
* @param window
* @return
*/
Scenes start(GLFWwindow* window) override; Scenes start(GLFWwindow* window) override;
/**
* @brief
*
*/
void render() override; void render() override;
/**
* @brief This method updates all the components on the window
*
* @param window Window it updates
*/
void update(GLFWwindow* window) override; void update(GLFWwindow* window) override;
/**
* @brief Listener for key events
*
* @param window Window it listens to for key events
* @param key Key of event that is activated
* @param scancode Code of Key
* @param action
* @param mods
*/
void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override; void onKey(GLFWwindow* window, int key, int scancode, int action, int mods) override;
}; };
} }

View File

@@ -1,6 +1,5 @@
#include "entity_shader.h" #include "entity_shader.h"
#include "../toolbox/toolbox.h" #include "../toolbox/toolbox.h"
#include <deque>
namespace shaders namespace shaders
{ {
@@ -161,25 +160,6 @@ namespace shaders
} }
} }
void EntityShader::LoadLightsDeque(std::deque<entities::Light>& lights) const
{
for (int i = 0; i < MAX_LIGHTS; ++i)
{
if (i < lights.size())
{
LoadVector(location_light_position[i], lights[i].GetPosition());
LoadVector(location_light_color[i], lights[i].GetColor());
LoadVector(location_light_attenuation[i], lights[i].GetAttenuation());
}
else
{
LoadVector(location_light_position[i], glm::vec3(0, 0, 0));
LoadVector(location_light_color[i], glm::vec3(0, 0, 0));
LoadVector(location_light_attenuation[i], glm::vec3(1, 0, 0));
}
}
}
void EntityShader::LoadShineVariables(float shine_damper, float reflectivity) const void EntityShader::LoadShineVariables(float shine_damper, float reflectivity) const
{ {
LoadFloat(location_shine_damper, shine_damper); LoadFloat(location_shine_damper, shine_damper);

View File

@@ -2,7 +2,6 @@
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <vector> #include <vector>
#include <deque>
#include "shader_program.h" #include "shader_program.h"
#include "../entities/camera.h" #include "../entities/camera.h"
#include "../entities/light.h" #include "../entities/light.h"
@@ -59,13 +58,6 @@ namespace shaders
*/ */
void LoadLights(std::vector<entities::Light>& lights) const; void LoadLights(std::vector<entities::Light>& lights) const;
/**
* @brief loads some lights contained in a deque.
*
* @param lights the deque containing the lights to load
*/
void LoadLightsDeque(std::deque<entities::Light>& lights) const;
/* /*
* @brief: A method to load the the shine variables from a model into the shader * @brief: A method to load the the shine variables from a model into the shader
* *

View File

@@ -11,10 +11,10 @@ namespace toolbox
// Change these macros to change the window size // Change these macros to change the window size
#define WINDOW_WIDTH 1400.0f #define WINDOW_WIDTH 1400.0f
#define WINDOW_HEIGT 800.0f #define WINDOW_HEIGHT 800.0f
#define SCALED_WIDTH (WINDOW_WIDTH/DEFAULT_WIDTH) #define SCALED_WIDTH (WINDOW_WIDTH/DEFAULT_WIDTH)
#define SCALED_HEIGHT (WINDOW_HEIGT/DEFAULT_HEIGHT) #define SCALED_HEIGHT (WINDOW_HEIGHT/DEFAULT_HEIGHT)
// //
/* /*

View File

@@ -22,6 +22,7 @@
<ClCompile Include="src\collision\collision_handler.cpp" /> <ClCompile Include="src\collision\collision_handler.cpp" />
<ClCompile Include="src\scenes\in_Game_Scene.cpp" /> <ClCompile Include="src\scenes\in_Game_Scene.cpp" />
<ClCompile Include="src\computervision\FaceDetector.cpp" /> <ClCompile Include="src\computervision\FaceDetector.cpp" />
<ClCompile Include="src\computervision\MenuTest.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" />
<ClCompile Include="src\computervision\FingerCount.cpp" /> <ClCompile Include="src\computervision\FingerCount.cpp" />
@@ -48,6 +49,7 @@
<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" />
<ClInclude Include="src\computervision\MenuTest.h" />
<ClInclude Include="src\computervision\SkinDetector.h" /> <ClInclude Include="src\computervision\SkinDetector.h" />
<ClInclude Include="src\computervision\ObjectDetection.h" /> <ClInclude Include="src\computervision\ObjectDetection.h" />
<ClInclude Include="src\entities\camera.h" /> <ClInclude Include="src\entities\camera.h" />

View File

@@ -75,6 +75,9 @@
<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\computervision\MenuTest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\entities\Camera.h"> <ClInclude Include="src\entities\Camera.h">
@@ -155,6 +158,9 @@
<ClInclude Include="src\toolbox\Timer.h"> <ClInclude Include="src\toolbox\Timer.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\computervision\MenuTest.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Xml Include="res\haarcascade_frontalface_alt.xml" /> <Xml Include="res\haarcascade_frontalface_alt.xml" />