Starting day 19, blending.
This commit is contained in:
parent
dc973009fd
commit
128f522089
94 changed files with 15008 additions and 0 deletions
105
19-blending/src/components.hpp
Normal file
105
19-blending/src/components.hpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "json.hpp"
|
||||
|
||||
const unsigned int SCR_WIDTH = 800;
|
||||
const unsigned int SCR_HEIGHT = 600;
|
||||
|
||||
#define MAX_LIGHTS 4
|
||||
|
||||
namespace components {
|
||||
template <typename T> 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;
|
||||
|
||||
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);
|
||||
|
||||
struct Lighting {
|
||||
std::vector<Light> directional;
|
||||
std::vector<Light> positioned;
|
||||
std::vector<Light> 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 Thing {
|
||||
std::string model;
|
||||
Position position;
|
||||
std::string material;
|
||||
};
|
||||
|
||||
ENROLL_COMPONENT(Thing, model, position, material);
|
||||
|
||||
struct Shader {
|
||||
std::string vertex_path;
|
||||
std::string frag_path;
|
||||
};
|
||||
|
||||
ENROLL_COMPONENT(Shader, vertex_path, frag_path);
|
||||
|
||||
struct Scene {
|
||||
components::Shader shader;
|
||||
components::Shader light_shader;
|
||||
std::map<std::string, Material> materials;
|
||||
std::map<std::string, Model> models;
|
||||
std::vector<Thing> things;
|
||||
Camera camera;
|
||||
Lighting light;
|
||||
};
|
||||
|
||||
ENROLL_COMPONENT(Scene, shader, light_shader, materials, models, things, camera, light);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue