This commit is contained in:
sasankasa 2024-01-18 19:01:12 +01:00
parent 1c4579f1d6
commit f3b87b5589
45 changed files with 73 additions and 27 deletions

View File

@ -15,14 +15,45 @@
#include <string> #include <string>
namespace texture { namespace texturePlanets {
GLuint earth; GLuint earth;
GLuint clouds; GLuint planet;
GLuint moon;
GLuint mercury; GLuint mercury;
GLuint venus; GLuint venus;
GLuint mars; GLuint mars;
GLuint sun; GLuint alpine;
GLuint ceres;
GLuint eris;
GLuint haumea;
GLuint icy;
GLuint jupiter;
GLuint makemake;
GLuint martian;
GLuint neptune;
GLuint saturn;
GLuint savannah;
GLuint swamp;
GLuint tropical;
GLuint uranus;
GLuint venusian;
GLuint volcanic;
}
namespace textureSuns {
GLuint sun1;
GLuint sun2;
GLuint sun3;
GLuint sun4;
}
namespace textureMoons {
GLuint moon1;
GLuint moon2;
GLuint moon3;
}
namespace textureMaterials {
GLuint clouds;
} }
GLuint program; GLuint program;
@ -53,8 +84,7 @@ int HDR_HEIGHT = 1024;
glm::vec3 lightColor = glm::vec3(50, 50, 50); glm::vec3 lightColor = glm::vec3(50, 50, 50);
glm::mat4 createCameraMatrix() glm::mat4 createCameraMatrix() {
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f))); 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::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
@ -72,9 +102,7 @@ glm::mat4 createCameraMatrix()
return cameraMatrix; return cameraMatrix;
} }
glm::mat4 createPerspectiveMatrix() glm::mat4 createPerspectiveMatrix() {
{
glm::mat4 perspectiveMatrix; glm::mat4 perspectiveMatrix;
float n = 0.05f; float n = 0.05f;
float f = 20.f; float f = 20.f;
@ -89,7 +117,6 @@ glm::mat4 createPerspectiveMatrix()
0.,0.,-1.,0., 0.,0.,-1.,0.,
}); });
perspectiveMatrix = glm::transpose(perspectiveMatrix); perspectiveMatrix = glm::transpose(perspectiveMatrix);
return perspectiveMatrix; return perspectiveMatrix;
@ -191,8 +218,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
} }
*/ */
void renderScene(GLFWwindow* window) void renderScene(GLFWwindow* window) {
{
glClearColor(0.0f, 0.0f, 0.15f, 1.0f); glClearColor(0.0f, 0.0f, 0.15f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 transformation; glm::mat4 transformation;
@ -201,25 +227,23 @@ void renderScene(GLFWwindow* window)
glm::mat4 sunScale = glm::scale(glm::vec3(0.04f)); glm::mat4 sunScale = glm::scale(glm::vec3(0.04f));
glm::mat4 sunTranslate = glm::translate(sunPosition); glm::mat4 sunTranslate = glm::translate(sunPosition);
drawSun(sphereContext, sunTranslate * sunScale, texture::sun); drawSun(sphereContext, sunTranslate * sunScale, textureSuns::sun1);
glm::mat4 planetScale = glm::scale(glm::vec3(0.005f)); // model jest bardzo duży, dlatego taka niska skala glm::mat4 planetScale = glm::scale(glm::vec3(0.005f)); // model jest bardzo duży, dlatego taka niska skala
glm::mat4 planetRotate = glm::rotate(time * 0.0416f, glm::vec3(0, 1, 0)); // 1 godzina mija w 1 sekundę, obrót z zachodu na wschód glm::mat4 planetRotate = glm::rotate(time * 0.0416f, glm::vec3(0, 1, 0)); // 1 godzina mija w 1 sekundę, obrót z zachodu na wschód
glm::mat4 planetTranslate = glm::translate(glm::vec3(0, 0, 0)); // zostaje na domyślnej pozycji glm::mat4 planetTranslate = glm::translate(glm::vec3(0, 0, 0)); // zostaje na domyślnej pozycji
drawObjectTexture(sphereContext, planetTranslate * planetRotate * planetScale, texture::earth); drawObjectTexture(sphereContext, planetTranslate * planetRotate * planetScale, texturePlanets::earth);
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
void framebuffer_size_callback(GLFWwindow* window, int width, int height) void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
{
aspectRatio = float(width) / float(height); aspectRatio = float(width) / float(height);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
} }
void loadModelToContext(std::string path, Core::RenderContext& context) void loadModelToContext(std::string path, Core::RenderContext& context) {
{
Assimp::Importer import; Assimp::Importer import;
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace); const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_CalcTangentSpace);
@ -231,8 +255,7 @@ void loadModelToContext(std::string path, Core::RenderContext& context)
context.initFromAssimpMesh(scene->mMeshes[0]); context.initFromAssimpMesh(scene->mMeshes[0]);
} }
void init(GLFWwindow* window) void init(GLFWwindow* window) {
{
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -246,21 +269,44 @@ void init(GLFWwindow* window)
loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/sphere.obj", sphereContext);
texture::earth = Core::LoadTexture("./textures/earth2.png"); texturePlanets::earth = Core::LoadTexture("./textures/planets/earth2.png");
texture::clouds = Core::LoadTexture("./textures/clouds.jpg"); /*texturePlanets::planet = Core::LoadTexture("./textures/planets/planet.png");
texture::sun = Core::LoadTexture("./textures/sun.jpg"); texturePlanets::mercury = Core::LoadTexture("./textures/planets/mercury1.jpg");
texturePlanets::venus = Core::LoadTexture("./textures/planets/earth2.png");
texturePlanets::mars = Core::LoadTexture("./textures/planets/mars.jpg");
texturePlanets::alpine = Core::LoadTexture("./textures/planets/Alpine.png");
texturePlanets::ceres = Core::LoadTexture("./textures/planets/ceres_fictional.jpg");
texturePlanets::eris = Core::LoadTexture("./textures/planets/eris_fictional.jpg");
texturePlanets::haumea = Core::LoadTexture("./textures/planets/haumea_fictional.jpg");
texturePlanets::icy = Core::LoadTexture("./textures/planets/Icy.png");
texturePlanets::jupiter = Core::LoadTexture("./textures/planets/jupiter.jpg");
texturePlanets::makemake = Core::LoadTexture("./textures/planets/makemake_fictional.jpg");
texturePlanets::martian = Core::LoadTexture("./textures/planets/Martian.png");
texturePlanets::neptune = Core::LoadTexture("./textures/planets/neptune.jpg");
texturePlanets::saturn = Core::LoadTexture("./textures/planets/saturn.jpg");
texturePlanets::savannah = Core::LoadTexture("./textures/planets/Savannah.png");
texturePlanets::swamp = Core::LoadTexture("./textures/planets/Swamp.png");
texturePlanets::tropical = Core::LoadTexture("./textures/planets/Tropical.png");
texturePlanets::uranus = Core::LoadTexture("./textures/planets/uranus.jpg");
texturePlanets::venusian = Core::LoadTexture("./textures/planets/Venusian.png");
texturePlanets::volcanic = Core::LoadTexture("./textures/planets/Volcanic.png");*/
textureSuns::sun1 = Core::LoadTexture("./textures/suns/sun1.jpg");
/*textureSuns::sun2 = Core::LoadTexture("./textures/suns/sun2.jpg");
textureSuns::sun3 = Core::LoadTexture("./textures/suns/sun3.jpg");
textureSuns::sun4 = Core::LoadTexture("./textures/suns/sun4.jpg");*/
textureMaterials::clouds = Core::LoadTexture("./textures/planets/clouds.jpg");
} }
void shutdown(GLFWwindow* window) void shutdown(GLFWwindow* window) {
{
shaderLoader.DeleteProgram(programDepth); shaderLoader.DeleteProgram(programDepth);
shaderLoader.DeleteProgram(programTex); shaderLoader.DeleteProgram(programTex);
shaderLoader.DeleteProgram(programSun); shaderLoader.DeleteProgram(programSun);
} }
//obsluga wejscia //obsluga wejscia
void processInput(GLFWwindow* window) void processInput(GLFWwindow* window) {
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f))); glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
float angleSpeed = 0.002f; float angleSpeed = 0.002f;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 MiB

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 6.5 MiB

After

Width:  |  Height:  |  Size: 6.5 MiB

View File

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

Before

Width:  |  Height:  |  Size: 598 KiB

After

Width:  |  Height:  |  Size: 598 KiB

View File

Before

Width:  |  Height:  |  Size: 424 KiB

After

Width:  |  Height:  |  Size: 424 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 9.2 MiB

After

Width:  |  Height:  |  Size: 9.2 MiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

View File

Before

Width:  |  Height:  |  Size: 279 KiB

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 3.0 MiB

View File

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 KiB

View File

Before

Width:  |  Height:  |  Size: 803 KiB

After

Width:  |  Height:  |  Size: 803 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB