more models, more better
This commit is contained in:
parent
f79cb1d402
commit
284f688c6d
@ -25,12 +25,12 @@ const unsigned int SCR_WIDTH = 800 * 2;
|
||||
const unsigned int SCR_HEIGHT = 600 * 2;
|
||||
|
||||
// camera
|
||||
Camera camera(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||
Camera camera(glm::vec3(-1.75f, 4.0f, 2.25f), glm::vec3(0.0f, 1.0f, 0.0f), 295.0f, -14.3f);
|
||||
float lastX = (float)SCR_WIDTH / 2.0;
|
||||
float lastY = (float)SCR_HEIGHT / 2.0;
|
||||
bool firstMouse = true;
|
||||
|
||||
glm::vec3 spaceshipTranslate(1.0f);
|
||||
glm::vec3 spaceshipTranslate(0.0f, 3.5f, -40.0f);
|
||||
|
||||
// timing
|
||||
float deltaTime = 0.0f;
|
||||
@ -43,7 +43,7 @@ glm::vec3 pointLightPositions[] = {
|
||||
glm::vec3(-18.0f, 3.0f, 99999.0f),
|
||||
glm::vec3( 0.8f, -16.6f, -0.6f),
|
||||
glm::vec3( 6.8f, -7.4f, -7.2f),
|
||||
glm::vec3( -11.8f, -7.889f, 15.0f),
|
||||
glm::vec3( 0.0f, 0.0f, 0.0f),
|
||||
glm::vec3(-14.0f, 3.0f, 2.0f),
|
||||
};
|
||||
size_t pointLightPositionsNum = sizeof(pointLightPositions) / sizeof(pointLightPositions[0]);
|
||||
@ -99,10 +99,14 @@ int main(int argc, char** argv)
|
||||
|
||||
// build and compile models
|
||||
// ------------------------
|
||||
Model kniedeModel("../resources/objects/kniede/kniede.obj1");
|
||||
Model kniedeModel("../resources/objects/kniede/kniede.obj");
|
||||
Model spaceshipModel("../resources/objects/spaceship/Intergalactic_Spaceship.obj");
|
||||
Model barrelModel("../resources/objects/barrel/barrel.obj");
|
||||
|
||||
Model cabinetModel("../resources/objects/cabinet/cabinet.obj");
|
||||
Model chairModel("../resources/objects/chair/chair.obj");
|
||||
Model commodeModel("../resources/objects/commode/commode.obj");
|
||||
|
||||
stbi_set_flip_vertically_on_load(true);
|
||||
Model backpackModel("../resources/objects/backpack/backpack.obj");
|
||||
stbi_set_flip_vertically_on_load(false);
|
||||
@ -222,7 +226,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// load textures
|
||||
// -------------
|
||||
string dir = "../resources/textures/SaintsPetersBasilica/";
|
||||
string dir = "../resources/textures/skybox/park-skyboxes/Park/";
|
||||
|
||||
vector<std::string> faces
|
||||
{
|
||||
@ -287,20 +291,20 @@ int main(int argc, char** argv)
|
||||
lightingShader.setFloat("pointLights[0].quadratic", 0.032);
|
||||
// point light 2
|
||||
lightingShader.setVec3("pointLights[1].position", pointLightPositions[1]);
|
||||
lightingShader.setVec3("pointLights[1].ambient", 0.1f, 0.5f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[1].diffuse", 0.5f, 1.0f, 0.8f);
|
||||
lightingShader.setVec3("pointLights[1].specular", 1.0f, 1.0f, 1.0f);
|
||||
lightingShader.setVec3("pointLights[1].ambient", 0.1f, 0.3f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[1].diffuse", 0.5f, 5.0f, 0.5f);
|
||||
lightingShader.setVec3("pointLights[1].specular", 0.6f, 0.6f, 0.6f);
|
||||
lightingShader.setFloat("pointLights[1].constant", 0.1f);
|
||||
lightingShader.setFloat("pointLights[1].linear", 0.09);
|
||||
lightingShader.setFloat("pointLights[1].linear", 0.19);
|
||||
lightingShader.setFloat("pointLights[1].quadratic", 0.032);
|
||||
// point light 3
|
||||
lightingShader.setVec3("pointLights[2].position", pointLightPositions[2]);
|
||||
lightingShader.setVec3("pointLights[2].ambient", 0.7f, 0.3f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[2].diffuse", 4.0f, 1.0f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[2].specular", 0.5f, 0.5f, 0.0f);
|
||||
lightingShader.setFloat("pointLights[2].constant", 0.3f);
|
||||
lightingShader.setFloat("pointLights[2].linear", 0.09);
|
||||
lightingShader.setFloat("pointLights[2].quadratic", 0.032);
|
||||
lightingShader.setVec3("pointLights[2].ambient", 0.4f, 0.1f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[2].diffuse", 0.5f, 0.5f, 0.0f);
|
||||
lightingShader.setVec3("pointLights[2].specular", 0.2f, 0.2f, 0.0f);
|
||||
lightingShader.setFloat("pointLights[2].constant", 1.0f);
|
||||
lightingShader.setFloat("pointLights[2].linear", 0.19);
|
||||
lightingShader.setFloat("pointLights[2].quadratic", 0.012);
|
||||
// point light 4
|
||||
// pointLightPositions[3].z = 14.0f + (glm::cos(glfwGetTime() * 3) * 2);
|
||||
lightingShader.setVec3("pointLights[3].position", pointLightPositions[3]);
|
||||
@ -314,13 +318,13 @@ int main(int argc, char** argv)
|
||||
lightingShader.setVec3("spotLight.position", pointLightPositions[4]);
|
||||
lightingShader.setVec3("spotLight.direction", glm::vec3(0.82f, -0.24f, -0.5f));
|
||||
lightingShader.setVec3("spotLight.ambient", 0.0f, 0.0f, 0.0f);
|
||||
lightingShader.setVec3("spotLight.diffuse", 40.0f, 40.0f, 40.0f);
|
||||
lightingShader.setVec3("spotLight.diffuse", 30.0f, 30.0f, 30.0f);
|
||||
lightingShader.setVec3("spotLight.specular", 1.0f, 1.0f, 1.0f);
|
||||
lightingShader.setFloat("spotLight.constant", 0.5f);
|
||||
lightingShader.setFloat("spotLight.linear", 0.09);
|
||||
lightingShader.setFloat("spotLight.quadratic", 0.032);
|
||||
lightingShader.setFloat("spotLight.cutOff", glm::cos(glm::radians(15.5f)));
|
||||
lightingShader.setFloat("spotLight.outerCutOff", glm::cos(glm::radians(40.0f + glm::sin(glfwGetTime()) * 8)));
|
||||
lightingShader.setFloat("spotLight.cutOff", glm::cos(glm::radians(10.0f)));
|
||||
lightingShader.setFloat("spotLight.outerCutOff", glm::cos(glm::radians(20.0f + glm::sin(glfwGetTime()) * 8)));
|
||||
|
||||
// DEFAULTS
|
||||
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
|
||||
@ -336,36 +340,51 @@ int main(int argc, char** argv)
|
||||
lightingShader.setMat4("view", view);
|
||||
|
||||
// plecak
|
||||
// model = glm::translate(glm::mat4(1.0f), glm::vec3(-0.8f, -13.6f, -7.0f));
|
||||
model = glm::translate(glm::mat4(1.0f), spaceshipTranslate);
|
||||
// model = glm::translate(model, spaceshipTranslate);
|
||||
model = glm::scale(model, glm::vec3(0.5f));
|
||||
model = glm::translate(model, glm::vec3(2.2f, 0.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians((float)glfwGetTime() * 60) + 90, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
model = glm::translate(model, glm::vec3(-2.2f, 0.0f, 0.0f));
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(4, 0.5, -4));
|
||||
model = glm::rotate(model, glm::radians(-90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
model = glm::scale(model, glm::vec3(0.2f));
|
||||
lightingShader.setMat4("model", model);
|
||||
backpackModel.Draw(lightingShader);
|
||||
|
||||
// pomnik
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(0.4, -23, -7));
|
||||
pointLightPositions[4] = glm::vec3(-12, 10, -15);
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(3, -10, -20));
|
||||
model = glm::rotate(model, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
model = glm::translate(model, glm::vec3(-0.4, 0.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians((float)glfwGetTime() * 60), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
model = glm::rotate(model, glm::radians((float)glfwGetTime() * 10), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
lightingShader.setMat4("model", model);
|
||||
kniedeModel.Draw(lightingShader);
|
||||
|
||||
// beczka
|
||||
model = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
model = glm::translate(model, glm::vec3(10, -3, -7));
|
||||
// model = glm::translate(glm::mat4(1.0f), spaceshipTranslate);
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, -5));
|
||||
model = glm::rotate(model, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
lightingShader.setMat4("model", model);
|
||||
barrelModel.Draw(lightingShader);
|
||||
|
||||
// światła nad meblami
|
||||
pointLightPositions[1] = glm::vec3(5 + (glm::cos((float)glfwGetTime() * 2)) * 8, 1, +5);
|
||||
pointLightPositions[2] = glm::vec3(1 + (glm::sin((float)glfwGetTime() * 2)) * 4, 5, -5);
|
||||
|
||||
// krzesło
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(1, 0, -5));
|
||||
lightingShader.setMat4("model", model);
|
||||
chairModel.Draw(lightingShader);
|
||||
|
||||
// komoda
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(2, 0, -5));
|
||||
lightingShader.setMat4("model", model);
|
||||
commodeModel.Draw(lightingShader);
|
||||
|
||||
// szafa
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(3.5, 0, -5));
|
||||
lightingShader.setMat4("model", model);
|
||||
cabinetModel.Draw(lightingShader);
|
||||
|
||||
// statek kosmiczny
|
||||
// model = glm::translate(glm::mat4(1.0f), glm::vec3(15, -4, 9));
|
||||
// model = glm::translate(model, spaceshipTranslate);
|
||||
// lightingShader.setMat4("model", model);
|
||||
// spaceshipModel.Draw(lightingShader);
|
||||
pointLightPositions[3] = spaceshipTranslate + glm::vec3(3.5f, 0.0f, -7.0f);
|
||||
model = glm::translate(model, spaceshipTranslate);
|
||||
model = glm::scale(model, glm::vec3(0.4f));
|
||||
lightingShader.setMat4("model", model);
|
||||
spaceshipModel.Draw(lightingShader);
|
||||
|
||||
// kostka z odbiciem
|
||||
model = glm::rotate(glm::mat4(1.0f), angle, glm::vec3(0, 1, 0));
|
||||
@ -382,8 +401,6 @@ int main(int argc, char** argv)
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
|
||||
// pointLightPositions[2] = spaceshipTranslate;
|
||||
|
||||
// światła (kostki)
|
||||
for (unsigned int i = 0; i < pointLightPositionsNum; i++)
|
||||
{
|
||||
@ -402,7 +419,7 @@ int main(int argc, char** argv)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
// glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
|
||||
@ -439,20 +456,25 @@ void processInput(GLFWwindow *window)
|
||||
camera.ProcessKeyboard(RIGHT, deltaTime);
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
|
||||
spaceshipTranslate.x += 0.02f;
|
||||
spaceshipTranslate.x += 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS)
|
||||
spaceshipTranslate.x -= 0.02f;
|
||||
spaceshipTranslate.x -= 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS)
|
||||
spaceshipTranslate.y -= 0.02f;
|
||||
spaceshipTranslate.y -= 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)
|
||||
spaceshipTranslate.y += 0.02f;
|
||||
spaceshipTranslate.y += 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
|
||||
spaceshipTranslate.z += 0.01f;
|
||||
spaceshipTranslate.z += 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
|
||||
spaceshipTranslate.z -= 0.01f;
|
||||
spaceshipTranslate.z -= 0.1f;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS)
|
||||
std::cout << spaceshipTranslate.x << " " << spaceshipTranslate.y << " " << spaceshipTranslate.z << std::endl;
|
||||
std::cout
|
||||
<< camera.Position.x << ", "
|
||||
<< camera.Position.y << ", "
|
||||
<< camera.Position.z << " - "
|
||||
<< camera.Yaw << ", "
|
||||
<< camera.Pitch << std::endl;
|
||||
if (glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS)
|
||||
spaceshipTranslate = glm::vec3(1.0f);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user