From a89f80d68bd20c94ca0d30d030757a829c339a78 Mon Sep 17 00:00:00 2001
From: xkamikoo <58092037+xkamikoo@users.noreply.github.com>
Date: Tue, 26 Jan 2021 23:18:54 +0100
Subject: [PATCH] engine lights
---
grk-project.vcxproj | 4 ++--
shaders/shader_4_tex.frag | 2 +-
src/main.cpp | 30 +++++++++++++++++++++---------
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/grk-project.vcxproj b/grk-project.vcxproj
index 672ac76..4fdbc9a 100644
--- a/grk-project.vcxproj
+++ b/grk-project.vcxproj
@@ -49,7 +49,7 @@
{1B448102-E76C-4347-BDC7-40D02A567DB6}
Win32Proj
grk-cw9
- 10.0
+ 10.0.17134.0
grk-project
@@ -64,7 +64,7 @@
false
true
Unicode
- v142
+ v141
diff --git a/shaders/shader_4_tex.frag b/shaders/shader_4_tex.frag
index 096d4ce..d897c8e 100644
--- a/shaders/shader_4_tex.frag
+++ b/shaders/shader_4_tex.frag
@@ -6,7 +6,7 @@ struct PointLight {
float intensity;
};
-#define NR_POINT_LIGHTS 3
+#define NR_POINT_LIGHTS 5
uniform vec3 objectColor;
uniform vec3 lightPos;
diff --git a/src/main.cpp b/src/main.cpp
index 3a16ac3..a74a9f1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -97,6 +97,7 @@ void keyboard(unsigned char key, int x, int y)
{
cameraPos += cameraDir * moveSpeed;
lights[2].intensity = 0.001;
+ lights[3].intensity = 0.001;
engineLightTimer = 0;
break;
}
@@ -273,13 +274,13 @@ void renderScene()
lights[0].position = sunPos;
lights[1].position = sunPos2;
- //lights[2].position = cameraPos + cameraDir * 0.5f + glm::vec3(0, -0.25f, 0);
- //lights[2].position = glm::vec3(cameraPos.x + cameraDir.x * 0.5f +0.f , cameraPos.y-0.25f, cameraPos.z + cameraDir.z * 0.5f );
- glm::mat4 engineLightPos = glm::translate(cameraPos + cameraDir * 0.3f + cameraSide * -0.5f + glm::vec3(0, -0.25f, 0)) * glm::rotate(-cameraAngle, glm::vec3(0, 1, 0));
- lights[2].position = glm::vec3(engineLightPos[3][0], engineLightPos[3][1], engineLightPos[3][2]);
+ glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.6f + glm::vec3(0, -0.25f, 0)) * glm::rotate(-cameraAngle + glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.0001f));
+ glm::mat4 engineLeft = glm::translate(shipModelMatrix, glm::vec3(500,0,-1500));
+ lights[2].position = glm::vec3(engineLeft[3][0], engineLeft[3][1], engineLeft[3][2]);
+ glm::mat4 engineRight = glm::translate(shipModelMatrix, glm::vec3(-500, 0, -1500));
+ lights[3].position = glm::vec3(engineRight[3][0], engineRight[3][1], engineRight[3][2]);
- lights[2].color = glm::vec3(1.0f, -0.0f, 0.0f);
for (int i = 0; i < lights.size(); i++)
{
@@ -296,8 +297,8 @@ void renderScene()
//rysowanie statku
//glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.6f + glm::vec3(0, -0.25f, 0)) * glm::rotate(-cameraAngle + glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.0001f));
- glm::mat4 shipModelMatrix = glm::translate(cameraPos + cameraDir * 0.6f + glm::vec3(0, -0.25f, 0)) * glm::rotate(-cameraAngle + glm::radians(90.0f), glm::vec3(0, 1, 0)) * glm::scale(glm::vec3(0.0001f));
-drawFromAssimpModel(programTex, corvette, shipModelMatrix, glm::vec3(1));
+
+ drawFromAssimpModel(programTex, corvette, shipModelMatrix, glm::vec3(1));
@@ -310,7 +311,11 @@ drawFromAssimpModel(programTex, corvette, shipModelMatrix, glm::vec3(1));
drawObjectTexture(programTex, sphereContext, moon, glm::vec3(0.9f, 1.0f, 0.9f), moonTexture);
if (engineLightTimer < 50) engineLightTimer++;
- else lights[2].intensity = 0.0001;
+ else
+ {
+ lights[2].intensity = 0.00001;
+ lights[3].intensity = 0.00001;
+ }
glUseProgram(0);
glutSwapBuffers();
@@ -355,10 +360,17 @@ void init()
Light l3;
l3.position = engineLight;
- l3.color = glm::vec3(0.5f, 0.5f, 0.5f);
+ l3.color = glm::vec3(1.0f, -0.0f, 0.0f);
l3.intensity = 0.0001;
lights.push_back(l3);
+ Light l4;
+ l4.position = engineLight;
+ l4.color = glm::vec3(1.0f, -0.0f, 0.0f);
+ l4.intensity = 0.0001;
+ lights.push_back(l4);
+
+
}
void shutdown()