#pragma once #include #include #include #include "json.hpp" const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600; #define MAX_LIGHTS 4 namespace components { template struct NameOf; struct Material { glm::vec3 ambient{0.1f,0.1f,0.1f}; float shininess{32.0f}; unsigned int diffuseMap = 0; unsigned int specularMap = 0; }; ENROLL_COMPONENT(Material, ambient, shininess, diffuseMap, specularMap); struct Light { glm::vec3 position{0.0f, 0.0f, 0.0f}; glm::vec3 direction{0.0f, 0.0f, 0.0f}; glm::vec3 ambient{0.0f, 0.0f, 0.0f}; glm::vec3 diffuse{0.0f, 0.0f, 0.0f}; glm::vec3 specular{0.0f, 0.0f, 0.0f}; float constant=0.0f; float linear=0.0f; float quadratic=0.0f; float cut_off=0.0f; float outer_cut_off=0.0f; bool on=true; void adjust(float amount) { ambient += amount; diffuse += amount; specular += amount; } }; ENROLL_COMPONENT(Light, position, direction, ambient, diffuse, specular, constant, linear, quadratic, cut_off, outer_cut_off, on); struct Lighting { std::vector directional; std::vector positioned; std::vector spot; Light camera; }; ENROLL_COMPONENT(Lighting, directional, positioned, spot, camera); struct Camera { glm::vec3 position{0.0f, 0.0f, 3.0f}; glm::vec3 front{0.0f, 0.0f, -1.0f}; glm::vec3 up{0.0f, 1.0f, 0.0f}; glm::vec3 direction{0.0f, 0.0f, 0.0f}; float movement_speed = 20.0f; }; ENROLL_COMPONENT(Camera, position, front, up, direction, movement_speed); struct Model { std::string directory; std::string model_path; }; ENROLL_COMPONENT(Model, directory, model_path); using Position = glm::vec3; struct Rotation { float angle = 0; glm::vec3 axes{1.0f, 0.0f, 0.0f}; }; ENROLL_COMPONENT(Rotation, angle, axes); struct Thing { std::string model; std::string material; Position position; Rotation rotation; float scale; }; ENROLL_COMPONENT(Thing, model, material, position, rotation, scale); struct Shader { std::string vertex_path; std::string frag_path; }; ENROLL_COMPONENT(Shader, vertex_path, frag_path); struct Scene { components::Shader shader; components::Shader screen_shader; components::Shader skybox_shader; std::vector skybox_faces; std::unordered_map materials; std::unordered_map models; std::vector things; Camera camera; Lighting light; }; ENROLL_COMPONENT(Scene, shader, screen_shader, skybox_shader, skybox_faces, materials, models, things, camera, light); }