Commit 5b464607 authored by Dario Seyb's avatar Dario Seyb

added one more console display

parent 0a4e8759
......@@ -99,6 +99,10 @@ public:
return cockpitCamTransform->position;
}
double getVelocity() {
return velocity;
}
glm::dvec3 getPosition() {
return cameraTransform->position;
......
......@@ -36,12 +36,20 @@ private:
SoundSource::Handle consoleSoundSource;
SoundSource::Handle cockpitSoundSource;
Entity planetViewCam;
Material cockpitMaterial, sunMaterial, skyboxMaterial, windshieldMaterial;
Geometry cockpitGeometry, sunGeometry, skyboxGeometry;
Geometry cockpitGeometry, sunGeometry, skyboxGeometry, planetViewGeom;
Geometry consoleGeom, consoleFrontLeftGeom, consoleFrontRightGeom, consoleBackLeftGeom, consoleBackRightGeom, consoleMiddleLeftGeom, consoleMiddleRightGeom, windShieldGeom;
SharedTexture2D outOfOrderTexture;
SharedShaderProgram defaultPbrProg;
double planetRotationSpeed = 0;
Transform::Handle planetViewTransform;
std::shared_ptr<Sound> soundTrackIntro, soundTrackMain;
bool resourceLoadingFinished = false;
......
......@@ -85,6 +85,12 @@ bool AtmosphereTestScene::startup() {
m_renderer->addRenderPass(consoleCamera, "Console"_sh, ScreenSpaceSize::HALF);
planetViewCam = m_sceneGraph->create();
planetViewCam.assign<Transform>();
planetViewCam.assign<Camera>(50, 0.1, 50);
m_renderer->addRenderPass(planetViewCam, "PlanetView"_sh, ScreenSpaceSize::HALF);
m_renderer->setRenderPassOnlyTexture("PlanetView"_sh, true);
m_console.m_events = m_events;
m_console.m_renderer = m_renderer;
m_console.m_sceneGraph = m_sceneGraph;
......@@ -163,6 +169,14 @@ bool AtmosphereTestScene::startup() {
cockpitSoundSource->setVolume(1);
}
}
double rotationSpeedFactor = (1.0 - exp(-glm::abs(m_player->getVelocity()) * 0.001)) * 3 * glm::sign(m_player->getVelocity());
planetRotationSpeed += rotationSpeedFactor * e.dt;
planetRotationSpeed = glm::sign(planetRotationSpeed) * glm::min(glm::abs(planetRotationSpeed), 3.0);
planetRotationSpeed -= planetRotationSpeed * e.dt * 0.3;
planetViewTransform->rotation = glm::rotate<double>(planetViewTransform->rotation, planetRotationSpeed * e.dt, glm::dvec3{ 0.0, 1.0, 0.0 });
});
m_events->subscribe<KeyboardEvent>([this](const KeyboardEvent &e) {
......@@ -330,7 +344,7 @@ void AtmosphereTestScene::switchToMainScene() {
consoleFrontRight.assign<Drawable>(
consoleFrontRightGeom,
Material{ glm::vec4{ 1, 1, 1, 1 }, glm::vec4{ 1, 1, 1, 1 },
outOfOrderTexture, nullptr, nullptr, nullptr,
m_renderer->getRenderPassTarget("PlanetView"_sh), nullptr, nullptr, nullptr,
skyboxMaterial.prog, true, RenderQueue::OPAQUE, GL_NONE },
0, cockpitPassId);
consoleFrontRight.assign<Transform>();
......@@ -380,11 +394,30 @@ void AtmosphereTestScene::switchToMainScene() {
windShield.assign<Transform>();
}
{
auto planetViewPassId = m_renderer->getRenderPassId("PlanetView"_sh);
auto planetView = m_sceneGraph->create();
planetView.assign<Drawable>(
planetViewGeom,
Material{ glm::vec4{ 1, 1, 1, 1 }, glm::vec4{ 0.3, 1.0, 0.4, 1 },
nullptr, nullptr, nullptr, nullptr,
defaultPbrProg, true, RenderQueue::OPAQUE, GL_NONE },
0, planetViewPassId);
planetViewTransform = planetView.assign<Transform>();
planetViewTransform->position = { 0.0, 0.0, -5.0 };;
planetViewTransform->scale = { 1.5, 1.5, 1.5 };
planetView.assign<Light>(glm::vec4(1, 1, 1, 0.2), glm::vec3(1, 0, 0),
false, LightType::POINT, planetViewPassId);
}
loadingText.component<Drawable>()->visible = false;
loadingText.destroy();
}
void AtmosphereTestScene::loadMainSceneResources() {
auto qualitySetting = m_settings->getQualitySetting();
{
auto vaoSkybox = VertexArrayObjectCreator("skybox.obj").create();
......@@ -393,6 +426,11 @@ void AtmosphereTestScene::loadMainSceneResources() {
.attributeLocations(vaoSkybox->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
defaultPbrProg = ShaderProgramFileManager::the()->get(
ShaderProgramCreator("PBR")
.attributeLocations(vaoSkybox->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
auto skyboxTexName = qualitySetting == QualitySetting::High ? "skybox_large.png" : qualitySetting == QualitySetting::Medium ? "skybox_medium.png" : "skybox.png";
......@@ -481,6 +519,10 @@ void AtmosphereTestScene::loadMainSceneResources() {
}
{
planetViewGeom = Geometry{ VertexArrayObjectCreator("planet_wireframe.obj").create() };
}
resourceLoadingFinished = true;
}
......
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