dodanie obrotu skyboxa i sterowanie klawiszami
This commit is contained in:
parent
77f42acbeb
commit
c2105f2d16
@ -3,14 +3,14 @@ Pos=60,60
|
||||
Size=400,400
|
||||
|
||||
[Window][Planet]
|
||||
Pos=1,195
|
||||
Pos=1,217
|
||||
Size=327,227
|
||||
|
||||
[Window][Sun]
|
||||
Pos=1,424
|
||||
Size=327,122
|
||||
Pos=1,445
|
||||
Size=327,118
|
||||
|
||||
[Window][General]
|
||||
Pos=1,0
|
||||
Size=327,193
|
||||
Size=327,216
|
||||
|
||||
|
@ -73,6 +73,7 @@ GLuint skyBoxTex;
|
||||
|
||||
glm::vec3 skyBoxPos = glm::vec3(0.f, 0.f, 0.f);
|
||||
float skyBoxSize = 3.f;
|
||||
float skyBoxRot = 0.f;
|
||||
|
||||
glm::vec3 cameraPos = glm::vec3(-2.f, 0.f, 0.f);
|
||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
||||
@ -179,6 +180,10 @@ void showGUI() {
|
||||
if (ImGui::Begin("General"))
|
||||
{
|
||||
ImGui::Checkbox("Sky Box", &skyBoxCheck);
|
||||
|
||||
if (skyBoxCheck)
|
||||
ImGui::SliderFloat("Rotation", &skyBoxRot, 0.0f, 360.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||
|
||||
ImGui::Checkbox("Tone Mapping", &toneMappingCheck);
|
||||
ImGui::SliderInt("Bloom Level", &blur_count, 1, 5, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::Checkbox("Lighting Model: ", &lightingCheck);
|
||||
@ -224,7 +229,7 @@ void showGUI() {
|
||||
if (atmosphereCheck) {
|
||||
ImGui::Text("Clouds");
|
||||
ImGui::SliderFloat("Intensity", &cloudIntensity, 0.0f, 100.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::SliderFloat("Brightness", &cloudBrightness, 0.01f, 0.20f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::SliderFloat("Brightness", &cloudBrightness, 0.0f, 0.20f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||
ImGui::SliderFloat("Motion", &cloudMotion, -0.5f, 0.5f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||
}
|
||||
}ImGui::End();
|
||||
@ -467,18 +472,19 @@ void renderScene(GLFWwindow* window) {
|
||||
|
||||
//rysowanie słońca
|
||||
glm::mat4 sunScale = glm::scale(glm::vec3(sunSize));
|
||||
glm::mat4 sunTranslate = glm::translate(sunPos);
|
||||
glm::mat4 sunRotate = glm::rotate(PI, glm::vec3(0, 1, 0));
|
||||
glm::mat4 sunTranslate = glm::translate(sunPos);
|
||||
|
||||
drawSun(sphereContext, sunTranslate * sunRotate * sunScale, sunTex);
|
||||
|
||||
//rysowanie skyboxa
|
||||
skyBoxPos = cameraPos;
|
||||
glm::mat4 skyBoxScale = glm::scale(glm::vec3(skyBoxSize));
|
||||
glm::mat4 skyBoxRotate = glm::rotate(glm::radians(skyBoxRot), glm::vec3(0, 1, 0));
|
||||
glm::mat4 skyBoxTranslate = glm::translate(skyBoxPos);
|
||||
|
||||
if (skyBoxCheck)
|
||||
drawSkyBox(cubeContext, skyBoxTranslate * skyBoxScale, skyBoxTex);
|
||||
drawSkyBox(cubeContext, skyBoxTranslate * skyBoxRotate * skyBoxScale, skyBoxTex);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
@ -521,7 +527,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
||||
|
||||
planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]);
|
||||
}
|
||||
if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
|
||||
else if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
|
||||
--planetTexIndex;
|
||||
|
||||
if (planetTexIndex < 0)
|
||||
@ -539,7 +545,7 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
||||
|
||||
sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]);
|
||||
}
|
||||
if (key == GLFW_KEY_I && action == GLFW_PRESS) {
|
||||
else if (key == GLFW_KEY_I && action == GLFW_PRESS) {
|
||||
--sunTexIndex;
|
||||
|
||||
if (sunTexIndex < 0)
|
||||
@ -564,6 +570,10 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
||||
if (key == GLFW_KEY_Q && action == GLFW_PRESS)
|
||||
skyBoxCheck = !skyBoxCheck;
|
||||
|
||||
//tonemapping
|
||||
if (key == GLFW_KEY_F && action == GLFW_PRESS)
|
||||
toneMappingCheck = !toneMappingCheck;
|
||||
|
||||
//bloom
|
||||
if (key == GLFW_KEY_M && action == GLFW_PRESS) {
|
||||
blur_count++;
|
||||
@ -659,6 +669,20 @@ void processInput(GLFWwindow* window)
|
||||
cloudBrightness += brightnessSpeed;
|
||||
else if (glfwGetKey(window, GLFW_KEY_B) == GLFW_PRESS && cloudBrightness > 0.01f)
|
||||
cloudBrightness -= brightnessSpeed;
|
||||
|
||||
//wielkość słońca
|
||||
if (glfwGetKey(window, GLFW_KEY_7) == GLFW_PRESS && sunSize < 0.1f)
|
||||
sunSize += sizeSpeed * 10;
|
||||
else if (glfwGetKey(window, GLFW_KEY_8) == GLFW_PRESS && sunSize > 0.01f)
|
||||
sunSize -= sizeSpeed * 10;
|
||||
|
||||
//obrót skyboxa
|
||||
float rotSpeed = 1.0f;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_9) == GLFW_PRESS && skyBoxRot < 360.0f)
|
||||
skyBoxRot += rotSpeed;
|
||||
else if (glfwGetKey(window, GLFW_KEY_0) == GLFW_PRESS && skyBoxRot > 0.0f)
|
||||
skyBoxRot -= rotSpeed;
|
||||
}
|
||||
|
||||
void init(GLFWwindow* window) {
|
||||
|
Loading…
Reference in New Issue
Block a user