liczenie odleglosci

This commit is contained in:
Wojciech Łukasik 2021-02-24 15:31:37 +01:00
parent e7a8327011
commit ab149ed378
1 changed files with 15 additions and 8 deletions

View File

@ -40,6 +40,7 @@ GLuint boxTexture, groundTexture, shipTexture, stoneTexture, redTex, yellowTex;
glm::vec3 cameraPos = glm::vec3(-40, 5, 0);
glm::vec3 cameraDir;
glm::vec3 cameraSide;
glm::vec3 stationPos;
float cameraAngle = 0;
glm::mat4 cameraMatrix, perspectiveMatrix;
@ -63,7 +64,7 @@ Core::RenderContext shipContextOrbit, sphereContextOrbit, stationContextOrbit;
float frustumScale = 1.f;
bool loading = false;
bool reload = false;
float orbitSpeed = 0.005f;
float orbitSpeed = 0.003f;
// skybox
std::vector<std::string> faces
@ -416,7 +417,7 @@ void renderScene()
// Update of camera and perspective matrices
cameraMatrix = createCameraMatrix();
perspectiveMatrix = Core::createPerspectiveMatrix(0.1f, 1000.f);
perspectiveMatrix = Core::createPerspectiveMatrix(0.1f, 1500.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.1f, 0.3f, 1.0f);
@ -477,7 +478,8 @@ void renderScene()
lightDir = glm::normalize(glm::vec3(1.0f, -1.0f, -1.0f));
lightPos = glm::vec3(0, 0, -800);
cameraAngle = glm::radians(0.0f);
cameraPos = glm::vec3(0, 0, -250);
cameraPos = glm::vec3(0.f, 0.f, 250.f);
stationPos = glm::vec3(0.f, -0.65f, 245.5f);
appLoadingTime = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
}
}
@ -513,18 +515,23 @@ void renderScene()
//drawObjectTexture(&sphereModelOrbit, glm::translate(glm::vec3(0, 0, 0)) * glm::scale(glm::vec3(20.f)), textureSun);
//STATION
glm::mat4 stationmat = glm::rotate(time / 2.0f, glm::vec3(0, 1, 0)) * glm::translate(glm::vec3(0, -0.7f, 245.5f)) * glm::scale(glm::vec3(0.4)) * glm::rotate(glm::radians(-90.0f), glm::vec3(0, 1, 0));
drawObjectColor(&stationContextOrbit, stationmat, glm::vec3(0.5));
glm::mat4 stationmat = glm::rotate(time / 5.0f, glm::vec3(0, 1, 0)) * glm::translate(stationPos) * glm::scale(glm::vec3(0.4)) * glm::rotate(glm::radians(-90.0f), glm::vec3(0, 1, 0));
drawObjectTexture(&stationContextOrbit, stationmat, shipTexture);
stationmat = perspectiveMatrix * stationmat;
//stationmat = perspectiveMatrix * stationmat;
glm::vec3 stationPos = glm::vec3(stationmat[3][0], stationmat[3][1], stationmat[3][2]);
glm::vec3 dif = stationPos - cameraPos;
float difference = dif.length();
//glm::vec3 dif = stationPos - cameraPos;
//float difference = dif.length();
//if (difference < 5) {
//shutdown();
//}
float distance = sqrt((cameraPos.x - stationPos.x)*(cameraPos.x - stationPos.x) + (cameraPos.z - stationPos.z)* (cameraPos.z - stationPos.z));
std::cout << "distance: " << distance << std::endl;
//std::cout << "cameraPos.x: " << cameraPos.x << "cameraPos.z: " << cameraPos.z <<std::endl;
//std::cout << "stationPos.x: " << stationPos.x << "stationPos.z: " << stationPos.z << std::endl;
//EARTH nieruchoma - <20>atwiejsze dla naszej cutscenki
drawObjectTexture(&sphereContextOrbit, glm::scale(glm::vec3(45)), textureEarthHighres);