Commit 3e95f4ba authored by Dario Seyb's avatar Dario Seyb

fixed in cockpit camera rotation

parent c8e178d1
......@@ -81,6 +81,10 @@ public:
m_hasControl = val;
}
glm::dmat4 getShipRotation() {
return directionRot;
}
glm::dmat4 getRotation() {
return cameraTransform->rotation;
}
......
......@@ -472,52 +472,18 @@ void PlayerSystem::update(float dt) {
glm::dmat4 oldDir = directionRot;
directionRot = directionRot * yprMatrix;
cameraTransform->rotation = cameraTransform->rotation * yprMatrix;
//cameraTransform->rotation = cameraTransform->rotation * yprMatrix ;
//skyboxCamTransform->rotation = skyboxCamTransform->rotation * yprMatrix;
auto dir = normalize( rotate(glm::dvec3(0, 0, -1), directionRot));
cameraTransform->position += glm::normalize(glm::vec3(dir)) * static_cast<double>(dt) * velocity;
/*
auto up = rotate(glm::dvec3(0, 1, 0), glm::inverse(cockpitCamTransform->rotation));
cockpitCamTransform->rotation = glm::rotate(cockpitCamTransform->rotation, mouseMove.x * 0.001, up);
cockpitCamTransform->rotation = glm::rotate(cockpitCamTransform->rotation, mouseMove.y * 0.001, glm::dvec3(1, 0, 0));
glm::dmat4 diff = cockpitCamTransform->rotation * glm::transpose(oldDir);
//cameraTransform->rotation = cameraTransform->rotation * yprMatrix;
cameraTransform->rotation = diff * directionRot;
*/
//cameraTransform->rotation = glm::rotate(cameraTransform->rotation, mouseMove.x * 0.001, up);
//cameraTransform->rotation = glm::rotate(cameraTransform->rotation, mouseMove.y * 0.001, glm::dvec3(1, 0, 0));
cameraTransform->rotation = directionRot * cockpitCamTransform->rotation;
mouseMove = glm::vec2(0, 0);
// Roll first
//auto dir = normalize(directionRot * glm::vec4{ 0, 0, -1, 0 });
//cameraTransform->position += glm::normalize(glm::vec3(dir)) * static_cast<double>(dt) * velocity;
//cameraTransform->rotation = glm::rotate(cameraTransform->rotation, rollDir * 0.01, glm::dvec3(0, 0, 1));
//auto up = rotate(glm::dvec3(0, 1, 0), glm::inverse(cameraTransform->rotation));
//auto directionUp = rotate(glm::dvec3(0, 1, 0), glm::inverse(directionRot));
//directionUp = glm::dvec3(normalize(cameraTransform->rotation * glm::vec4{ 0, 1, 0, 0 }));
//cameraTransform->rotation = glm::rotate(cameraTransform->rotation, rotDir.x * 0.01, up);
//cameraTransform->rotation = glm::rotate(cameraTransform->rotation, rotDir.y * 0.01, glm::dvec3(1, 0, 0));
//skyboxCamTransform->rotation = cameraTransform->rotation;
//directionRot = glm::rotate(directionRot, rotDir.x * 0.01, directionUp);
//directionRot = glm::rotate(directionRot, rotDir.y * 0.01, glm::dvec3(1, 0, 0));
}
}
......
......@@ -136,7 +136,7 @@ bool AtmosphereTestScene::startup() {
sunLight->dir = -glm::normalize(m_player->getWorldPosition());
cockpitSunLight->dir =
glm::vec3(glm::dvec4(sunLight->dir, 0) * m_player->getRotation());
glm::vec3(glm::dvec4(sunLight->dir, 0) * m_player->getShipRotation());
if (isFocusedOnConsole) {
if (m_console.update(e, m_player->getKeyTable())) {
......@@ -245,7 +245,7 @@ void AtmosphereTestScene::switchToMainScene() {
sun.assign<Drawable>(sunGeometry, sunMaterial, 0, m_renderer->getRenderPassId("Main"_sh));
float scale = m_orbitals->solarRadius * m_orbitals->scaleFactor * 0.1;
sunTransform->scale = glm::dvec3(scale);
sunLight = sun.assign<Light>(glm::vec4(1, 1, 1, 3), glm::vec3(1, 0, 0),
sunLight = sun.assign<Light>(glm::vec4(1, 1, 1, 1.5), glm::vec3(1, 0, 0),
false, LightType::DIRECTIONAL, m_renderer->getRenderPassId("Main"_sh));
// Let's create a placeholder sun
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment