camera needs a big ol refractor
This commit is contained in:
@@ -32,6 +32,9 @@ public:
|
||||
void UpdateEulerLookDirection(float roll, float pitch, float yaw);
|
||||
void UpdateLookDirection(glm::vec3 lookDirection);
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
glm::vec3 Position = {};
|
||||
float Roll, Pitch, Yaw;
|
||||
float FOV = 45.0f;
|
||||
|
||||
58
src/random.hpp
Normal file
58
src/random.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "singleton.hpp"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <random>
|
||||
|
||||
// TODO: compile time precomputed random numbers
|
||||
|
||||
namespace inferno {
|
||||
|
||||
class Random : public helpers::Singleton<Random>
|
||||
{
|
||||
public:
|
||||
inline Random()
|
||||
: mGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline ~Random()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline float rand(float l, float u)
|
||||
{
|
||||
static std::uniform_real_distribution<float> distribution(l, u);
|
||||
return distribution(mGenerator);
|
||||
}
|
||||
|
||||
inline float rand01() {
|
||||
static std::uniform_real_distribution<float> distribution(0, 1);
|
||||
return distribution(mGenerator);
|
||||
}
|
||||
|
||||
inline float rand11() {
|
||||
static std::uniform_real_distribution<float> distribution(-1, 1);
|
||||
return distribution(mGenerator);
|
||||
}
|
||||
|
||||
inline glm::vec3 randomUnitVector()
|
||||
{
|
||||
static std::uniform_real_distribution<float> distribution(-1, 1);
|
||||
|
||||
float x = distribution(mGenerator);
|
||||
float y = distribution(mGenerator);
|
||||
float z = distribution(mGenerator);
|
||||
|
||||
return glm::normalize(glm::vec3({x,y,z}));
|
||||
}
|
||||
|
||||
private:
|
||||
std::default_random_engine mGenerator;
|
||||
};
|
||||
|
||||
}
|
||||
28
src/renderer/ray_source.cpp
Normal file
28
src/renderer/ray_source.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "ray_source.hpp"
|
||||
|
||||
using namespace inferno;
|
||||
|
||||
RaySource::RaySource()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RaySource::~RaySource()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RaySource::cameraUpdate(Camera* camera)
|
||||
{
|
||||
mReferenceCamera = camera;
|
||||
}
|
||||
|
||||
void RaySource::generate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RayField RaySource::getInitialRays(bool MSAA)
|
||||
{
|
||||
return RayField{};
|
||||
}
|
||||
@@ -1,17 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <graphics.hpp>
|
||||
|
||||
#include <tracing/ray.hpp>
|
||||
|
||||
namespace inferno {
|
||||
|
||||
typedef std::vector<Ray*> RayField;
|
||||
|
||||
class Camera;
|
||||
|
||||
class RaySource
|
||||
{
|
||||
public:
|
||||
RaySource();
|
||||
~RaySource();
|
||||
|
||||
void setCast
|
||||
void cameraUpdate(Camera* camera);
|
||||
void generate();
|
||||
|
||||
RayField getInitialRays(bool MSAA);
|
||||
|
||||
private:
|
||||
Camera* mReferenceCamera;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <scene/scene.hpp>
|
||||
|
||||
#include "hart_module.hpp"
|
||||
#include "ray_source.hpp"
|
||||
|
||||
using namespace inferno;
|
||||
|
||||
RayRenderer::RayRenderer(HHM* accelIface)
|
||||
: mIface(accelIface)
|
||||
, mRaySource(new RaySource)
|
||||
{
|
||||
mTarget = new glm::fvec4[mRenderTargetSize.x * mRenderTargetSize.y];
|
||||
|
||||
@@ -55,12 +57,16 @@ GLuint RayRenderer::getRenderedTexture()
|
||||
|
||||
void RayRenderer::prepare()
|
||||
{
|
||||
assert(mCurrentScene == NULL);
|
||||
assert(mCurrentScene != NULL);
|
||||
mIface->newScene(mCurrentScene);
|
||||
|
||||
mRaySource->cameraUpdate(mCurrentScene->getCamera());
|
||||
}
|
||||
|
||||
void RayRenderer::draw()
|
||||
{
|
||||
RayField startRays = mRaySource->getInitialRays(true);
|
||||
|
||||
for (int x = 0; x < mRenderTargetSize.x; x++)
|
||||
for (int y = 0; y < mRenderTargetSize.y; y++)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace inferno {
|
||||
class HHM;
|
||||
|
||||
class Scene;
|
||||
class Colour;
|
||||
class RaySource;
|
||||
|
||||
class RayRenderer
|
||||
{
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
glm::ivec2 mRenderTargetSize = {300, 300};
|
||||
|
||||
Scene* mCurrentScene = nullptr;
|
||||
RaySource* mRaySource;
|
||||
|
||||
private:
|
||||
HHM* mIface;
|
||||
|
||||
Reference in New Issue
Block a user