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
164}164}
165#endif165#endif
166 166
167#include <procedural/ProceduralSkybox.h>
168#include <model/Skybox.h>
169
170static model::Skybox* skybox{ new ProceduralSkybox() } ;
171static NetworkTexturePointer skyboxTexture;
172static bool skyboxTextureLoaded = false;
173
167using namespace std;174using namespace std;
168 175
169static QTimer locationUpdateTimer;176static QTimer locationUpdateTimer;
@@ -1212,6 +1219,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 1042 unmodified lines
1212 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);1219 connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
1213 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);1220 qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
1214 1221
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
1215 // After all of the constructor is completed, then set firstRun to false.1225 // After all of the constructor is completed, then set firstRun to false.
1216 Setting::Handle<bool> firstRun{ Settings::firstRun, true };1226 Setting::Handle<bool> firstRun{ Settings::firstRun, true };
1217 firstRun.set(false);1227 firstRun.set(false);
@@ -4241,6 +4251,7 @@ namespace render { · 3023 unmodified lines
4241 4251
4242 // Fall through: if no skybox is available, render the SKY_DOME4252 // Fall through: if no skybox is available, render the SKY_DOME
4243 case model::SunSkyStage::SKY_DOME: {4253 case model::SunSkyStage::SKY_DOME: {
4254 /*
4244 if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {4255 if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
4245 PerformanceTimer perfTimer("stars");4256 PerformanceTimer perfTimer("stars");
4246 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),4257 PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
@@ -4250,6 +4261,25 @@ namespace render { · 3 unmodified lines
4250 static const float alpha = 1.0f;4261 static const float alpha = 1.0f;
4251 background->_stars.render(args, alpha);4262 background->_stars.render(args, alpha);
4252 }4263 }
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 }
4253 }4283 }
4254 break;4284 break;
4255 4285
@@ -4443,7 +4473,6 @@ void Application::updateWindowTitle() const { · 187 unmodified lines
4443#endif4473#endif
4444 _window->setWindowTitle(title);4474 _window->setWindowTitle(title);
4445}4475}
4446
4447void Application::clearDomainOctreeDetails() {4476void Application::clearDomainOctreeDetails() {
4448 4477
4449 // if we're about to quit, we really don't need to do any of these things...4478 // 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
4469 getEntities()->clear();4498 getEntities()->clear();
4470 4499
4471 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();4500 auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
4501
4472 skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);4502 skyStage->setBackgroundMode(model::SunSkyStage::SKY_DOME);
4473 4503
4474 _recentlyClearedDomain = true;4504 _recentlyClearedDomain = true;