Compare commits
No commits in common. "2b390af6d9fb2ed57d5cf93c8545e6deb433b200" and "321f321cb06d7df2908ff335af6299a7d748b611" have entirely different histories.
2b390af6d9
...
321f321cb0
@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
class GameUtils
|
||||
{
|
||||
private:
|
||||
|
||||
// Private constructor to prevent external instantiation
|
||||
GameUtils() : aspectRatio(1.f) {}
|
||||
|
||||
public:
|
||||
float aspectRatio;
|
||||
|
||||
static GameUtils& getInstance()
|
||||
{
|
||||
static GameUtils instance; // Jedna i jedyna instancja
|
||||
return instance;
|
||||
}
|
||||
};
|
@ -1,95 +0,0 @@
|
||||
#include "glm.hpp"
|
||||
#include "ext.hpp"
|
||||
|
||||
#pragma once
|
||||
class Spaceship
|
||||
{
|
||||
private:
|
||||
// Prywatny konstruktor, aby zapobiec zewnêtrznemu tworzeniu instancji
|
||||
Spaceship() {}
|
||||
|
||||
// Prywatny destruktor, aby zapobiec przypadkowemu usuwaniu instancji
|
||||
~Spaceship() {}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static Spaceship& getInstance()
|
||||
{
|
||||
static Spaceship instance; // Jedna i jedyna instancja
|
||||
return instance;
|
||||
}
|
||||
|
||||
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f);
|
||||
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
|
||||
|
||||
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
|
||||
float spotlightPhi = 3.14 / 4;
|
||||
|
||||
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
||||
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
||||
|
||||
glm::mat4 calculateModelMatrix() {
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
||||
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
||||
-spaceshipDir.x,-spaceshipDir.y,-spaceshipDir.z,0,
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
return glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f));
|
||||
}
|
||||
|
||||
void processInput(GLFWwindow* window, float deltaTime) {
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
|
||||
float angleSpeed = 0.05f * deltaTime * 60;
|
||||
float moveSpeed = 0.05f * deltaTime * 60;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
|
||||
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
|
||||
cameraDir = spaceshipDir;
|
||||
|
||||
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
|
||||
spotlightConeDir = spaceshipDir;
|
||||
}
|
||||
|
||||
glm::mat4 createCameraMatrix()
|
||||
{
|
||||
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
|
||||
glm::mat4 cameraRotrationMatrix = glm::mat4({
|
||||
cameraSide.x,cameraSide.y,cameraSide.z,0,
|
||||
cameraUp.x,cameraUp.y,cameraUp.z ,0,
|
||||
-cameraDir.x,-cameraDir.y,-cameraDir.z,0,
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
cameraRotrationMatrix = glm::transpose(cameraRotrationMatrix);
|
||||
glm::mat4 cameraMatrix = cameraRotrationMatrix * glm::translate(-cameraPos);
|
||||
|
||||
return cameraMatrix;
|
||||
}
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
#include "glm.hpp"
|
||||
#include "ext.hpp"
|
||||
#include "./Spaceship.h"
|
||||
|
||||
#pragma once
|
||||
class Sun
|
||||
{
|
||||
public:
|
||||
glm::vec3 sunPos = glm::vec3(0, 2, 0);
|
||||
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
||||
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5;
|
||||
GLuint program;
|
||||
Core::RenderContext sphereContext;
|
||||
|
||||
Sun(GLuint program, Core::RenderContext sphereContext) {
|
||||
this->program = program;
|
||||
this->sphereContext = sphereContext;
|
||||
}
|
||||
|
||||
Sun(){}
|
||||
|
||||
void draw() {
|
||||
glUseProgram(program);
|
||||
glm::mat4 viewProjectionMatrix = Core::createPerspectiveMatrix() * Spaceship::getInstance().createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * glm::translate(sunPos) * glm::scale(glm::vec3(0.1));
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniform3f(glGetUniformLocation(program, "color"), sunColor.x / 2, sunColor.y / 2, sunColor.z / 2);
|
||||
glUniform1f(glGetUniformLocation(program, "exposition"), 1.f);
|
||||
Core::DrawContext(sphereContext);
|
||||
}
|
||||
};
|
@ -23,8 +23,6 @@
|
||||
<ClCompile Include="src\Texture.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameUtils.h" />
|
||||
<ClInclude Include="Spaceship.h" />
|
||||
<ClInclude Include="src\Camera.h" />
|
||||
<ClInclude Include="src\ex_9_1.hpp" />
|
||||
<ClInclude Include="src\objload.h" />
|
||||
@ -37,7 +35,6 @@
|
||||
<ClInclude Include="src\SOIL\stbi_DDS_aug_c.h" />
|
||||
<ClInclude Include="src\SOIL\stb_image_aug.h" />
|
||||
<ClInclude Include="src\Texture.h" />
|
||||
<ClInclude Include="Sun.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\shader_9_1.frag" />
|
||||
|
@ -89,15 +89,6 @@
|
||||
<ClInclude Include="src\ex_9_1.hpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Sun.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Spaceship.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GameUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\shader_8_sun.vert">
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include "../GameUtils.h"
|
||||
|
||||
|
||||
|
||||
@ -127,24 +126,3 @@ void Core::DrawContext(Core::RenderContext& context)
|
||||
);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
glm::mat4 Core::createPerspectiveMatrix()
|
||||
{
|
||||
|
||||
glm::mat4 perspectiveMatrix;
|
||||
float n = 0.05;
|
||||
float f = 20.;
|
||||
float a1 = glm::min(GameUtils::getInstance().aspectRatio, 1.f);
|
||||
float a2 = glm::min(1 / GameUtils::getInstance().aspectRatio, 1.f);
|
||||
perspectiveMatrix = glm::mat4({
|
||||
1,0.,0.,0.,
|
||||
0.,GameUtils::getInstance().aspectRatio,0.,0.,
|
||||
0.,0.,(f + n) / (n - f),2 * f * n / (n - f),
|
||||
0.,0.,-1.,0.,
|
||||
});
|
||||
|
||||
|
||||
perspectiveMatrix = glm::transpose(perspectiveMatrix);
|
||||
|
||||
return perspectiveMatrix;
|
||||
}
|
@ -69,6 +69,4 @@ namespace Core
|
||||
void DrawVertexArray(const VertexData & data);
|
||||
|
||||
void DrawContext(RenderContext& context);
|
||||
|
||||
glm::mat4 createPerspectiveMatrix();
|
||||
}
|
@ -14,9 +14,6 @@
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
#include <string>
|
||||
#include "../Sun.h"
|
||||
#include "../Spaceship.h"
|
||||
#include "../GameUtils.h"
|
||||
|
||||
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||
|
||||
@ -52,14 +49,32 @@ Core::Shader_Loader shaderLoader;
|
||||
Core::RenderContext shipContext;
|
||||
Core::RenderContext sphereContext;
|
||||
|
||||
Sun sun;
|
||||
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
||||
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
||||
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f)*5;
|
||||
|
||||
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
||||
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
||||
|
||||
|
||||
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f);
|
||||
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
|
||||
GLuint VAO,VBO;
|
||||
|
||||
float aspectRatio = 1.f;
|
||||
|
||||
float exposition = 1.f;
|
||||
|
||||
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
|
||||
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
|
||||
|
||||
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9)*3;
|
||||
float spotlightPhi = 3.14 / 4;
|
||||
|
||||
|
||||
|
||||
float lastTime = -1.f;
|
||||
float deltaTime = 0.f;
|
||||
|
||||
@ -73,10 +88,46 @@ void updateDeltaTime(float time) {
|
||||
if (deltaTime > 0.1) deltaTime = 0.1;
|
||||
lastTime = time;
|
||||
}
|
||||
glm::mat4 createCameraMatrix()
|
||||
{
|
||||
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
|
||||
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide,cameraDir));
|
||||
glm::mat4 cameraRotrationMatrix = glm::mat4({
|
||||
cameraSide.x,cameraSide.y,cameraSide.z,0,
|
||||
cameraUp.x,cameraUp.y,cameraUp.z ,0,
|
||||
-cameraDir.x,-cameraDir.y,-cameraDir.z,0,
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
cameraRotrationMatrix = glm::transpose(cameraRotrationMatrix);
|
||||
glm::mat4 cameraMatrix = cameraRotrationMatrix * glm::translate(-cameraPos);
|
||||
|
||||
return cameraMatrix;
|
||||
}
|
||||
|
||||
glm::mat4 createPerspectiveMatrix()
|
||||
{
|
||||
|
||||
glm::mat4 perspectiveMatrix;
|
||||
float n = 0.05;
|
||||
float f = 20.;
|
||||
float a1 = glm::min(aspectRatio, 1.f);
|
||||
float a2 = glm::min(1 / aspectRatio, 1.f);
|
||||
perspectiveMatrix = glm::mat4({
|
||||
1,0.,0.,0.,
|
||||
0.,aspectRatio,0.,0.,
|
||||
0.,0.,(f+n) / (n - f),2*f * n / (n - f),
|
||||
0.,0.,-1.,0.,
|
||||
});
|
||||
|
||||
|
||||
perspectiveMatrix=glm::transpose(perspectiveMatrix);
|
||||
|
||||
return perspectiveMatrix;
|
||||
}
|
||||
|
||||
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float roughness, float metallic) {
|
||||
|
||||
glm::mat4 viewProjectionMatrix = Core::createPerspectiveMatrix() * Spaceship::getInstance().createCameraMatrix();
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
@ -88,18 +139,18 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), Spaceship::getInstance().cameraPos.x, Spaceship::getInstance().cameraPos.y, Spaceship::getInstance().cameraPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "sunDir"), sun.sunDir.x, sun.sunDir.y, sun.sunDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "sunColor"), sun.sunColor.x, sun.sunColor.y, sun.sunColor.z);
|
||||
glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
|
||||
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), Spaceship::getInstance().spotlightConeDir.x, Spaceship::getInstance().spotlightConeDir.y, Spaceship::getInstance().spotlightConeDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightPos"), Spaceship::getInstance().spotlightPos.x, Spaceship::getInstance().spotlightPos.y, Spaceship::getInstance().spotlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), Spaceship::getInstance().spotlightColor.x, Spaceship::getInstance().spotlightColor.y, Spaceship::getInstance().spotlightColor.z);
|
||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), Spaceship::getInstance().spotlightPhi);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||
Core::DrawContext(context);
|
||||
|
||||
}
|
||||
@ -128,7 +179,12 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
//space lamp
|
||||
glUseProgram(programSun);
|
||||
sun.draw();
|
||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||
glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1));
|
||||
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||
glUniform3f(glGetUniformLocation(programSun, "color"), sunColor.x / 2, sunColor.y / 2, sunColor.z / 2);
|
||||
glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition);
|
||||
Core::DrawContext(sphereContext);
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
@ -150,16 +206,31 @@ void renderScene(GLFWwindow* window)
|
||||
drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
|
||||
drawObjectPBR(models::windowContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
||||
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
||||
-spaceshipDir.x,-spaceshipDir.y,-spaceshipDir.z,0,
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
|
||||
//drawObjectColor(shipContext,
|
||||
// glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
||||
// glm::vec3(0.3, 0.3, 0.5)
|
||||
// );
|
||||
drawObjectPBR(shipContext,
|
||||
Spaceship::getInstance().calculateModelMatrix(),
|
||||
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)),
|
||||
glm::vec3(0.3, 0.3, 0.5),
|
||||
0.2,1.0
|
||||
);
|
||||
|
||||
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
|
||||
spotlightConeDir = spaceshipDir;
|
||||
|
||||
|
||||
|
||||
//test depth buffer
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glUseProgram(programTest);
|
||||
@ -172,7 +243,7 @@ void renderScene(GLFWwindow* window)
|
||||
}
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
GameUtils::getInstance().aspectRatio = width / float(height);
|
||||
aspectRatio = width / float(height);
|
||||
glViewport(0, 0, width, height);
|
||||
WIDTH = width;
|
||||
HEIGHT = height;
|
||||
@ -213,12 +284,11 @@ void init(GLFWwindow* window)
|
||||
loadModelToContext("./models/pencils.obj", models::pencilsContext);
|
||||
loadModelToContext("./models/plane.obj", models::planeContext);
|
||||
loadModelToContext("./models/room.obj", models::roomContext);
|
||||
loadModelToContext("./models/GameUtils::spaceship.obj", models::spaceshipContext);
|
||||
loadModelToContext("./models/spaceship.obj", models::spaceshipContext);
|
||||
loadModelToContext("./models/sphere.obj", models::sphereContext);
|
||||
loadModelToContext("./models/window.obj", models::windowContext);
|
||||
loadModelToContext("./models/test.obj", models::testContext);
|
||||
|
||||
sun = Sun(programSun, models::sphereContext);
|
||||
}
|
||||
|
||||
void shutdown(GLFWwindow* window)
|
||||
@ -229,16 +299,41 @@ void shutdown(GLFWwindow* window)
|
||||
//obsluga wejscia
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
Spaceship::getInstance().processInput(window, deltaTime);
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f,1.f,0.f)));
|
||||
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
|
||||
float angleSpeed = 0.05f * deltaTime * 60;
|
||||
float moveSpeed = 0.05f * deltaTime * 60;
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipDir * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipSide * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
|
||||
spaceshipPos += spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
|
||||
spaceshipPos -= spaceshipUp * moveSpeed;
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
|
||||
|
||||
/*if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS)
|
||||
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
|
||||
cameraDir = spaceshipDir;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS)
|
||||
exposition -= 0.05;
|
||||
if (glfwGetKey(window, GLFW_KEY_2) == GLFW_PRESS)
|
||||
exposition += 0.05;*/
|
||||
exposition += 0.05;
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_3) == GLFW_PRESS) {
|
||||
printf("GameUtils::spaceshipPos = glm::vec3(%ff, %ff, %ff);\n", Spaceship::getInstance().spaceshipPos.x, Spaceship::getInstance().spaceshipPos.y, Spaceship::getInstance().spaceshipPos.z);
|
||||
printf("GameUtils::spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", Spaceship::getInstance().spaceshipDir.x, Spaceship::getInstance().spaceshipDir.y, Spaceship::getInstance().spaceshipDir.z);
|
||||
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);
|
||||
}
|
||||
|
||||
//cameraDir = glm::normalize(-cameraPos);
|
||||
|
Loading…
Reference in New Issue
Block a user