gltut / Tut 16 Gamma and Textures / LightEnv.h


#include <map>
#include <string>
#include "../framework/Timer.h"
#include <glm/glm.hpp>
#include "../framework/Interpolators.h"

//Lighting Environment
struct PerLight
	glm::vec4 cameraSpaceLightPos;
	glm::vec4 lightIntensity;

const int MAX_NUMBER_OF_LIGHTS = 4;

struct LightBlock
	glm::vec4 ambientIntensity;
	float lightAttenuation;
	float maxIntensity;
	float padding[2];
	PerLight lights[MAX_NUMBER_OF_LIGHTS];

class LightEnv
	LightEnv(const std::string &envFilename);

	void UpdateTime();

	void TogglePause();

	void SetPause(bool pause = true);

	bool IsPaused() const
		return m_sunTimer.IsPaused();

	void RewindTime(float secRewind);

	void FastForwardTime(float secFF);

	glm::vec4 GetBackgroundColor() const
		return m_backgroundInterpolator.Interpolate(m_sunTimer.GetAlpha());

	float GetMaxIntensity() const
		return m_maxIntensityInterpolator.Interpolate(m_sunTimer.GetAlpha());

	glm::vec4 GetSunlightDirection() const;

	glm::vec4 GetSunlightIntensity() const
		return m_sunlightInterpolator.Interpolate(m_sunTimer.GetAlpha());

	float GetElapsedTime() const
		return m_sunTimer.GetProgression();

	int GetNumLights() const;

	LightBlock GetLightBlock(const glm::mat4 &worldToCamera) const;

	typedef Framework::ConstVelLinearInterpolator<glm::vec3> LightInterpolator;
	typedef std::map<std::string, Framework::Timer> ExtraTimerMap;

	Framework::Timer m_sunTimer;
	Framework::TimedLinearInterpolator<glm::vec4> m_ambientInterpolator;
	Framework::TimedLinearInterpolator<glm::vec4> m_backgroundInterpolator;
	Framework::TimedLinearInterpolator<glm::vec4> m_sunlightInterpolator;
	Framework::TimedLinearInterpolator<float> m_maxIntensityInterpolator;

	std::vector<LightInterpolator> m_lightPos;
	std::vector<glm::vec4> m_lightIntensity;
	std::vector<Framework::Timer> m_lightTimers;

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.