2018-09-14 22:09:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "AutoPrerenderingScene.h"
|
2018-09-19 07:52:42 +00:00
|
|
|
#include "LitTypes.h"
|
2018-09-14 22:09:43 +00:00
|
|
|
#include "Camera.h"
|
|
|
|
#include "Batched.h"
|
2018-09-15 01:29:05 +00:00
|
|
|
#include "LitBatch.h"
|
2018-09-14 22:09:43 +00:00
|
|
|
#include "LitShaderProgram.h"
|
|
|
|
|
|
|
|
namespace charcoal
|
|
|
|
{
|
|
|
|
namespace builtin
|
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
namespace lit
|
2018-09-14 22:09:43 +00:00
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
// A scene lit by the Phong Reflection Model (See https://en.wikipedia.org/wiki/Phong_reflection_model )
|
|
|
|
class Scene : public AutoPrerenderingScene, public Batched<Renderable, Batch>
|
2018-09-15 01:29:05 +00:00
|
|
|
{
|
2018-09-19 07:52:42 +00:00
|
|
|
public:
|
|
|
|
Scene(Application& application) : AutoPrerenderingScene(application) {}
|
|
|
|
virtual ~Scene() {}
|
|
|
|
|
|
|
|
void init() override;
|
|
|
|
|
|
|
|
void use() override;
|
|
|
|
|
|
|
|
void unuse() override;
|
|
|
|
|
|
|
|
void render() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void set_camera(const Camera* p_camera) { m_p_camera = p_camera; }
|
|
|
|
|
|
|
|
Light& add_light(
|
|
|
|
const Position& position,
|
|
|
|
const Light::Power& power,
|
|
|
|
const ColorRGB ambient,
|
|
|
|
const ColorRGB diffuse,
|
|
|
|
const ColorRGB specular,
|
|
|
|
const Light::Fade& fade
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_lights.emplace_back(position, power, ambient, diffuse, specular, fade);
|
|
|
|
return m_lights.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ShaderProgram m_shader_program;
|
|
|
|
const Camera* m_p_camera = nullptr;
|
|
|
|
std::vector<Light> m_lights;
|
|
|
|
};
|
|
|
|
}
|
2018-09-14 22:09:43 +00:00
|
|
|
}
|
|
|
|
}
|