History

Add default skybox

Ryan Huffman committed 10 years ago

Commit 35ea9901 parent 55c690d2 files · +31 −2Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+31−1
@@ -164,6 +164,13 @@ extern "C" { · 163 unmodified lines
164164 }
165165 #endif
166166
167+#include <procedural/ProceduralSkybox.h>
168+#include <model/Skybox.h>
169+
170+static model::Skybox* skybox{ new ProceduralSkybox() } ;
171+static NetworkTexturePointer skyboxTexture;
172+static bool skyboxTextureLoaded = false;
173+
167174 using namespace std;
168175
169176 static QTimer locationUpdateTimer;
@@ -1212,6 +1219,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 1042 unmodified lines
12121219 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
12131220 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
12141221
1222+ auto textureCache = DependencyManager::get<TextureCache>();
1223+ skyboxTexture = textureCache->getTexture(QUrl("https://hifi-public.s3.amazonaws.com/images/SkyboxTextures/FullMoon1024Compressed.jpg"), NetworkTexture::CUBE_TEXTURE);
1224+
12151225 // After all of the constructor is completed, then set firstRun to false.
12161226 Setting::Handle<bool> firstRun{ Settings::firstRun, true };
12171227 firstRun.set(false);
@@ -4241,6 +4251,7 @@ namespace render { · 3023 unmodified lines
42414251
42424252 // Fall through: if no skybox is available, render the SKY_DOME
42434253 case model::SunSkyStage::SKY_DOME: {
4254+ /*
42444255 if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
42454256 PerformanceTimer perfTimer("stars");
42464257 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -4250,6 +4261,25 @@ namespace render { · 3 unmodified lines
42504261 static const float alpha = 1.0f;
42514262 background->_stars.render(args, alpha);
42524263 }
4264+ */
4265+
4266+ if (!skyboxTextureLoaded && skyboxTexture && skyboxTexture->isLoaded()) {
4267+ skybox->setColor({ 1.0, 1.0, 1.0 });
4268+ skyboxTextureLoaded = true;
4269+ auto texture = skyboxTexture->getGPUTexture();
4270+ if (texture) {
4271+ skybox->setCubemap(texture);
4272+ auto scene = DependencyManager::get<SceneScriptingInterface>()->getStage();
4273+ auto sceneKeyLight = scene->getKeyLight();
4274+ sceneKeyLight->setAmbientSphere(texture->getIrradiance());
4275+ sceneKeyLight->setAmbientMap(texture);
4276+ } else {
4277+ skybox->setCubemap(nullptr);
4278+ }
4279+ }
4280+ if (skyboxTextureLoaded) {
4281+ skybox->render(batch, args->getViewFrustum());
4282+ }
42534283 }
42544284 break;
42554285
@@ -4443,7 +4473,6 @@ void Application::updateWindowTitle() const { · 187 unmodified lines
44434473 #endif
44444474 _window->setWindowTitle(title);
44454475 }
4446−
44474476 void Application::clearDomainOctreeDetails() {
44484477
44494478 // if we're about to quit, we really don't need to do any of these things...
@@ -4469,6 +4498,7 @@ void Application::clearDomainOctreeDetails() { · 19 unmodified lines
44694498 getEntities()->clear();
44704499
44714500 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
4501+
44724502 skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);
44734503
44744504 _recentlyClearedDomain = true;