[ADD] load bee in scene
This commit is contained in:
21593
res/beeTwo.obj
Normal file
21593
res/beeTwo.obj
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,6 +10,8 @@ namespace entities
|
||||
void Camera::Move(GLFWwindow* window)
|
||||
{
|
||||
float movement_speed = 0;
|
||||
float up_down_speed = 0;
|
||||
float side_speed = 0;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
{
|
||||
@@ -23,28 +25,21 @@ namespace entities
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
{
|
||||
rotation.y += ROT_SPEED;
|
||||
side_speed += SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
{
|
||||
rotation.y -= ROT_SPEED;
|
||||
side_speed -= SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||
{
|
||||
rotation.x -= ROT_SPEED;
|
||||
up_down_speed += UP_SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||
{
|
||||
rotation.x += ROT_SPEED;
|
||||
}
|
||||
|
||||
float dx = glm::cos(glm::radians(rotation.y + 90)) * movement_speed;
|
||||
float dz = glm::sin(glm::radians(rotation.y + 90)) * movement_speed;
|
||||
|
||||
position.x += dx;
|
||||
position.z += dz;
|
||||
position.x += side_speed;
|
||||
position.z += movement_speed;
|
||||
position.y += up_down_speed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace entities
|
||||
{
|
||||
private:
|
||||
// The movement speed of the camera
|
||||
const float SPEED = 0.52f;
|
||||
const float ROT_SPEED = 1.0f;
|
||||
const float SPEED = 0.5f;
|
||||
const float UP_SPEED = 0.9f;
|
||||
|
||||
glm::vec3 position;
|
||||
glm::vec3 rotation;
|
||||
|
||||
60
src/entities/main_character.cpp
Normal file
60
src/entities/main_character.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "main_character.h"
|
||||
#include "../models/Model.h"
|
||||
#include <iostream>
|
||||
#include "entity.h"
|
||||
#include"../renderEngine/Renderer.h"
|
||||
#include"../renderEngine/obj_loader.h"
|
||||
#include"../renderEngine/loader.h"
|
||||
namespace entities
|
||||
{
|
||||
main_character::main_character(const models::TexturedModel& model, const glm::vec3& position,
|
||||
const glm::vec3& rotation, float scale, const collision::Box& bounding_box)
|
||||
: CollisionEntity(model, position, rotation, scale, bounding_box) {
|
||||
|
||||
}
|
||||
|
||||
Entity main_character::loadCharacter()
|
||||
{
|
||||
models::RawModel raw_model = render_engine::LoadObjModel("res/beeTwo.obj");
|
||||
models::ModelTexture texture = { render_engine::loader::LoadTexture("res/Texture.png") };
|
||||
texture.shine_damper = 10;
|
||||
texture.reflectivity = 0;
|
||||
models::TexturedModel model = { raw_model, texture };
|
||||
entities::Entity entity(model, glm::vec3(0, -50, -100), glm::vec3(0, 90, 0), 5);
|
||||
return entity;
|
||||
}
|
||||
glm::vec3 main_character::move(GLFWwindow* window)
|
||||
{
|
||||
float movement_speed = 0;
|
||||
float up_down_speed = 0;
|
||||
float side_speed = 0;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
{
|
||||
movement_speed -= SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
{
|
||||
movement_speed += SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
{
|
||||
side_speed += SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
{
|
||||
side_speed -= SPEED;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||
{
|
||||
up_down_speed += UP_SPEED;
|
||||
}
|
||||
return glm::vec3(side_speed, movement_speed, up_down_speed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
src/entities/main_character.h
Normal file
18
src/entities/main_character.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "collision_entity.h"
|
||||
#include "../shaders/entity_shader.h"
|
||||
|
||||
namespace entities
|
||||
{
|
||||
|
||||
class main_character : public CollisionEntity {
|
||||
const int SPEED = 10;
|
||||
const float UP_SPEED = 1.0f;
|
||||
public:
|
||||
main_character(const models::TexturedModel& model, const glm::vec3& position,
|
||||
const glm::vec3& rotation, float scale, const collision::Box& bounding_box);
|
||||
Entity loadCharacter();
|
||||
glm::vec3 move(GLFWwindow* window);
|
||||
};
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "in_Game_Scene.h"
|
||||
#include "startup_Scene.h"
|
||||
#include "../entities/main_character.h"
|
||||
#include "../gui/gui_interactable.h"
|
||||
#include "../models/model.h"
|
||||
#include "../renderEngine/loader.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
namespace scene
|
||||
{
|
||||
std::vector<entities::Entity> entities;
|
||||
std::vector<entities::main_character> mainCharacter;
|
||||
std::vector<entities::Light> lights;
|
||||
models::RawModel raw_model;
|
||||
models::ModelTexture texture;
|
||||
@@ -48,6 +50,9 @@ namespace scene
|
||||
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);
|
||||
}
|
||||
entities::main_character character{ model, glm::vec3(0, -50, -100), glm::vec3(0, 90, 0), 5,collision::Box() };
|
||||
entities.push_back(character.loadCharacter());
|
||||
mainCharacter.push_back(character);
|
||||
|
||||
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)));
|
||||
@@ -94,6 +99,7 @@ namespace scene
|
||||
{
|
||||
render_engine::renderer::Render(entity, *shader);
|
||||
}
|
||||
|
||||
|
||||
// Render GUI items
|
||||
render_engine::renderer::Render(guis, *gui_shader);
|
||||
@@ -104,12 +110,18 @@ namespace scene
|
||||
|
||||
void scene::In_Game_Scene::update(GLFWwindow* window)
|
||||
{
|
||||
camera.Move(window);
|
||||
//camera.Move(window);
|
||||
|
||||
entities::main_character character = mainCharacter[0];
|
||||
glm::vec3 movement = character.move(window);
|
||||
character.IncreasePosition(movement);
|
||||
std::cout <<"x: "<< character.GetPosition().x << "\ny: " << character.GetPosition().y << "\nz: " << character.GetPosition().z << "\n";
|
||||
std::cout <<"x get: "<< movement.x << "\ny get: " << movement.y << "\nz get: " << movement.z << "\n";
|
||||
}
|
||||
|
||||
void scene::In_Game_Scene::onKey(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
{
|
||||
return_value = scene::Scenes::STOP;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\collision\collision_handler.cpp" />
|
||||
<ClCompile Include="src\entities\main_character.cpp" />
|
||||
<ClCompile Include="src\scenes\in_Game_Scene.cpp" />
|
||||
<ClCompile Include="src\computervision\FaceDetector.cpp" />
|
||||
<ClCompile Include="src\computervision\ObjectDetection.cpp" />
|
||||
@@ -43,6 +44,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\collision\collision.h" />
|
||||
<ClInclude Include="src\collision\collision_handler.h" />
|
||||
<ClInclude Include="src\entities\main_character.h" />
|
||||
<ClInclude Include="src\scenes\in_Game_Scene.h" />
|
||||
<ClInclude Include="src\scenes\scene.h" />
|
||||
<ClInclude Include="src\computervision\FaceDetector.h" />
|
||||
|
||||
@@ -75,6 +75,9 @@
|
||||
<ClCompile Include="src\computervision\BackgroundRemover.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\entities\main_character.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\entities\Camera.h">
|
||||
@@ -152,6 +155,9 @@
|
||||
<ClInclude Include="src\computervision\BackgroundRemover.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\entities\main_character.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="res\haarcascade_frontalface_alt.xml" />
|
||||
|
||||
Reference in New Issue
Block a user