fixed lamp and turning off/on lights;

This commit is contained in:
Angelika Iskra 2023-02-11 15:26:26 +01:00
parent 3501a17241
commit 1cef08d75b
27 changed files with 32 additions and 50 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,35 +1,34 @@
 main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
C:\Users\annas\Desktop\graf\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(118,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(136,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(159,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(178,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(196,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(288,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(294,96): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(118,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(136,38): warning C4305: "=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(159,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(178,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(196,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(288,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(294,96): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(298,59): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(297,59): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(462,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(487,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(504,109): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(445,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(470,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(487,109): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(560,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(699,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(701,21): warning C4305: "+=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(539,2): warning C4305: "argument": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(678,21): warning C4305: "-=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(680,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu
54 of 607 functions ( 8.9%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
18 functions had inline decision re-evaluated but remain unchanged
Previous IPDB and IOBJ mismatch, fall back to full compilation.
All 607 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\annas\Desktop\graf\Release\room.exe
grk-cw9.vcxproj -> D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\annas\Desktop\graf\Release\room.exe</FullPath>
<FullPath>D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Release|Win32|C:\Users\annas\Desktop\graf\|
Release|Win32|D:\UAM\Grafika komputerowa\projekt\GRK_Room\|

Binary file not shown.

Binary file not shown.

View File

@ -107,7 +107,7 @@ unsigned int pingpongBuffer[2];
GLuint VAO,VBO;
float aspectRatio = 1.f;
float exposition = 1.f;
float exposition = 3.0f;
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); //cienie z latarki
@ -123,7 +123,7 @@ glm::mat4 lightShipVP;
float lastTime = -1.f;
float deltaTime = 0.f;
bool lightOn = true;
float lightOn = 1.0f;
glm::vec3 carPosTranform = glm::vec3(0, 0, 0);
void updateDeltaTime(float time) {
@ -231,7 +231,7 @@ void drawSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glUniformMatrix4fv(glGetUniformLocation(programSkybox, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniform1i(glGetUniformLocation(programSkybox, "skybox"), 0);
glUniform1f(glGetUniformLocation(programSkybox, "exposition"), exposition);
if (lightOn)
if (lightOn > 0.0f)
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
else
glUniform3f(glGetUniformLocation(program, "lightPos"), 1000.f, 1000.f, 1000.f);
@ -269,7 +269,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
if (lightOn)
if (lightOn > 0.0f)
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
else
glUniform3f(glGetUniformLocation(program, "lightPos"), 1000.f, 1000.f, 1000.f);
@ -292,38 +292,22 @@ void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
glUseProgram(programDepth);
drawObjectDepth(sphereContext, light, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)));
drawObjectDepth(sphereContext,
light,
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)));
drawObjectDepth(models::couchContext, light, glm::scale(glm::vec3(0.5f)) * glm::translate(glm::vec3(8.4f, 0, -0.4f)) * glm::eulerAngleY(3.15f));
drawObjectDepth(models::coffeeTableContext, light, glm::translate(glm::vec3(2.8f, 0, 0.5f)));
drawObjectDepth(models::doorContext, light, glm::mat4());
drawObjectDepth(models::planeContext, light, glm::mat4());
drawObjectDepth(models::roomContext, light, glm::mat4());
// draw windows
drawObjectDepth(models::windowContext, light, glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.2f)));
drawObjectDepth(models::windowContext, light, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)));
drawObjectDepth(models::windowContext, light, glm::eulerAngleY(1.57f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.45f)) * glm::translate(glm::vec3(-0.6f, 0, -0.25f)));
drawObjectDepth(models::deskContext, light, glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.9f)));
drawObjectDepth(models::displayScreenContext, light, glm::scale(glm::vec3(0.1, 0.1, 0.1)) * glm::translate(glm::vec3(-28.5f, 9.0f, -20.0f)));
drawObjectDepth(models::chairContext, light, glm::scale(glm::vec3(1.0f, 1.2f, 1.0f)) * glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.5f)));
drawObjectDepth(models::ps5Context, light, glm::mat4());
drawObjectDepth(models::tvStandContext, light, glm::mat4());
@ -431,7 +415,6 @@ void initBloom()
void initPingPong()
{
glGenFramebuffers(2, pingpongFBO);
glGenTextures(2, pingpongBuffer);
for (unsigned int i = 0; i < 2; i++)
@ -498,7 +481,7 @@ void renderScene(GLFWwindow* window)
if (lightOn) {
if (lightOn > 0.0f) {
glUseProgram(programSun);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1));
@ -508,16 +491,12 @@ void renderScene(GLFWwindow* window)
Core::DrawContext(sphereContext);
}
//pingPongBluring(time);
glUseProgram(program);
drawObjectPBR(models::couchContext, glm::scale(glm::vec3(0.5f)) * glm::translate(glm::vec3(8.4f, 0, -0.4f)) * glm::eulerAngleY(3.15f), glm::vec3(0.03f, 0.03f, 0.03f), 0.2f, 0.0f);
drawObjectPBR(models::coffeeTableContext, glm::translate(glm::vec3(2.8f, 0, 0.5f)), glm::vec3(1.f, 1.f, 1.f), 0.4f, 0.0f);
drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::planeContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.8f, 0.0f);
drawObjectPBR(models::deskContext, glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.9f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.0f);
drawObjectPBR(models::displayScreenContext, glm::scale(glm::vec3(0.1, 0.1, 0.1)) * glm::translate(glm::vec3(-28.5f, 9.0f, -20.0f)), glm::vec3(0.0f, 0.0f, 0.0f), 0.0f, 0.3f);
@ -529,12 +508,13 @@ void renderScene(GLFWwindow* window)
drawObjectPBR(models::carpetContext, glm::mat4(), glm::vec3(0.6745098039215686f, 0.6352941176470588f, 0.6235294117647059f), 0.0f, 0.2f);
drawObjectPBR(models::cabinet1Context, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::cabinet2Context, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lampContext, glm::translate(glm::vec3(0.023f, 0.15f, 0.0f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lampContext, glm::translate(glm::vec3(0.022f, 0.15f, 0.04f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::bookshelfContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lightSwitchContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::easelContext, glm::mat4(), glm::vec3(0.6745098039215686f, 0.6352941176470588f, 0.6235294117647059f), 0.0f, 0.2f);
drawObjectPBR(models::carContext, glm::translate(carPosTranform), glm::vec3(1.0f, 0.0f, 0.0f), 0.0f, 0.2f);
drawObjectPBR(models::vaseContext, glm::translate(glm::vec3(1.1f, 1.41f, -2.2f)), glm::vec3(244.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f), 0.0f, 0.2f);
// draw windows
drawObjectPBR(models::windowContext, glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.2f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::windowContext, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
@ -551,7 +531,6 @@ void renderScene(GLFWwindow* window)
});
//drawObjectPBR(shipContext,
drawObjectPBR(models::spaceshipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)),
@ -703,9 +682,13 @@ void processInput(GLFWwindow* window)
if (glfwGetKey(window, GLFW_KEY_3) == GLFW_PRESS) {
printf("spaceshipPos = glm::vec3(%ff, %ff, %ff);\n", spaceshipPos.x, spaceshipPos.y, spaceshipPos.z);
printf("spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", spaceshipDir.x, spaceshipDir.y, spaceshipDir.z);
printf("exposition = %ff);\n", exposition);
}
if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS)
lightOn = !lightOn;
lightOn -= 1.0f;
if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS)
lightOn += 1.0f;
// if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)