51 lines
984 B
C++
51 lines
984 B
C++
#ifndef LIGHT_H
|
|
#define LIGHT_H
|
|
|
|
#include <cmath>
|
|
|
|
#include <QObject>
|
|
#include <QOpenGLFunctions_4_5_Core>
|
|
#include <QVector4D>
|
|
#include <QVector3D>
|
|
#include <QDebug>
|
|
|
|
#include "types.h"
|
|
#include "shader.h"
|
|
|
|
class Light: public QObject, protected QOpenGLFunctions_4_5_Core
|
|
{
|
|
Q_OBJECT
|
|
|
|
private:
|
|
float m_timeOfDay;
|
|
int m_inclination;
|
|
|
|
float m_sunriseStart;
|
|
float m_sunriseEnd;
|
|
float m_sunsetStart;
|
|
float m_sunsetEnd;
|
|
|
|
float m_dayNightFactor;
|
|
|
|
QVector4D m_sunlightDirection;
|
|
|
|
void computeDayNightFactor();
|
|
public:
|
|
Light(int time, int angle);
|
|
void updateSunlightDirection();
|
|
void setUniforms(Shader* program, RenderPassType renderPass);
|
|
void initGl();
|
|
void addToTimeOfDay(float timeDelta);
|
|
|
|
public slots:
|
|
void setTimeOfDay(int time);
|
|
void setTimeOfDay(float time);
|
|
void setInclination(int angle);
|
|
|
|
signals:
|
|
void directionChanged(QVector3D newDirection);
|
|
void timeOfDayChanged(int newTime);
|
|
};
|
|
|
|
#endif // LIGHT_H
|