Commits

Jason McKesson committed d887a8c

Tut12: Light movement done, in rough form.

  • Participants
  • Parent commits 5ed67a0

Comments (0)

Files changed (2)

File Tut 12 Dynamic Range/Lights.cpp

 	m_lightPos[1].SetValues(posValues);
 	m_lightTimers.push_back(Framework::Timer(Framework::Timer::TT_LOOP, 25.0f));
 
-	//Left-side light. -7.0f, 30.0f, -14.0f
+	//Left-side light.
 	posValues.clear();
-/*
 	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(-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));
+	posValues.push_back(glm::vec3(-83.0f, 30.0f, -92.0f));
+	posValues.push_back(glm::vec3(-98.0f, 27.0f, -77.0f));
+	posValues.push_back(glm::vec3(-83.0f, 24.0f, -62.0f));
+	posValues.push_back(glm::vec3(-68.0f, 21.0f, -77.0f));
+	posValues.push_back(glm::vec3(-83.0f, 18.0f, -92.0f));
+	posValues.push_back(glm::vec3(-98.0f, 15.0f, -77.0f));
+
+	posValues.push_back(glm::vec3(-50.0f, 8.0f, 25.0f));
+	posValues.push_back(glm::vec3(-59.5f, 4.0f, 65.0f));
+	posValues.push_back(glm::vec3(-59.5f, 4.0f, 78.0f));
+	posValues.push_back(glm::vec3(-45.0f, 4.0f, 82.0f));
+	posValues.push_back(glm::vec3(-40.0f, 4.0f, 50.0f));
+	posValues.push_back(glm::vec3(-70.0f, 20.0f, 40.0f));
+	posValues.push_back(glm::vec3(-60.0f, 20.0f, 90.0f));
+	posValues.push_back(glm::vec3(-40.0f, 25.0f, 90.0f));
 
 
 	m_lightPos[2].SetValues(posValues);

File Tut 12 Dynamic Range/Scene Lighting.cpp

 LightManager g_lights;
 
 Framework::RadiusDef radiusDef = {50.0f, 3.0f, 80.0f, 4.0f, 1.0f};
-glm::vec3 objectCenter = glm::vec3(0.0f, 50.0f, 0.0f);
+glm::vec3 objectCenter = glm::vec3(-59.5f, 4.0f, 65.0f);
 
 Framework::MousePole g_mousePole(objectCenter, radiusDef);
 
 }
 
 bool g_bDrawCameraPos = false;
+bool g_bDrawLights = true;
 
 void DrawObject(const Framework::Mesh *pMesh, 
 				const ProgramData &prog, int mtlIx,
 			g_pSphereMesh->Render("flat");
 		}
 
-		//Render the light
-		for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
+		//Render the lights
+		if(g_bDrawLights)
 		{
-			Framework::MatrixStackPusher push(modelMatrix);
+			for(int light = 0; light < g_lights.GetNumberOfPointLights(); light++)
+			{
+				Framework::MatrixStackPusher push(modelMatrix);
 
-			modelMatrix.Translate(g_lights.GetWorldLightPosition(light));
+				modelMatrix.Translate(g_lights.GetWorldLightPosition(light));
 
-			glUseProgram(g_Unlit.theProgram);
-			glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
-				glm::value_ptr(modelMatrix.Top()));
+				glUseProgram(g_Unlit.theProgram);
+				glUniformMatrix4fv(g_Unlit.modelToCameraMatrixUnif, 1, GL_FALSE,
+					glm::value_ptr(modelMatrix.Top()));
 
-			glm::vec4 lightColor = g_lights.GetPointLightIntensity(light);
-			glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor));
-			g_pCubeMesh->Render("flat");
+				glm::vec4 lightColor = g_lights.GetPointLightIntensity(light);
+				glUniform4fv(g_Unlit.objectColorUnif, 1, glm::value_ptr(lightColor));
+				g_pCubeMesh->Render("flat");
+			}
 		}
 
 		if(g_bDrawCameraPos)
 		delete g_pTetraMesh;
 		delete g_pCylMesh;
 		delete g_pSphereMesh;
+		g_pTerrainMesh = NULL;
+		g_pCubeMesh = NULL;
+		g_pTetraMesh = NULL;
+		g_pCylMesh = NULL;
+		g_pSphereMesh = NULL;
 		glutLeaveMainLoop();
 		break;
 		
 	}
 
 	g_mousePole.GLUTKeyOffset(key, 5.0f, 1.0f);
-
-	glutPostRedisplay();
 }