Jason McKesson avatar Jason McKesson committed 5ed67a0

Tut12: Dark lighting operational.
Updated one of the light movement.

Comments (0)

Files changed (17)

Tut 12 Dynamic Range/Lights.cpp

 	return ret;
 }
 
-const float g_fLightAttenuation = 1.0f / (15.0f * 15.0f);
+const float g_fHalfLightDistance = 70.0f;
+const float g_fLightAttenuation = 1.0f / (g_fHalfLightDistance * g_fHalfLightDistance);
 
 float distance(const glm::vec3 &lhs, const glm::vec3 &rhs)
 {
 	m_lightIntensity.resize(NUMBER_OF_POINT_LIGHTS, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f));
 
 	std::vector<glm::vec3> posValues;
-	posValues.reserve(20);
+	posValues.reserve(60);
 
 	posValues.push_back(glm::vec3(-50.0f, 30.0f, 70.0f));
 	posValues.push_back(glm::vec3(-70.0f, 30.0f, 50.0f));
 	m_lightPos[0].SetValues(posValues);
 	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 15.0f));
 
+	//Right-side light.
 	posValues.clear();
-	posValues.push_back(glm::vec3(80.0f, 30.0f, -70.0f));
-	posValues.push_back(glm::vec3(70.0f, 25.0f, 70.0f));
+	posValues.push_back(glm::vec3(100.0f, 6.0f, 75.0f));
+	posValues.push_back(glm::vec3(90.0f, 8.0f, 90.0f));
+	posValues.push_back(glm::vec3(75.0f, 10.0f, 100.0f));
+	posValues.push_back(glm::vec3(60.0f, 12.0f, 90.0f));
+	posValues.push_back(glm::vec3(50.0f, 14.0f, 75.0f));
+	posValues.push_back(glm::vec3(60.0f, 16.0f, 60.0f));
+	posValues.push_back(glm::vec3(75.0f, 18.0f, 50.0f));
+	posValues.push_back(glm::vec3(90.0f, 20.0f, 60.0f));
+	posValues.push_back(glm::vec3(100.0f, 22.0f, 75.0f));
+	posValues.push_back(glm::vec3(90.0f, 24.0f, 90.0f));
+	posValues.push_back(glm::vec3(75.0f, 26.0f, 100.0f));
+	posValues.push_back(glm::vec3(60.0f, 28.0f, 90.0f));
+	posValues.push_back(glm::vec3(50.0f, 30.0f, 75.0f));
+
+	posValues.push_back(glm::vec3(105.0f, 9.0f, -70.0f));
+	posValues.push_back(glm::vec3(105.0f, 10.0f, -90.0f));
+	posValues.push_back(glm::vec3(72.0f, 20.0f, -90.0f));
+	posValues.push_back(glm::vec3(72.0f, 22.0f, -70.0f));
+	posValues.push_back(glm::vec3(105.0f, 32.0f, -70.0f));
+	posValues.push_back(glm::vec3(105.0f, 34.0f, -90.0f));
+	posValues.push_back(glm::vec3(72.0f, 44.0f, -90.0f));
+
 	m_lightPos[1].SetValues(posValues);
-	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 15.0f));
+	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 25.0f));
 
+	//Left-side light. -7.0f, 30.0f, -14.0f
 	posValues.clear();
-	posValues.push_back(glm::vec3(-70.0f, 25.0f, -75.0f));
-	posValues.push_back(glm::vec3(-70.0f, 5.0f, 0.0f));
-	posValues.push_back(glm::vec3(-70.0f, 25.0f, 70.0f));
-	posValues.push_back(glm::vec3(0.0f, 50.0f, 0.0f));
+/*
+	posValues.push_back(glm::vec3(-7.0f, 35.0f, 1.0f));
+	posValues.push_back(glm::vec3(8.0f, 40.0f, -14.0f));
+	posValues.push_back(glm::vec3(-7.0f, 45.0f, -29.0f));
+	posValues.push_back(glm::vec3(-22.0f, 50.0f, -14.0f));
+	posValues.push_back(glm::vec3(-7.0f, 55.0f, 1.0f));
+	posValues.push_back(glm::vec3(8.0f, 60.0f, -14.0f));
+	posValues.push_back(glm::vec3(-7.0f, 65.0f, -29.0f));
+*/
+
+	//-83.0f, 14.0f, -77.0f
+	posValues.push_back(glm::vec3(-100.0f, 30.0f, -94.0f));
+	posValues.push_back(glm::vec3(-83.0f, 30.0f, -94.0f));
+	posValues.push_back(glm::vec3(-66.0f, 30.0f, -94.0f));
+	posValues.push_back(glm::vec3(-83.0f, 30.0f, -94.0f));
+	posValues.push_back(glm::vec3(-100.0f, 14.0f, -94.0f));
+
+
 	m_lightPos[2].SetValues(posValues);
-	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 15.0f));
+	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 5.0f));
 }
 
 typedef std::pair<glm::vec4, float> LightVectorData;
 
 struct PauseTimer
 {
-	void operator()(Framework::Timer &timer) {timer.TogglePause();}
+	PauseTimer(bool _pause) : pause(_pause) {}
+	void operator()(Framework::Timer &timer) {timer.SetPause(pause);}
 	void operator()(std::pair<const std::string, Framework::Timer> &timeData)
-	{timeData.second.TogglePause();}
+	{timeData.second.SetPause(pause);}
+
+	bool pause;
 };
 
 struct RewindTimer
 	std::for_each(m_extraTimers.begin(), m_extraTimers.end(), UpdateTimer());
 }
 
-bool LightManager::TogglePause()
+void LightManager::SetPause(TimerTypes eTimer, bool pause)
 {
-	std::for_each(m_lightTimers.begin(), m_lightTimers.end(), PauseTimer());
-	std::for_each(m_extraTimers.begin(), m_extraTimers.end(), PauseTimer());
+	if(eTimer == TIMER_ALL || eTimer == TIMER_LIGHTS)
+	{
+		std::for_each(m_lightTimers.begin(), m_lightTimers.end(), PauseTimer(pause));
+		std::for_each(m_extraTimers.begin(), m_extraTimers.end(), PauseTimer(pause));
+	}
 
-	return m_sunTimer.TogglePause();
+	if(eTimer == TIMER_ALL || eTimer == TIMER_SUN)
+		m_sunTimer.TogglePause();
 }
 
-bool LightManager::ToggleSunPause()
+void LightManager::TogglePause( TimerTypes eTimer )
 {
-	return m_sunTimer.TogglePause();
+	SetPause(eTimer, !IsPaused(eTimer));
 }
 
-void LightManager::RewindTime( float secRewind )
+bool LightManager::IsPaused( TimerTypes eTimer ) const
 {
-	m_sunTimer.Rewind(secRewind);
-	std::for_each(m_lightTimers.begin(), m_lightTimers.end(), RewindTimer(secRewind));
-	std::for_each(m_extraTimers.begin(), m_extraTimers.end(), RewindTimer(secRewind));
+	if(eTimer == TIMER_ALL || eTimer == TIMER_SUN)
+		return m_sunTimer.IsPaused();
+
+	return m_lightTimers.front().IsPaused();
 }
 
-void LightManager::FastForwardTime( float secFF )
+void LightManager::RewindTime(TimerTypes eTimer, float secRewind )
 {
-	m_sunTimer.Fastforward(secFF);
-	std::for_each(m_lightTimers.begin(), m_lightTimers.end(), FFTimer(secFF));
-	std::for_each(m_extraTimers.begin(), m_extraTimers.end(), FFTimer(secFF));
+	if(eTimer == TIMER_ALL || eTimer == TIMER_SUN)
+		m_sunTimer.Rewind(secRewind);
+
+	if(eTimer == TIMER_ALL || eTimer == TIMER_LIGHTS)
+	{
+		std::for_each(m_lightTimers.begin(), m_lightTimers.end(), RewindTimer(secRewind));
+		std::for_each(m_extraTimers.begin(), m_extraTimers.end(), RewindTimer(secRewind));
+	}
+}
+
+void LightManager::FastForwardTime(TimerTypes eTimer,  float secFF )
+{
+	if(eTimer == TIMER_ALL || eTimer == TIMER_SUN)
+		m_sunTimer.Fastforward(secFF);
+
+	if(eTimer == TIMER_ALL || eTimer == TIMER_LIGHTS)
+	{
+		std::for_each(m_lightTimers.begin(), m_lightTimers.end(), FFTimer(secFF));
+		std::for_each(m_extraTimers.begin(), m_extraTimers.end(), FFTimer(secFF));
+	}
 }
 
 LightBlock LightManager::GetLightPositions( const glm::mat4 &worldToCameraMat ) const
 	lightData.ambientIntensity = m_ambientInterpolator.Interpolate(m_sunTimer.GetAlpha());
 	lightData.lightAttenuation = g_fLightAttenuation;
 
-	float angle = 2.0f * 3.14159f * m_sunTimer.GetAlpha();
-	glm::vec4 sunDirection(0.0f);
-	sunDirection[0] = sinf(angle);
-	sunDirection[1] = cosf(angle);
-
-	//Keep the sun from being perfectly centered overhead.
-	sunDirection = glm::rotate(glm::mat4(1.0f), 5.0f, glm::vec3(0.0f, 1.0f, 0.0f)) * sunDirection;
-
 	lightData.lights[0].cameraSpaceLightPos =
-		worldToCameraMat * sunDirection;
-
+		worldToCameraMat * GetSunlightDirection();
 	lightData.lights[0].lightIntensity = m_sunlightInterpolator.Interpolate(m_sunTimer.GetAlpha());
 
 	for(int light = 0; light < NUMBER_OF_POINT_LIGHTS; light++)
 	return lightData;
 }
 
+glm::vec4 LightManager::GetSunlightDirection() const
+{
+	float angle = 2.0f * 3.14159f * m_sunTimer.GetAlpha();
+	glm::vec4 sunDirection(0.0f);
+	sunDirection[0] = sinf(angle);
+	sunDirection[1] = cosf(angle);
+
+	//Keep the sun from being perfectly centered overhead.
+	sunDirection = glm::rotate(glm::mat4(1.0f), 5.0f, glm::vec3(0.0f, 1.0f, 0.0f)) * sunDirection;
+
+	return sunDirection;
+}
+
+glm::vec4 LightManager::GetSunlightIntensity() const
+{
+	return m_sunlightInterpolator.Interpolate(m_sunTimer.GetAlpha());
+}
+
 int LightManager::GetNumberOfPointLights() const
 {
 	return m_lightPos.size();

Tut 12 Dynamic Range/Lights.h

 	glm::vec4 backgroundColor;
 };
 
+enum TimerTypes
+{
+	TIMER_SUN,
+	TIMER_LIGHTS,
+	TIMER_ALL,
+	NUM_TIMER_TYPES,
+};
+
 class LightManager
 {
 public:
 	void SetSunlightValues(SunlightValue *pValues, int iSize);
 
 	void UpdateTime();
-	bool TogglePause();
-	bool ToggleSunPause();
+	void TogglePause(TimerTypes eTimer);
+	void SetPause(TimerTypes eTimer, bool pause = true);
+	bool IsPaused(TimerTypes eTimer) const;
 
-	void RewindTime(float secRewind);
-	void FastForwardTime(float secRewind);
+	void RewindTime(TimerTypes eTimer, float secRewind);
+	void FastForwardTime(TimerTypes eTimer, float secRewind);
 
 	LightBlock GetLightPositions(const glm::mat4 &worldToCameraMat) const;
 	glm::vec4 GetBackgroundColor() const;
 
+	glm::vec4 GetSunlightDirection() const;
+	glm::vec4 GetSunlightIntensity() const;
+
 	int GetNumberOfPointLights() const;
 	glm::vec3 GetWorldLightPosition(int iLightIx) const;
 	void SetPointLightIntensity(int iLightIx, const glm::vec4 &intensity);

Tut 12 Dynamic Range/Scene Lighting.cpp

 	materials[4].specularColor = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
 	materials[4].specularShininess = 0.6f;
 
-	//Sphere 85/80/02
+	//Sphere
 	materials[5].diffuseColor = glm::vec4(0.63f, 0.60f, 0.02f, 1.0f);
 	materials[5].specularColor = glm::vec4(0.22f, 0.20f, 0.0f, 1.0f);
 	materials[5].specularShininess = 0.3f;
 	glBufferData(GL_UNIFORM_BUFFER, sizeMaterialUniformBuffer, bufferPtr, GL_STATIC_DRAW);
 }
 
-bool g_daytimeLighting = false;
-
 const glm::vec4 g_skyDaylightColor = glm::vec4(0.65f, 0.65f, 1.0f, 1.0f);
 
 void SetupDaytimeLighting()
 {
-	g_daytimeLighting = true;
-
 	SunlightValue values[] =
 	{
 		{ 0.0f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
 
 	g_lights.SetSunlightValues(values, 7);
 
-	g_lights.SetPointLightIntensity(0, glm::vec4(0.05f, 0.05f, 0.05f, 1.0f));
-	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.1f, 1.0f));
-	g_lights.SetPointLightIntensity(2, glm::vec4(0.1f, 0.0f, 0.0f, 1.0f));
+	g_lights.SetPointLightIntensity(0, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f));
+	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.3f, 1.0f));
+	g_lights.SetPointLightIntensity(2, glm::vec4(0.3f, 0.0f, 0.0f, 1.0f));
 }
 
 void SetupNighttimeLighting()
 {
-	g_daytimeLighting = false;
-
 	SunlightValue values[] =
 	{
-		{0.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.4f, 0.4f, 0.4f, 1.0f), glm::vec4(0.9f, 0.9f, 1.0f, 1.0f)},
-		{0.25f, glm::vec4(0.1f, 0.05f, 0.05f, 1.0f), glm::vec4(0.2f, 0.0f, 0.0f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f)},
-		{0.5f, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)},
-		{0.75f, glm::vec4(0.1f, 0.05f, 0.05f, 1.0f), glm::vec4(0.2f, 0.0f, 0.0f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f)},
+		{ 0.0f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
+		{ 4.5f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
+		{ 6.5f/24.0f, glm::vec4(0.15f, 0.05f, 0.05f, 1.0f), glm::vec4(0.3f, 0.1f, 0.10f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f)},
+		{ 8.0f/24.0f, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)},
+		{18.0f/24.0f, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)},
+		{19.5f/24.0f, glm::vec4(0.15f, 0.05f, 0.05f, 1.0f), glm::vec4(0.3f, 0.1f, 0.1f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f)},
+		{20.5f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
 	};
 
-	g_lights.SetSunlightValues(values, 4);
+	g_lights.SetSunlightValues(values, 7);
 
-	g_lights.SetPointLightIntensity(0, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f));
-	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.3f, 1.0f));
-	g_lights.SetPointLightIntensity(2, glm::vec4(0.3f, 0.0f, 0.0f, 1.0f));
+	g_lights.SetPointLightIntensity(0, glm::vec4(0.6f, 0.6f, 0.6f, 1.0f));
+	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.7f, 1.0f));
+	g_lights.SetPointLightIntensity(2, glm::vec4(0.7f, 0.0f, 0.0f, 1.0f));
 }
 
 Framework::Mesh *g_pTerrainMesh = NULL;
 				5, modelMatrix);
 		}
 
+		//Render the sun
+		{
+			Framework::MatrixStackPusher push(modelMatrix);
+
+			glm::vec3 sunlightDir(g_lights.GetSunlightDirection());
+			modelMatrix.Translate(sunlightDir * 500.0f);
+			modelMatrix.Scale(30.0f, 30.0f, 30.0f);
+
+			glUseProgram(g_Unlit.theProgram);
+			glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
+				glm::value_ptr(modelMatrix.Top()));
+
+			glm::vec4 lightColor = g_lights.GetSunlightIntensity();
+			glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor));
+			g_pSphereMesh->Render("flat");
+		}
+
 		//Render the light
 		for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
 		{
 }
 
 
+TimerTypes g_eTimerMode = TIMER_ALL;
+
 //Called whenever a key on the keyboard was pressed.
 //The key is given by the ''key'' parameter, which is in ASCII.
 //It's often a good idea to have the escape key (ASCII value 27) call glutLeaveMainLoop() to 
 		glutLeaveMainLoop();
 		break;
 		
-	case 'b': g_lights.TogglePause(); break;
-	case 'B': g_lights.ToggleSunPause(); break;
-	case '-': g_lights.RewindTime(1.0f); break;
-	case '=': g_lights.FastForwardTime(1.0f); break;
+	case 'b': g_lights.TogglePause(g_eTimerMode); break;
+	case '-': g_lights.RewindTime(g_eTimerMode, 1.0f); break;
+	case '=': g_lights.FastForwardTime(g_eTimerMode, 1.0f); break;
 	case 't': g_bDrawCameraPos = !g_bDrawCameraPos; break;
+	case 'y': g_eTimerMode = TIMER_ALL; printf("All\n"); break;
+	case 'h': g_eTimerMode = TIMER_SUN; printf("Sun\n"); break;
+	case 'n': g_eTimerMode = TIMER_LIGHTS; printf("Lights\n"); break;
 
-	case 'l':
-		if(g_daytimeLighting)
-			SetupNighttimeLighting();
-		else
-			SetupDaytimeLighting();
-		break;
+	case 'l': SetupDaytimeLighting(); break;
+	case 'L': SetupNighttimeLighting(); break;
 
 	case 32:
 		printf("%f\n", g_lights.GetSunTime());

Tut 12 Dynamic Range/data/DiffuseOnly.frag

 	float lightDistanceSqr = dot(lightDifference, lightDifference);
 	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
 	
-	return (1 / ( 1.0 + Lgt.lightAttenuation * Lgt.lightAttenuation
-		* sqrt(lightDistanceSqr)));
+	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
 }
 
 vec4 ComputeLighting(in PerLight lightData)

Tut 12 Dynamic Range/data/DiffuseOnlyMtl.frag

 	float lightDistanceSqr = dot(lightDifference, lightDifference);
 	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
 	
-	return (1 / ( 1.0 + Lgt.lightAttenuation * Lgt.lightAttenuation
-		* sqrt(lightDistanceSqr)));
+	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
 }
 
 vec4 ComputeLighting(in PerLight lightData)

Tut 12 Dynamic Range/data/DiffuseSpecular.frag

 	float lightDistanceSqr = dot(lightDifference, lightDifference);
 	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
 	
-	return (1 / ( 1.0 + Lgt.lightAttenuation * Lgt.lightAttenuation
-		* sqrt(lightDistanceSqr)));
+	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
 }
 
 vec4 ComputeLighting(in PerLight lightData)

Tut 12 Dynamic Range/data/DiffuseSpecularMtl.frag

 	float lightDistanceSqr = dot(lightDifference, lightDifference);
 	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
 	
-	return (1 / ( 1.0 + Lgt.lightAttenuation * Lgt.lightAttenuation
-		* sqrt(lightDistanceSqr)));
+	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
 }
 
 vec4 ComputeLighting(in PerLight lightData)

Tut 12 Dynamic Range/data/GenCube.lua

 
 local colors =
 {
-	vmath.vec4(0.0, 1.0, 0.0, 1.0),
-	vmath.vec4(0.0, 1.0, 0.0, 1.0),
-	vmath.vec4(0.0, 1.0, 0.0, 1.0),
-	vmath.vec4(0.0, 1.0, 0.0, 1.0),
+	vmath.vec4(0.25, 1.0, 0.25, 1.0),
+	vmath.vec4(0.25, 1.0, 0.25, 1.0),
+	vmath.vec4(0.25, 1.0, 0.25, 1.0),
+	vmath.vec4(0.25, 1.0, 0.25, 1.0),
 
-	vmath.vec4(0.0, 0.0, 1.0, 1.0),
-	vmath.vec4(0.0, 0.0, 1.0, 1.0),
-	vmath.vec4(0.0, 0.0, 1.0, 1.0),
-	vmath.vec4(0.0, 0.0, 1.0, 1.0),
+	vmath.vec4(0.5, 0.5, 1.0, 1.0),
+	vmath.vec4(0.5, 0.5, 1.0, 1.0),
+	vmath.vec4(0.5, 0.5, 1.0, 1.0),
+	vmath.vec4(0.5, 0.5, 1.0, 1.0),
 
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
 
-	vmath.vec4(1.0, 1.0, 0.0, 1.0),
-	vmath.vec4(1.0, 1.0, 0.0, 1.0),
-	vmath.vec4(1.0, 1.0, 0.0, 1.0),
-	vmath.vec4(1.0, 1.0, 0.0, 1.0),
+	vmath.vec4(1.0, 1.0, 0.5, 1.0),
+	vmath.vec4(1.0, 1.0, 0.5, 1.0),
+	vmath.vec4(1.0, 1.0, 0.5, 1.0),
+	vmath.vec4(1.0, 1.0, 0.5, 1.0),
 
-	vmath.vec4(0.0, 1.0, 1.0, 1.0),
-	vmath.vec4(0.0, 1.0, 1.0, 1.0),
-	vmath.vec4(0.0, 1.0, 1.0, 1.0),
-	vmath.vec4(0.0, 1.0, 1.0, 1.0),
+	vmath.vec4(0.5, 1.0, 1.0, 1.0),
+	vmath.vec4(0.5, 1.0, 1.0, 1.0),
+	vmath.vec4(0.5, 1.0, 1.0, 1.0),
+	vmath.vec4(0.5, 1.0, 1.0, 1.0),
 
-	vmath.vec4(1.0, 0.0, 1.0, 1.0),
-	vmath.vec4(1.0, 0.0, 1.0, 1.0),
-	vmath.vec4(1.0, 0.0, 1.0, 1.0),
-	vmath.vec4(1.0, 0.0, 1.0, 1.0),
+	vmath.vec4(1.0, 0.5, 1.0, 1.0),
+	vmath.vec4(1.0, 0.5, 1.0, 1.0),
+	vmath.vec4(1.0, 0.5, 1.0, 1.0),
+	vmath.vec4(1.0, 0.5, 1.0, 1.0),
 }
 
 local indices =

Tut 12 Dynamic Range/data/GenCylinder.lua

 
 local iAngle = 3.14159 * 2.0 / iSegCount;
 local iColorCycleAngle = 3.14159 * 2.0 / iColorRepeatCount;
-local highColor = vmath.vec4(0.9, 0.5, 0.5, 1.0);
-local lowColor = vmath.vec4(0.5, 0.1, 0.1, 1.0)
+local highColor = vmath.vec4(0.9, 0.8, 0.8, 1.0);
+local lowColor = vmath.vec4(0.6, 0.6, 0.5, 1.0)
 
 --Compute caps
 positions[#positions + 1] = vmath.vec3(0.0, 0.5, 0.0);

Tut 12 Dynamic Range/data/GenSphere.lua

 			writer:PushElement("source"); writer:AddAttribute("attrib", "0"); writer:PopElement();
 			writer:PushElement("source"); writer:AddAttribute("attrib", "1"); writer:PopElement();
 		writer:PopElement();
+		writer:PushElement("vao");
+			writer:AddAttribute("name", "flat");
+			writer:PushElement("source"); writer:AddAttribute("attrib", "0"); writer:PopElement();
+		writer:PopElement();
 		writer:PushElement("indices");
 			writer:AddAttribute("cmd", "tri-fan");
 			writer:AddAttribute("type", "ushort");

Tut 12 Dynamic Range/data/GenTetrahedron.lua

 	vmath.vec4(0.5, 0.5, 1.0, 1.0),
 	vmath.vec4(0.5, 0.5, 1.0, 1.0),
 	
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
-	vmath.vec4(1.0, 0.0, 0.0, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
+	vmath.vec4(1.0, 0.5, 0.5, 1.0),
 	
-	vmath.vec4(0.0, 0.0, 0.0, 1.0),
-	vmath.vec4(0.0, 0.0, 0.0, 1.0),
-	vmath.vec4(0.0, 0.0, 0.0, 1.0),
+	vmath.vec4(0.3, 0.3, 0.3, 1.0),
+	vmath.vec4(0.3, 0.3, 0.3, 1.0),
+	vmath.vec4(0.3, 0.3, 0.3, 1.0),
 }
 
 do

Tut 12 Dynamic Range/data/UnitCube.xml

         -0.5 -0.5 -0.5
         -0.5 0.5 -0.5</attribute>
 	<attribute index="1" type="float" size="4" > 
-        0 1 0 1
-        0 1 0 1
-        0 1 0 1
-        0 1 0 1
-        0 0 1 1
-        0 0 1 1
-        0 0 1 1
-        0 0 1 1
-        1 0 0 1
-        1 0 0 1
-        1 0 0 1
-        1 0 0 1
-        1 1 0 1
-        1 1 0 1
-        1 1 0 1
-        1 1 0 1
-        0 1 1 1
-        0 1 1 1
-        0 1 1 1
-        0 1 1 1
-        1 0 1 1
-        1 0 1 1
-        1 0 1 1
-        1 0 1 1</attribute>
+        0.25 1 0.25 1
+        0.25 1 0.25 1
+        0.25 1 0.25 1
+        0.25 1 0.25 1
+        0.5 0.5 1 1
+        0.5 0.5 1 1
+        0.5 0.5 1 1
+        0.5 0.5 1 1
+        1 0.5 0.5 1
+        1 0.5 0.5 1
+        1 0.5 0.5 1
+        1 0.5 0.5 1
+        1 1 0.5 1
+        1 1 0.5 1
+        1 1 0.5 1
+        1 1 0.5 1
+        0.5 1 1 1
+        0.5 1 1 1
+        0.5 1 1 1
+        0.5 1 1 1
+        1 0.5 1 1
+        1 0.5 1 1
+        1 0.5 1 1
+        1 0.5 1 1</attribute>
 	<attribute index="2" type="float" size="3" > 
         0 0 1
         0 0 1

Tut 12 Dynamic Range/data/UnitCylinder.xml

         0.48907326703854 -0.5 -0.10395835448992</attribute>
 	<attribute index="1" type="float" size="4" > 
         1 1 1 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
         1 1 1 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.9 0.5 0.5 1
-        0.9 0.5 0.5 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.5 0.1 0.1 1
-        0.5 0.1 0.1 1
-        0.58 0.18 0.18 1
-        0.58 0.18 0.18 1
-        0.66 0.26 0.26 1
-        0.66 0.26 0.26 1
-        0.74 0.34 0.34 1
-        0.74 0.34 0.34 1
-        0.82 0.42 0.42 1
-        0.82 0.42 0.42 1</attribute>
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.9 0.8 0.8 1
+        0.9 0.8 0.8 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.6 0.6 0.5 1
+        0.6 0.6 0.5 1
+        0.66 0.64 0.56 1
+        0.66 0.64 0.56 1
+        0.72 0.68 0.62 1
+        0.72 0.68 0.62 1
+        0.78 0.72 0.68 1
+        0.78 0.72 0.68 1
+        0.84 0.76 0.74 1
+        0.84 0.76 0.74 1</attribute>
 	<attribute index="2" type="float" size="3" > 
         0 1 0
         0 1 0

Tut 12 Dynamic Range/data/UnitSphere.xml

 		<source attrib="0" />
 		<source attrib="1" />
 	</vao>
+	<vao name="flat" >
+		<source attrib="0" />
+	</vao>
 	<indices cmd="tri-fan" type="ushort" >0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1</indices>
 	<indices cmd="tri-fan" type="ushort" >121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 120</indices>
 	<indices cmd="tri-strip" type="ushort" >1 16 2 17 3 18 4 19 5 20 6 21 7 22 8 23 9 24 10 25 11 26 12 27 13 28 14 29 15 30 1 16</indices>

Tut 12 Dynamic Range/data/UnitTetrahedron.xml

         0.5 0.5 1 1
         0.5 0.5 1 1
         0.5 0.5 1 1
-        1 0 0 1
-        1 0 0 1
-        1 0 0 1
-        0 0 0 1
-        0 0 0 1
-        0 0 0 1</attribute>
+        1 0.5 0.5 1
+        1 0.5 0.5 1
+        1 0.5 0.5 1
+        0.3 0.3 0.3 1
+        0.3 0.3 0.3 1
+        0.3 0.3 0.3 1</attribute>
 	<attribute index="2" type="float" size="3" > 
         -0.57735026918963 0.57735026918963 0.57735026918963
         -0.57735026918963 0.57735026918963 0.57735026918963

framework/Timer.cpp

 		return m_isPaused;
 	}
 
+	bool Timer::IsPaused() const
+	{
+		return m_isPaused;
+	}
+
+	void Timer::SetPause( bool pause )
+	{
+		m_isPaused = pause;
+	}
+
 	bool Timer::Update()
 	{
 		float absCurrTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0f;

framework/Timer.h

 		//Pauses/unpauses. Returns true if the timer is paused after the toggling.
 		bool TogglePause();
 
+		//Sets the pause state to the given value.
+		void SetPause(bool pause = true);
+
+		//Returns true if the timer is paused.
+		bool IsPaused() const;
+
 		//Updates the time for the timer. Returns true if the timer has reached the end.
 		//Will only return true for SINGLE timers that have reached their duration.
 		bool Update();
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 ProjectModifiedEvent.java.
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.