dodane planety układu słonecznego z mapowaniem normalnych

This commit is contained in:
mikgaw@st.amu.edu.pl 2024-02-22 19:31:42 +01:00
parent 12b505c047
commit da2cd749bc
39 changed files with 143 additions and 25 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,8 +2,10 @@
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1): message : zobacz poprzednią definicję „APIENTRY”
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(78,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(154,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(91,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(166,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(184,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(187,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw7.vcxproj -> D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\Debug\projekt_grk.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -41,5 +41,4 @@ void main()
gl_Position = transformation * vec4(vertexPosition, 1.0);
//
}

View File

@ -18,17 +18,30 @@
namespace texture {
GLuint mercury;
GLuint venus;
GLuint earth;
GLuint moon;
GLuint ship;
GLuint sun;
GLuint mars;
GLuint jupiter;
GLuint saturn;
GLuint uranus;
GLuint neptune;
GLuint grid;
GLuint mercuryNormal;
GLuint venusNormal;
GLuint earthNormal;
GLuint asteroidNormal;
GLuint shipNormal;
GLuint marsNormal;
GLuint jupiterNormal;
GLuint saturnNormal;
GLuint uranusNormal;
GLuint neptuneNormal;
GLuint grid;
}
@ -136,8 +149,10 @@ void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glUseProgram(programSkyBox);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
GLint transformLoc = glGetUniformLocation(programSkyBox, "transformation");
glUniformMatrix4fv(transformLoc, 1, GL_FALSE, glm::value_ptr(transformation));
GLint modelLoc = glGetUniformLocation(programSkyBox, "modelMatrix");
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(modelMatrix));
glUniform3f(glGetUniformLocation(programSkyBox, "lightPos"), 0, 0, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
Core::DrawContext(context);
@ -146,23 +161,114 @@ void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
}
void renderPlanets() {
float time = glfwGetTime();
float mercuryOrbitRadius = 1.0f;
float venusOrbitRadius = 2.0f;
float earthOrbitRadius = 5.0f;
float moonOrbitRadius = 0.8f;
float marsOrbitRadius = 8.0f;
float jupiterOrbitRadius = 10.0f;
float saturnOrbitRadius = 11.0f;
float uranusOrbitRadius = 12.5f;
float neptuneOrbitRadius = 13.0f;
// im mniejsze tym szybciej
float mercuryRotationSpeed = 1.0f / 10;
float venusRotationSpeed = 1.0f / 7;
float earthRotationSpeed = 1.0f / 5;
float moonRotationSpeed = 1.0f / 0.5;
float marsRotationSpeed = 1.0f / 4;
float jupiterRotationSpeed = 1.0f / 6.5;
float saturnRotationSpeed = 1.0f / 4;
float uranusRotationSpeed = 1.0f / 8;
float neptuneRotationSpeed = 1.0f / 8.5;
float mercuryScale = 0.11f;
float venusScale = 0.14f;
float earthScale = 0.3f;
float moonScale = 0.09f;
float marsScale = 0.2f;
float jupiterScale = 0.7f;
float saturnScale = 0.5f;
float uranusScale = 0.3f;
float neptuneScale = 0.32f;
//mercury
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * mercuryRotationSpeed) * glm::translate(glm::vec3(mercuryOrbitRadius, 0, 0)) * glm::scale(glm::vec3(mercuryScale)),
texture::mercury,
texture::mercuryNormal);
//venus
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * venusRotationSpeed) * glm::translate(glm::vec3(venusOrbitRadius, 0, 0)) * glm::scale(glm::vec3(venusScale)),
texture::venus,
texture::venusNormal);
//earth
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::scale(glm::vec3(earthScale)),
texture::earth,
texture::earthNormal);
//earths moon
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::eulerAngleY(time * moonRotationSpeed) * glm::translate(glm::vec3(moonOrbitRadius, 0, 0)) * glm::scale(glm::vec3(moonScale)),
texture::moon,
texture::asteroidNormal);
//mars
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * marsRotationSpeed) * glm::translate(glm::vec3(marsOrbitRadius, 0, 0)) * glm::scale(glm::vec3(marsScale)),
texture::mars,
texture::marsNormal);
//jupiter
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * jupiterRotationSpeed) * glm::translate(glm::vec3(jupiterOrbitRadius, 0, 0)) * glm::scale(glm::vec3(jupiterScale)),
texture::jupiter,
texture::jupiterNormal);
//saturn
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * saturnRotationSpeed) * glm::translate(glm::vec3(saturnOrbitRadius, 0, 0)) * glm::scale(glm::vec3(saturnScale)),
texture::saturn,
texture::saturnNormal);
//uranus
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * uranusRotationSpeed) * glm::translate(glm::vec3(uranusOrbitRadius, 0, 0)) * glm::scale(glm::vec3(uranusScale)),
texture::uranus,
texture::uranusNormal);
//neptune
drawObjectTexture(sphereContext,
glm::eulerAngleY(time * neptuneRotationSpeed) * glm::translate(glm::vec3(neptuneOrbitRadius, 0, 0)) * glm::scale(glm::vec3(neptuneScale)),
texture::neptune,
texture::neptuneNormal);
}
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 transformation;
float time = glfwGetTime();
//skybox
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
//sun
drawSun(sphereContext, glm::mat4(), texture::sun);
//rendering all the planets
renderPlanets();
drawObjectTexture(sphereContext, glm::mat4(), texture::ship, texture::asteroidNormal);
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), texture::earth, texture::earthNormal);
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::asteroidNormal);
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));
@ -173,7 +279,7 @@ void renderScene(GLFWwindow* window)
0.,0.,0.,1.,
});
//spaceship drawing
drawObjectTexture(shipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
texture::ship, texture::shipNormal
@ -217,16 +323,28 @@ void init(GLFWwindow* window)
loadModelToContext("./models/spaceship.obj", shipContext);
loadModelToContext("./models/cube.obj", cubeContext);
texture::mercury = Core::LoadTexture("textures/mercury/mercury.jpg");
texture::venus = Core::LoadTexture("textures/venus/venus.jpg");
texture::earth = Core::LoadTexture("textures/earth/earth.png");
texture::ship = Core::LoadTexture("textures/spaceship/spaceship.jpg");
texture::moon = Core::LoadTexture("textures/earths_moon/moon.jpg");
texture::sun = Core::LoadTexture("textures/sun/sun.jpg");
texture::mars = Core::LoadTexture("textures/mars/mars.jpg");
texture::jupiter = Core::LoadTexture("textures/jupiter/jupiter.jpg");
texture::saturn = Core::LoadTexture("textures/saturn/saturn.jpg");
texture::uranus = Core::LoadTexture("textures/uranus/uranus.jpg");
texture::neptune = Core::LoadTexture("textures/neptune/neptune.jpg");
texture::earth = Core::LoadTexture("textures/earth2.png");
texture::ship = Core::LoadTexture("textures/spaceship.jpg");
texture::moon = Core::LoadTexture("textures/moon.jpg");
texture::sun = Core::LoadTexture("textures/sun.jpg");
texture::mars = Core::LoadTexture("textures/mars.jpg");
texture::earthNormal = Core::LoadTexture("textures/earth2_normals.png");
texture::shipNormal = Core::LoadTexture("textures/spaceship_normal.jpg");
texture::asteroidNormal = Core::LoadTexture("textures/moon_normal.jpg");
texture::mercuryNormal = Core::LoadTexture("textures/mercury/mercury_normal.png");
texture::venusNormal = Core::LoadTexture("textures/venus/venus_normal.png");
texture::earthNormal = Core::LoadTexture("textures/earth/earth_normal.png");
texture::shipNormal = Core::LoadTexture("textures/spaceship/spaceship_normal.jpg");
texture::asteroidNormal = Core::LoadTexture("textures/earths_moon/moon_normal.jpg");
texture::marsNormal = Core::LoadTexture("textures/mars/mars_normal.jpg");
texture::jupiterNormal = Core::LoadTexture("textures/jupiter/jupiter_normal.png");
texture::saturnNormal = Core::LoadTexture("textures/saturn/saturn_normal.png");
texture::uranusNormal = Core::LoadTexture("textures/uranus/uranus_normal.png");
texture::neptuneNormal = Core::LoadTexture("textures/neptune/neptune_normal.png");
//tutaj skybox start
@ -312,4 +430,3 @@ void renderLoop(GLFWwindow* window) {
glfwPollEvents();
}
}
//}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 4.4 MiB

After

Width:  |  Height:  |  Size: 4.4 MiB

View File

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 374 KiB

After

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 3.3 MiB

After

Width:  |  Height:  |  Size: 3.3 MiB

View File

Before

Width:  |  Height:  |  Size: 803 KiB

After

Width:  |  Height:  |  Size: 803 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB