Start day 16, scene refactor.
This commit is contained in:
parent
f2a20876f3
commit
3041ae0172
73 changed files with 14114 additions and 0 deletions
107
16-scene-refactor/src/scene.hpp
Normal file
107
16-scene-refactor/src/scene.hpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "shader.hpp"
|
||||
#include "model.hpp"
|
||||
#include "shader.hpp"
|
||||
#include "model.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "scene.hpp"
|
||||
#include <vector>
|
||||
|
||||
const unsigned int SCR_WIDTH = 800;
|
||||
const unsigned int SCR_HEIGHT = 600;
|
||||
|
||||
const float AMBIENT_LEVEL = 0.25f;
|
||||
|
||||
struct Scene {
|
||||
Shader shader;
|
||||
Shader lightShader;
|
||||
std::vector<Model> models;
|
||||
|
||||
Lighting light{
|
||||
.directional={
|
||||
.direction={-0.2f, -1.0f, -0.3f},
|
||||
.ambient={0.2f, 0.2f, 0.2f},
|
||||
.diffuse={0.8f, 0.8f, 0.8f},
|
||||
.specular={1.0f, 1.0f, 1.0f},
|
||||
},
|
||||
.positioned={
|
||||
{
|
||||
.position={1.2f, 1.0f, 2.0f},
|
||||
.direction={-0.2f, -1.0f, -0.3f},
|
||||
.ambient={0.2f, 0.2f, 0.2f},
|
||||
.diffuse={0.8f, 0.8f, 0.8f},
|
||||
.specular={1.0f, 1.0f, 1.0f},
|
||||
.constant=1.0f,
|
||||
.linear=0.09f,
|
||||
.quadratic=0.032f,
|
||||
.cutOff=12.5f,
|
||||
.outerCutOff=17.5f,
|
||||
},
|
||||
{
|
||||
.position={-1.2f, -1.0f, -2.0f},
|
||||
.direction={0.2f, 1.0f, 0.3f},
|
||||
.ambient={0.2f, 0.2f, 0.2f},
|
||||
.diffuse={0.8f, 0.8f, 0.8f},
|
||||
.specular={1.0f, 1.0f, 1.0f},
|
||||
.constant=1.0f,
|
||||
.linear=0.09f,
|
||||
.quadratic=0.032f,
|
||||
.cutOff=12.5f,
|
||||
.outerCutOff=17.5f,
|
||||
},
|
||||
},
|
||||
.spot={
|
||||
.position={2.2f, 1.0f, 2.0f},
|
||||
.direction={0.0f, 0.0f, -1.0f},
|
||||
.ambient={0.2f, 0.2f, 0.2f},
|
||||
.diffuse={0.8f, 0.8f, 0.8f},
|
||||
.specular={1.0f, 1.0f, 1.0f},
|
||||
.constant=1.0f,
|
||||
.linear=0.09f,
|
||||
.quadratic=0.032f,
|
||||
.cutOff=12.5f,
|
||||
.outerCutOff=17.5f,
|
||||
},
|
||||
};
|
||||
|
||||
// positions all containers
|
||||
std::vector<glm::vec3> positions{
|
||||
{0.0f, 0.0f, 0.0f},
|
||||
{2.0f, 5.0f, -15.0f},
|
||||
{-1.5f, -2.2f, -2.5f},
|
||||
{-3.8f, -2.0f, -12.3f},
|
||||
{ 2.4f, -0.4f, -3.5f},
|
||||
{-1.7f, 3.0f, -7.5f},
|
||||
{ 1.3f, -2.0f, -2.5f},
|
||||
{ 1.5f, 2.0f, -2.5f},
|
||||
{ 1.5f, 0.2f, -1.5f},
|
||||
{-1.3f, 1.0f, -1.5f}
|
||||
};
|
||||
|
||||
Camera camera{
|
||||
.pos={2.2f, 1.0f, 2.0f},
|
||||
.movementSpeed=2.0f
|
||||
};
|
||||
|
||||
Material cubeMaterial{
|
||||
.ambient = {1.0f, 0.5f, 0.31f},
|
||||
.shininess = 32.0f,
|
||||
.diffuseMap = 0,
|
||||
.specularMap = 0,
|
||||
};
|
||||
|
||||
float deltaTime = 0.0f;
|
||||
float lastFrame = 0.0f;
|
||||
|
||||
void updateDelta();
|
||||
void configure();
|
||||
void draw_model(Model& scene_model, glm::mat4& projection, glm::mat4& view, glm::vec3& position);
|
||||
void render(GLFWwindow* window);
|
||||
void cleanup();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue