adding materials, adding serialization for meshes and materials, random fixes

This commit is contained in:
Erris
2026-03-03 08:51:02 +01:00
parent b7e5ceb1d1
commit 4a624cfe70
16 changed files with 222 additions and 22 deletions

View File

@@ -10,6 +10,14 @@
namespace OpenEngine {
// SHOULD BE MOVED ==================================
enum class PrimitiveType
{
None = 0,
Quad,
Cube
};
struct MeshVertex
{
glm::vec3 position;
@@ -19,6 +27,15 @@ namespace OpenEngine {
uint32_t id = -1;
};
struct Material
{
glm::vec4 albedo = { 1.0f, 1.0f, 1.0f, 1.0f };
float roughness = 1.0f;
float metallic = 1.0f;
float ambient_strength = 1.0f;
float specular_strength = 1.0f;
};
struct Mesh
{
Ref<VertexArray> vertex_array;
@@ -46,7 +63,8 @@ namespace OpenEngine {
static void BeginScene(const EditorCamera& camera);
static void EndScene();
static void DrawMesh(const Ref<Mesh>& mesh, const glm::mat4& transform);
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
const glm::mat4& transform);
};
}

View File

@@ -86,17 +86,28 @@ namespace OpenEngine {
(delete nsc->instance);
nsc->instance = nullptr;
};
}
};
};
struct MeshComponent
{
Ref<Mesh> mesh;
PrimitiveType primitive_type = PrimitiveType::None;
MeshComponent() = default;
MeshComponent(const MeshComponent&) = default;
MeshComponent(const Ref<Mesh>& mesh)
: mesh(mesh) {}
: mesh(mesh) {};
};
struct MaterialComponent
{
Material material;
MaterialComponent() = default;
MaterialComponent(const MaterialComponent&) = default;
MaterialComponent(const Material& material)
: material(material) {};
};
}

View File

@@ -40,7 +40,7 @@ namespace OpenEngine {
uint32_t viewport_width = 0, viewport_height = 0;
std::vector<entt::entity> entities_to_be_deleted;
std::vector<entt::entity> pending_deletion;
friend class SceneSerializer;
friend class Entity;