Additions to editor
Entities can be selected using the scene-explorer, Components can be viewed and edited through the inspector , empty Entities can be added through the mainmenu bar
This commit is contained in:
		@ -3,7 +3,7 @@
 | 
			
		||||
#include "../Graphics/Memory/VertexArray.h"
 | 
			
		||||
#include "../Graphics/Memory/Buffer.h"
 | 
			
		||||
#include <glad/glad.h>
 | 
			
		||||
 | 
			
		||||
#include <glm/gtc/type_precision.hpp>
 | 
			
		||||
float Angle = 0.0;
 | 
			
		||||
Camera cam = Camera(glm::vec3(12.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
 | 
			
		||||
glm::mat4 projection = glm::perspective(glm::radians(cam.Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
 | 
			
		||||
@ -63,8 +63,17 @@ void BarinkEngine::Renderer::Render(Scene& scene)
 | 
			
		||||
			renderComponent.shader.setUniformFloat("lighting.strength", light.Strength);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), trans.Rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
 | 
			
		||||
		rotation *= glm::rotate(glm::mat4(1.0f), trans.Rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
 | 
			
		||||
		rotation *= glm::rotate(glm::mat4(1.0f), trans.Rotation.z, glm::vec3(0.0f, 0.0f, 1.0f));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), trans.Position) * glm::scale(glm::mat4(1.0f), trans.Scale) *rotation;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		renderComponent.shader.setUniformVec3("Color", renderComponent.color);
 | 
			
		||||
		renderComponent.shader.setUniformMat4("M", trans.transform);
 | 
			
		||||
		renderComponent.shader.setUniformMat4("M", modelMatrix);
 | 
			
		||||
		renderComponent.shader.setUniformMat4("V", cam.GetViewMatrix());
 | 
			
		||||
		renderComponent.shader.setUniformMat4("P", projection);
 | 
			
		||||
 | 
			
		||||
@ -82,7 +91,7 @@ void BarinkEngine::Renderer::Render(Framebuffer& framebuffer, Scene& scene)
 | 
			
		||||
 | 
			
		||||
	glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.GetId());
 | 
			
		||||
 | 
			
		||||
	glClearColor(.5f, .0f, .5f, 1.0f);
 | 
			
		||||
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
 | 
			
		||||
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 | 
			
		||||
 | 
			
		||||
	Render(scene);
 | 
			
		||||
 | 
			
		||||
@ -8,14 +8,14 @@ namespace BarinkEngine {
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct TransformComponent {
 | 
			
		||||
		glm::mat4 transform = glm::mat4(1.0f);
 | 
			
		||||
 | 
			
		||||
		glm::vec3 Position = glm::vec3(0.0f);
 | 
			
		||||
		glm::vec3 Rotation = glm::vec3(0.0f);
 | 
			
		||||
		glm::vec3 Scale = glm::vec3(1.0f);
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct LightComponent {
 | 
			
		||||
		float Strength = 1.0f;
 | 
			
		||||
		glm::vec3 Color = glm::vec3(1.0f, 1.0f, 1.0f);
 | 
			
		||||
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,11 @@ namespace BarinkEngine {
 | 
			
		||||
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	struct ScriptComponent {
 | 
			
		||||
		std::string file; // TODO : replace with proper properties
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct Render3DComponent {
 | 
			
		||||
		unsigned int VAO = 0;
 | 
			
		||||
		unsigned int IBO = 0;
 | 
			
		||||
 | 
			
		||||
@ -2,13 +2,13 @@
 | 
			
		||||
#include <entt/entt.hpp>
 | 
			
		||||
class Scene;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Entity {
 | 
			
		||||
public:
 | 
			
		||||
	Entity() = default;
 | 
			
		||||
	Entity(entt::entity e, Scene* scene);
 | 
			
		||||
	Entity(const Entity& other) = default;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	template<class T >
 | 
			
		||||
	T& AddComponent() {
 | 
			
		||||
		return m_scene->m_registry.emplace<T>(m_entity);
 | 
			
		||||
@ -19,6 +19,19 @@ public:
 | 
			
		||||
		return m_scene->m_registry.get<T>(m_entity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	template<class T>
 | 
			
		||||
	bool HasComponent() {
 | 
			
		||||
		return m_scene->getReg().all_of<T>(m_entity);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	// NOTE: Not Scene context aware!!
 | 
			
		||||
	bool operator== (Entity& other) {
 | 
			
		||||
		return m_entity == other.m_entity;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	entt::entity m_entity;
 | 
			
		||||
	Scene* m_scene;
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@
 | 
			
		||||
#include "Components.h"
 | 
			
		||||
Scene::Scene()
 | 
			
		||||
{
 | 
			
		||||
	m_registry = entt::basic_registry();
 | 
			
		||||
	//m_registry = entt::basic_registry();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Scene::~Scene()
 | 
			
		||||
@ -21,3 +21,4 @@ Entity Scene::AddEntity(std::string name)
 | 
			
		||||
	return entity;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user