boost
This commit is contained in:
parent
2e26ed7042
commit
a7eaeffaf3
@ -23,6 +23,7 @@ Core::RenderContext shipContext;
|
||||
Core::RenderContext sunContext;
|
||||
Core::RenderContext planetContext;
|
||||
Core::RenderContext stationContext;
|
||||
Core::RenderContext engineContext;
|
||||
|
||||
Core::RenderContext cubeContext;
|
||||
|
||||
@ -91,6 +92,9 @@ glm::vec3 cameraDir;
|
||||
glm::vec3 spaceshipPos = glm::vec3(-4.0f, 0.0f, 0.0f);
|
||||
glm::vec3 spaceshipDir = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
|
||||
glm::float1 engineIs = 0;
|
||||
//glm::float1 engineInstalled = 0;
|
||||
|
||||
float lastTime = -1.f;
|
||||
float deltaTime = 0.f;
|
||||
|
||||
@ -114,8 +118,20 @@ void processInput(GLFWwindow* window)
|
||||
if (!glfwJoystickPresent(GLFW_JOYSTICK_1)) {
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
float cameraSpeed = 0.1f * deltaTime * 15;
|
||||
|
||||
|
||||
//station glm::vec3(0.f, 0.4f, 4.f)
|
||||
if (engineIs==1&&spaceshipPos.x > -0.7 && 0.3>spaceshipPos.x && spaceshipPos.z > 3.7 && 4.3>spaceshipPos.z)
|
||||
{
|
||||
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
|
||||
engineIs = 2;
|
||||
}
|
||||
|
||||
if (engineIs == 2)
|
||||
cameraSpeed = cameraSpeed * 3;//1.5;
|
||||
|
||||
|
||||
float cameraSpeed = 0.1f * deltaTime * 20;
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += cameraSpeed * spaceshipDir;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
@ -131,6 +147,7 @@ void processInput(GLFWwindow* window)
|
||||
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.05f;
|
||||
}
|
||||
|
||||
|
||||
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint albedo, GLuint normal, GLuint ao, GLuint roughness, GLuint metallic) {
|
||||
|
||||
glUseProgram(program);
|
||||
@ -246,6 +263,23 @@ unsigned int loadCubemap()
|
||||
return textureID;
|
||||
}
|
||||
|
||||
void isTouching(glm::vec3 objectPos) {
|
||||
//spaceXYZ = glm::vec3(float x, float y, float z);
|
||||
float xpos = spaceshipPos.x;
|
||||
float zpos = spaceshipPos.z;
|
||||
float xup = objectPos.x+0.2;
|
||||
float xdown = objectPos.x-0.2;
|
||||
float zup = objectPos.z+0.2;
|
||||
float zdown = objectPos.z-0.2;
|
||||
//6,0,0
|
||||
if (xup > xpos&&xpos > xdown && zup > zpos &&zpos > zdown)
|
||||
//if(xpos>6&&1>zpos&&zpos>-1)
|
||||
engineIs = 1;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void renderScene(GLFWwindow* window) {
|
||||
@ -280,6 +314,13 @@ void renderScene(GLFWwindow* window) {
|
||||
* glm::scale(glm::vec3(0.005f)),
|
||||
texture::ship_albedo, texture::ship_normal, texture::ship_ao, texture::ship_roughness, texture::ship_metallic);
|
||||
|
||||
|
||||
isTouching(glm::vec3(4, -0.2f, -3));
|
||||
if (engineIs == 0)
|
||||
drawObjectPBR(engineContext, glm::translate(glm::vec3(4, -0.2f, -3)) * glm::eulerAngleY(-0.7f * time) * glm::scale(glm::vec3(0.1f)), texture::station_albedo, texture::station_normal, texture::station_ao, texture::station_roughness, texture::station_metallic);
|
||||
|
||||
|
||||
|
||||
drawObjectPBR(planetContext, glm::eulerAngleY(time / 4) * glm::translate(glm::vec3(6.f, 0, 0)) * glm::eulerAngleY(-0.7f * time) * glm::scale(glm::vec3(0.4f)), texture::planet_albedo, texture::planet_normal, texture::planet_ao, texture::planet_roughness, texture::planet_metallic);
|
||||
drawObjectPBR(planetContext, glm::eulerAngleY(time / 5) * glm::translate(glm::vec3(-7.f, 0, 0)) * glm::eulerAngleY(-0.3f * time) * glm::scale(glm::vec3(0.2f)), texture::mars_albedo, texture::mars_normal, texture::mars_ao, texture::mars_roughness, texture::mars_metallic);
|
||||
drawObjectPBR(planetContext, glm::eulerAngleY(time / 7) * glm::translate(glm::vec3(0, 0, 8.f)) * glm::eulerAngleY(-2.0f * time) * glm::scale(glm::vec3(0.3f)), texture::jupiter_albedo, texture::jupiter_normal, texture::jupiter_ao, texture::jupiter_roughness, texture::jupiter_metallic);
|
||||
@ -327,6 +368,8 @@ void init(GLFWwindow* window)
|
||||
|
||||
loadModelToContext("./models/cube.obj", cubeContext);
|
||||
|
||||
loadModelToContext("./models/engine.obj", engineContext);
|
||||
|
||||
//load skybox here
|
||||
|
||||
programSkybox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||
@ -380,10 +423,10 @@ void init(GLFWwindow* window)
|
||||
//texture::station_metallic = Core::LoadTexture("textures/station1/metallic.jpg");
|
||||
|
||||
|
||||
texture::station_albedo = Core::LoadTexture("textures/station2/ALUM_8L2.JPG");
|
||||
texture::station_normal = Core::LoadTexture("textures/station2/ALUM_8L4.JPG");
|
||||
texture::station_roughness = Core::LoadTexture("textures/station2/ALUM_809.JPG");
|
||||
texture::station_ao = Core::LoadTexture("textures/station2/Alum_panel1.jpg");
|
||||
texture::station_ao = Core::LoadTexture("textures/station2/ALUM_8L2.JPG");
|
||||
texture::station_normal = Core::LoadTexture("textures/station2/ALUM_809.JPG");
|
||||
texture::station_roughness = Core::LoadTexture("textures/station2/ALUM_8L4.JPG");
|
||||
texture::station_albedo = Core::LoadTexture("textures/station2/Alum_panel1.jpg");
|
||||
texture::station_metallic = Core::LoadTexture("textures/station2/Aluminium6.jpg");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user