Merge branch 'develop' of https://github.com/SemvdH/SDBA into develop
* 'develop' of https://github.com/SemvdH/SDBA: [FIX] pointer [FIX] in game scene [FIX] in game scene
This commit is contained in:
@@ -44,7 +44,6 @@ static GLFWwindow* window;
|
|||||||
|
|
||||||
scene::Scene* current_scene;
|
scene::Scene* current_scene;
|
||||||
|
|
||||||
static GLFWwindow* window;
|
|
||||||
bool points_img_available = false;
|
bool points_img_available = false;
|
||||||
cv::Mat points_img;
|
cv::Mat points_img;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
namespace scene
|
namespace scene
|
||||||
{
|
{
|
||||||
std::shared_ptr<entities::MainCharacter>main_character;
|
std::shared_ptr<entities::MainCharacter>main_character;
|
||||||
std::deque<entities::Light> lights;
|
|
||||||
std::vector<std::shared_ptr<entities::CollisionEntity>> collision_entities;
|
std::vector<std::shared_ptr<entities::CollisionEntity>> collision_entities;
|
||||||
entities::HouseGenerator* house_generator;
|
entities::HouseGenerator* house_generator;
|
||||||
std::deque<std::shared_ptr<entities::Entity>> house_models;
|
std::deque<std::shared_ptr<entities::Entity>> house_models;
|
||||||
@@ -39,7 +38,6 @@ namespace scene
|
|||||||
models::ModelTexture texture;
|
models::ModelTexture texture;
|
||||||
shaders::EntityShader* shader;
|
shaders::EntityShader* shader;
|
||||||
shaders::GuiShader* gui_shader;
|
shaders::GuiShader* gui_shader;
|
||||||
entities::Camera camera(glm::vec3(0, -50, 0), glm::vec3(0, 0, 0));
|
|
||||||
std::vector<gui::GuiTexture*> guis;
|
std::vector<gui::GuiTexture*> guis;
|
||||||
|
|
||||||
int furniture_count_old;
|
int furniture_count_old;
|
||||||
@@ -53,7 +51,7 @@ namespace scene
|
|||||||
*/
|
*/
|
||||||
In_Game_Scene::In_Game_Scene()
|
In_Game_Scene::In_Game_Scene()
|
||||||
{
|
{
|
||||||
camera = new entities::Camera(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
|
camera = std::make_unique<entities::Camera>(glm::vec3(0, 0, 0), glm::vec3(0, 0, 0));
|
||||||
|
|
||||||
shader = new shaders::EntityShader;
|
shader = new shaders::EntityShader;
|
||||||
shader->Init();
|
shader->Init();
|
||||||
@@ -80,7 +78,6 @@ namespace scene
|
|||||||
*/
|
*/
|
||||||
In_Game_Scene::~In_Game_Scene()
|
In_Game_Scene::~In_Game_Scene()
|
||||||
{
|
{
|
||||||
delete camera;
|
|
||||||
delete shader;
|
delete shader;
|
||||||
delete gui_shader;
|
delete gui_shader;
|
||||||
delete house_generator;
|
delete house_generator;
|
||||||
@@ -230,14 +227,14 @@ namespace scene
|
|||||||
shader->Start();
|
shader->Start();
|
||||||
shader->LoadSkyColor(render_engine::renderer::SKY_COLOR);
|
shader->LoadSkyColor(render_engine::renderer::SKY_COLOR);
|
||||||
shader->LoadLightsDeque(lights);
|
shader->LoadLightsDeque(lights);
|
||||||
shader->LoadViewMatrix(camera);
|
shader->LoadViewMatrix(*camera);
|
||||||
|
|
||||||
for (std::shared_ptr<entities::Entity> model_entity : house_models)
|
for (std::shared_ptr<entities::Entity> model_entity : house_models)
|
||||||
{
|
{
|
||||||
render_engine::renderer::Render(model_entity, *shader);
|
render_engine::renderer::Render(model_entity, *shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_engine::renderer::Render(*main_character, *shader);
|
render_engine::renderer::Render(main_character, *shader);
|
||||||
|
|
||||||
// Render GUI items
|
// Render GUI items
|
||||||
//render_engine::renderer::Render(guis, *gui_shader);
|
//render_engine::renderer::Render(guis, *gui_shader);
|
||||||
@@ -254,11 +251,11 @@ namespace scene
|
|||||||
main_character->Move(window);
|
main_character->Move(window);
|
||||||
|
|
||||||
//std::cout << "x get: " << movement.x << "\ny get: " << movement.y << "\nz get: " << movement.z << "\n";
|
//std::cout << "x get: " << movement.x << "\ny get: " << movement.y << "\nz get: " << movement.z << "\n";
|
||||||
camera.Follow(main_character->GetPosition());
|
camera->Follow(main_character->GetPosition());
|
||||||
|
|
||||||
// calculate where the next house model should be loaded
|
// calculate where the next house model should be loaded
|
||||||
static int last_model_pos = 0;
|
static int last_model_pos = 0;
|
||||||
int model_pos = -round(camera.GetPosition().z / (house_generator->GetHouseDepth())); // how much models we have passed, minus because we are moving in the negative z axis
|
int model_pos = -round(camera->GetPosition().z / (house_generator->GetHouseDepth())); // 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 we have passed a model, load a new one and delete the one behind us
|
||||||
if (last_model_pos != model_pos)
|
if (last_model_pos != model_pos)
|
||||||
@@ -317,4 +314,10 @@ namespace scene
|
|||||||
|
|
||||||
cv::imshow("camera", camera_frame);
|
cv::imshow("camera", camera_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//renders the models for the pause menu
|
||||||
|
void In_Game_Scene::render_pause_menu()
|
||||||
|
{
|
||||||
|
render_engine::renderer::Render(pause_guis, *gui_shader);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
#include "../gui/gui_interactable.h"
|
#include "../gui/gui_interactable.h"
|
||||||
#include "../models/model.h"
|
#include "../models/model.h"
|
||||||
@@ -38,7 +39,7 @@ namespace scene
|
|||||||
//entities_to_render is a list of entities, those entities will be rendered in the 3D environment.
|
//entities_to_render is a list of entities, those entities will be rendered in the 3D environment.
|
||||||
std::vector<entities::Entity> entities_to_render;
|
std::vector<entities::Entity> entities_to_render;
|
||||||
//lights is a lost of light points in the game, for example the sun or it can be used to attach light effects to lamps.
|
//lights is a lost of light points in the game, for example the sun or it can be used to attach light effects to lamps.
|
||||||
std::vector<entities::Light> lights;
|
std::deque<entities::Light> lights;
|
||||||
|
|
||||||
models::RawModel raw_model;
|
models::RawModel raw_model;
|
||||||
models::ModelTexture texture;
|
models::ModelTexture texture;
|
||||||
@@ -47,7 +48,7 @@ namespace scene
|
|||||||
//the gui_shader is used of rendering the gui models (for example the pause buttons).
|
//the gui_shader is used of rendering the gui models (for example the pause buttons).
|
||||||
shaders::GuiShader* gui_shader;
|
shaders::GuiShader* gui_shader;
|
||||||
//camera is the camera view of the game scene, this camera will be behind the main character.
|
//camera is the camera view of the game scene, this camera will be behind the main character.
|
||||||
entities::Camera *camera;
|
std::unique_ptr<entities::Camera> camera;
|
||||||
//guis is a list of all the gui components that needs to be load in the scene.
|
//guis is a list of all the gui components that needs to be load in the scene.
|
||||||
std::vector<gui::GuiTexture*> guis;
|
std::vector<gui::GuiTexture*> guis;
|
||||||
//pause_guis is a list of components that will be rendered when the game is paused.
|
//pause_guis is a list of components that will be rendered when the game is paused.
|
||||||
|
|||||||
@@ -41,16 +41,27 @@ namespace scene
|
|||||||
}
|
}
|
||||||
|
|
||||||
gui::Button* ConvertGuiTextureToButton(gui::GuiTexture* texture) {
|
gui::Button* ConvertGuiTextureToButton(gui::GuiTexture* texture) {
|
||||||
|
gui::Button* button;
|
||||||
if (texture != NULL)
|
if (texture != NULL)
|
||||||
|
{
|
||||||
|
|
||||||
if (texture->GetType() == gui::GuiType::BUTTON) {
|
if (texture->GetType() == gui::GuiType::BUTTON) {
|
||||||
|
|
||||||
gui::Button* button = (gui::Button*)texture;
|
button = (gui::Button*)texture;
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return NULL;
|
button = nullptr;
|
||||||
|
return button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
button = nullptr;
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*gui::InteractableGui* ConvertGuiTextureToInteractableGui(gui::GuiTexture* texture) {
|
/*gui::InteractableGui* ConvertGuiTextureToInteractableGui(gui::GuiTexture* texture) {
|
||||||
if (texture != NULL)
|
if (texture != NULL)
|
||||||
@@ -121,10 +132,11 @@ namespace scene
|
|||||||
update(window);
|
update(window);
|
||||||
|
|
||||||
if (hand_mode) {
|
if (hand_mode) {
|
||||||
cameraFrame = objDetect.readCamera();
|
cameraFrame = objDetect.ReadCamera();
|
||||||
|
|
||||||
//Get hand state from camera
|
//Get hand state from camera
|
||||||
bool hand_detection = objDetect.detectHand(cameraFrame);
|
bool detect = false;
|
||||||
|
bool hand_detection = objDetect.DetectHand(cameraFrame,detect);
|
||||||
|
|
||||||
if (hand_detection)
|
if (hand_detection)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
<ClCompile Include="src\computervision\calibration\HandCalibrator.cpp" />
|
<ClCompile Include="src\computervision\calibration\HandCalibrator.cpp" />
|
||||||
<ClCompile Include="src\computervision\HandDetectRegion.cpp" />
|
<ClCompile Include="src\computervision\HandDetectRegion.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\MenuTest.cpp" />
|
<ClCompile Include="src\computervision\MenuTest.cpp" />
|
||||||
<ClCompile Include="src\computervision\async\async_arm_detection.cpp" />
|
<ClCompile Include="src\computervision\async\async_arm_detection.cpp" />
|
||||||
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
||||||
|
|||||||
@@ -80,9 +80,6 @@
|
|||||||
<ClCompile Include="src\computervision\FingerCount.cpp">
|
<ClCompile Include="src\computervision\FingerCount.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\computervision\FaceDetector.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -90,6 +87,8 @@
|
|||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\scenes\scene.cpp">
|
<ClCompile Include="src\scenes\scene.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="src\entities\house_generator.cpp">
|
<ClCompile Include="src\entities\house_generator.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -164,9 +163,6 @@
|
|||||||
<ClInclude Include="src\computervision\FingerCount.h">
|
<ClInclude Include="src\computervision\FingerCount.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\computervision\FaceDetector.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
Reference in New Issue
Block a user