[ADD] load bee in scene

This commit is contained in:
Nathalie Seen
2021-06-04 10:01:13 +02:00
parent 739b4a9eb6
commit c25efec103
8 changed files with 21703 additions and 17 deletions

View File

@@ -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;
}
}

View File

@@ -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;

View 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);
}
}

View 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);
};
}