[ADD] custom rendering system
This commit is contained in:
32
src/entities/Camera.cpp
Normal file
32
src/entities/Camera.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "Camera.h"
|
||||
|
||||
namespace entities
|
||||
{
|
||||
Camera::Camera(const ::glm::vec3& position, const ::glm::vec3& rotation)
|
||||
: position(position),
|
||||
rotation(rotation)
|
||||
{}
|
||||
|
||||
void Camera::move(GLFWwindow* window)
|
||||
{
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
{
|
||||
position.z -= speed;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
{
|
||||
position.z += speed;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
{
|
||||
position.x += speed;
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
{
|
||||
position.x -= speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/entities/Camera.h
Normal file
24
src/entities/Camera.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
namespace entities
|
||||
{
|
||||
class Camera
|
||||
{
|
||||
private:
|
||||
float speed = 0.02f;
|
||||
|
||||
glm::vec3 position;
|
||||
glm::vec3 rotation;
|
||||
|
||||
public:
|
||||
Camera(const ::glm::vec3& position, const ::glm::vec3& rotation);
|
||||
|
||||
void move(GLFWwindow* window);
|
||||
|
||||
inline glm::vec3 getPosition() const{ return position; }
|
||||
inline glm::vec3 getRotation() const{ return rotation; }
|
||||
};
|
||||
}
|
||||
29
src/entities/Entity.cpp
Normal file
29
src/entities/Entity.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "Entity.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace entities
|
||||
{
|
||||
Entity::Entity(const models::TexturedModel& model, const glm::vec3& position, const glm::vec3& rotation, float scale)
|
||||
: model(model),
|
||||
position(position),
|
||||
rotation(rotation),
|
||||
scale(scale)
|
||||
{
|
||||
}
|
||||
|
||||
void Entity::increasePosition(const glm::vec3& distance)
|
||||
{
|
||||
position.x += distance.x;
|
||||
position.y += distance.y;
|
||||
position.z += distance.z;
|
||||
}
|
||||
|
||||
void Entity::increaseRotation(const glm::vec3& rotation)
|
||||
{
|
||||
this->rotation.x += rotation.x;
|
||||
this->rotation.y += rotation.y;
|
||||
this->rotation.z += rotation.z;
|
||||
}
|
||||
}
|
||||
|
||||
31
src/entities/Entity.h
Normal file
31
src/entities/Entity.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include "../models/Model.h"
|
||||
|
||||
namespace entities
|
||||
{
|
||||
class Entity
|
||||
{
|
||||
private:
|
||||
models::TexturedModel model;
|
||||
glm::vec3 position;
|
||||
glm::vec3 rotation;
|
||||
float scale;
|
||||
|
||||
public:
|
||||
Entity(const models::TexturedModel& model, const glm::vec3& position, const glm::vec3& rotation, float scale);
|
||||
|
||||
void increasePosition(const glm::vec3& distance);
|
||||
void increaseRotation(const glm::vec3& rotation);
|
||||
|
||||
inline models::TexturedModel getModel() const{return model;}
|
||||
inline void set_model(const ::models::TexturedModel& model) { this->model = model; }
|
||||
inline glm::vec3 getPosition() const { return position; }
|
||||
inline void set_position(const ::glm::vec3& position) { this->position = position; }
|
||||
inline glm::vec3 getRotation() const { return rotation; }
|
||||
inline void set_rotation(const ::glm::vec3& rotation) { this->rotation = rotation; }
|
||||
inline float getScale() const { return scale; }
|
||||
inline void set_scale(const float scale) { this->scale = scale; }
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user