/** * @file llpaneleditsky.cpp * @brief Floaters to create and edit fixed settings for sky and water. * * $LicenseInfo:firstyear=2011&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2011, Linden Research, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "llviewerprecompiledheaders.h" #include "llpaneleditsky.h" #include "llslider.h" #include "llsliderctrl.h" #include "lltexturectrl.h" #include "llcolorswatch.h" #include "llvirtualtrackball.h" #include "llsettingssky.h" namespace { // Atmosphere Tab const std::string FIELD_SKY_AMBIENT_LIGHT("ambient_light"); const std::string FIELD_SKY_BLUE_HORIZON("blue_horizon"); const std::string FIELD_SKY_BLUE_DENSITY("blue_density"); const std::string FIELD_SKY_HAZE_HORIZON("haze_horizon"); const std::string FIELD_SKY_HAZE_DENSITY("haze_density"); const std::string FIELD_SKY_SCENE_GAMMA("scene_gamma"); const std::string FIELD_SKY_DENSITY_MULTIP("density_multip"); const std::string FIELD_SKY_DISTANCE_MULTIP("distance_multip"); const std::string FIELD_SKY_MAX_ALT("max_alt"); const std::string FIELD_SKY_CLOUD_COLOR("cloud_color"); const std::string FIELD_SKY_CLOUD_COVERAGE("cloud_coverage"); const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale"); const std::string FIELD_SKY_CLOUD_SCROLL_XY("cloud_scroll_xy"); const std::string FIELD_SKY_CLOUD_MAP("cloud_map"); const std::string FIELD_SKY_CLOUD_DENSITY_X("cloud_density_x"); const std::string FIELD_SKY_CLOUD_DENSITY_Y("cloud_density_y"); const std::string FIELD_SKY_CLOUD_DENSITY_D("cloud_density_d"); const std::string FIELD_SKY_CLOUD_DETAIL_X("cloud_detail_x"); const std::string FIELD_SKY_CLOUD_DETAIL_Y("cloud_detail_y"); const std::string FIELD_SKY_CLOUD_DETAIL_D("cloud_detail_d"); const std::string FIELD_SKY_SUN_MOON_COLOR("sun_moon_color"); const std::string FIELD_SKY_GLOW_FOCUS("glow_focus"); const std::string FIELD_SKY_GLOW_SIZE("glow_size"); const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness"); const std::string FIELD_SKY_SUN_ROTATION("sun_rotation"); const std::string FIELD_SKY_SUN_IMAGE("sun_image"); const std::string FIELD_SKY_SUN_SCALE("sun_scale"); const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); const std::string FIELD_SKY_MOON_IMAGE("moon_image"); const std::string FIELD_SKY_MOON_SCALE("moon_scale"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL("rayleigh_exponential"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE("rayleigh_exponential_scale"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_LINEAR("rayleigh_linear"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT("rayleigh_constant"); const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL("mie_exponential"); const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE("mie_exponential_scale"); const std::string FIELD_SKY_DENSITY_MIE_LINEAR("mie_linear"); const std::string FIELD_SKY_DENSITY_MIE_CONSTANT("mie_constant"); const std::string FIELD_SKY_DENSITY_MIE_ANISO("mie_aniso_factor"); const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL("absorption_exponential"); const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE("absorption_exponential_scale"); const std::string FIELD_SKY_DENSITY_ABSORPTION_LINEAR("absorption_linear"); const std::string FIELD_SKY_DENSITY_ABSORPTION_CONSTANT("absorption_constant"); const std::string FIELD_SKY_DENSITY_MAX_ALTITUDE("max_altitude"); const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); const F32 SLIDER_SCALE_GLOW_R(20.0f); const F32 SLIDER_SCALE_GLOW_B(-5.0f); const LLVector2 CLOUD_SCROLL_ADJUST(10, 10); } static LLPanelInjector t_settings_atmos("panel_settings_atmos"); static LLPanelInjector t_settings_cloud("panel_settings_cloud"); static LLPanelInjector t_settings_sunmoon("panel_settings_sunmoon"); static LLPanelInjector t_settings_density("panel_settings_density"); //========================================================================== LLPanelSettingsSky::LLPanelSettingsSky() : LLSettingsEditPanel(), mSkySettings() { } //========================================================================== LLPanelSettingsSkyAtmosTab::LLPanelSettingsSkyAtmosTab() : LLPanelSettingsSky() { } BOOL LLPanelSettingsSkyAtmosTab::postBuild() { getChild(FIELD_SKY_AMBIENT_LIGHT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAmbientLightChanged(); }); getChild(FIELD_SKY_BLUE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueHorizonChanged(); }); getChild(FIELD_SKY_BLUE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueDensityChanged(); }); getChild(FIELD_SKY_HAZE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeHorizonChanged(); }); getChild(FIELD_SKY_HAZE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeDensityChanged(); }); getChild(FIELD_SKY_SCENE_GAMMA)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSceneGammaChanged(); }); getChild(FIELD_SKY_DENSITY_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDensityMultipChanged(); }); getChild(FIELD_SKY_DISTANCE_MULTIP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDistanceMultipChanged(); }); getChild(FIELD_SKY_MAX_ALT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltChanged(); }); refresh(); return TRUE; } //virtual void LLPanelSettingsSkyAtmosTab::setEnabled(BOOL enabled) { LLPanelSettingsSky::setEnabled(enabled); getChild(FIELD_SKY_HAZE_HORIZON)->setEnabled(enabled); getChild(FIELD_SKY_HAZE_DENSITY)->setEnabled(enabled); getChild(FIELD_SKY_SCENE_GAMMA)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MULTIP)->setEnabled(enabled); getChild(FIELD_SKY_DISTANCE_MULTIP)->setEnabled(enabled); getChild(FIELD_SKY_MAX_ALT)->setEnabled(enabled); } void LLPanelSettingsSkyAtmosTab::refresh() { if (!mSkySettings) { setAllChildrenEnabled(FALSE); setEnabled(FALSE); return; } setEnabled(TRUE); setAllChildrenEnabled(TRUE); getChild(FIELD_SKY_AMBIENT_LIGHT)->set(mSkySettings->getAmbientColor() / SLIDER_SCALE_SUN_AMBIENT); getChild(FIELD_SKY_BLUE_HORIZON)->set(mSkySettings->getBlueHorizon() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); getChild(FIELD_SKY_BLUE_DENSITY)->set(mSkySettings->getBlueDensity() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); getChild(FIELD_SKY_HAZE_HORIZON)->setValue(mSkySettings->getHazeHorizon()); getChild(FIELD_SKY_HAZE_DENSITY)->setValue(mSkySettings->getHazeDensity()); getChild(FIELD_SKY_SCENE_GAMMA)->setValue(mSkySettings->getGamma()); getChild(FIELD_SKY_DENSITY_MULTIP)->setValue(mSkySettings->getDensityMultiplier()); getChild(FIELD_SKY_DISTANCE_MULTIP)->setValue(mSkySettings->getDistanceMultiplier()); getChild(FIELD_SKY_MAX_ALT)->setValue(mSkySettings->getMaxY()); } //------------------------------------------------------------------------- void LLPanelSettingsSkyAtmosTab::onAmbientLightChanged() { mSkySettings->setAmbientColor(LLColor3(getChild(FIELD_SKY_AMBIENT_LIGHT)->get() * SLIDER_SCALE_SUN_AMBIENT)); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onBlueHorizonChanged() { mSkySettings->setBlueHorizon(LLColor3(getChild(FIELD_SKY_BLUE_HORIZON)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onBlueDensityChanged() { mSkySettings->setBlueDensity(LLColor3(getChild(FIELD_SKY_BLUE_DENSITY)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onHazeHorizonChanged() { mSkySettings->setHazeHorizon(getChild(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onHazeDensityChanged() { mSkySettings->setHazeDensity(getChild(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onSceneGammaChanged() { mSkySettings->setGamma(getChild(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onDensityMultipChanged() { mSkySettings->setDensityMultiplier(getChild(FIELD_SKY_DENSITY_MULTIP)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onDistanceMultipChanged() { mSkySettings->setDistanceMultiplier(getChild(FIELD_SKY_DISTANCE_MULTIP)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyAtmosTab::onMaxAltChanged() { mSkySettings->setMaxY(getChild(FIELD_SKY_MAX_ALT)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } //========================================================================== LLPanelSettingsSkyCloudTab::LLPanelSettingsSkyCloudTab() : LLPanelSettingsSky() { } BOOL LLPanelSettingsSkyCloudTab::postBuild() { getChild(FIELD_SKY_CLOUD_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudColorChanged(); }); getChild(FIELD_SKY_CLOUD_COVERAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudCoverageChanged(); }); getChild(FIELD_SKY_CLOUD_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScaleChanged(); }); getChild(FIELD_SKY_CLOUD_SCROLL_XY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScrollChanged(); }); getChild(FIELD_SKY_CLOUD_MAP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudMapChanged(); }); getChild(FIELD_SKY_CLOUD_MAP)->setDefaultImageAssetID(LLSettingsSky::GetDefaultCloudNoiseTextureId()); getChild(FIELD_SKY_CLOUD_MAP)->setAllowNoTexture(TRUE); getChild(FIELD_SKY_CLOUD_MAP)->setAllowLocalTexture(FALSE); getChild(FIELD_SKY_CLOUD_DENSITY_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); getChild(FIELD_SKY_CLOUD_DENSITY_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); getChild(FIELD_SKY_CLOUD_DENSITY_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDensityChanged(); }); getChild(FIELD_SKY_CLOUD_DETAIL_X)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); getChild(FIELD_SKY_CLOUD_DETAIL_Y)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); getChild(FIELD_SKY_CLOUD_DETAIL_D)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudDetailChanged(); }); refresh(); return TRUE; } //virtual void LLPanelSettingsSkyCloudTab::setEnabled(BOOL enabled) { LLPanelSettingsSky::setEnabled(enabled); getChild(FIELD_SKY_CLOUD_COVERAGE)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DENSITY_X)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DENSITY_Y)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DENSITY_D)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DETAIL_X)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DETAIL_Y)->setEnabled(enabled); getChild(FIELD_SKY_CLOUD_DETAIL_D)->setEnabled(enabled); } void LLPanelSettingsSkyCloudTab::refresh() { if (!mSkySettings) { setAllChildrenEnabled(FALSE); setEnabled(FALSE); return; } setEnabled(TRUE); setAllChildrenEnabled(TRUE); getChild(FIELD_SKY_CLOUD_COLOR)->set(mSkySettings->getCloudColor()); getChild(FIELD_SKY_CLOUD_COVERAGE)->setValue(mSkySettings->getCloudShadow()); getChild(FIELD_SKY_CLOUD_SCALE)->setValue(mSkySettings->getCloudScale()); LLVector2 cloudScroll(mSkySettings->getCloudScrollRate()); cloudScroll -= CLOUD_SCROLL_ADJUST; getChild(FIELD_SKY_CLOUD_SCROLL_XY)->setValue(cloudScroll.getValue()); getChild(FIELD_SKY_CLOUD_MAP)->setValue(mSkySettings->getCloudNoiseTextureId()); LLVector3 cloudDensity(mSkySettings->getCloudPosDensity1().getValue()); getChild(FIELD_SKY_CLOUD_DENSITY_X)->setValue(cloudDensity[0]); getChild(FIELD_SKY_CLOUD_DENSITY_Y)->setValue(cloudDensity[1]); getChild(FIELD_SKY_CLOUD_DENSITY_D)->setValue(cloudDensity[2]); LLVector3 cloudDetail(mSkySettings->getCloudPosDensity1().getValue()); getChild(FIELD_SKY_CLOUD_DETAIL_X)->setValue(cloudDetail[0]); getChild(FIELD_SKY_CLOUD_DETAIL_Y)->setValue(cloudDetail[1]); getChild(FIELD_SKY_CLOUD_DETAIL_D)->setValue(cloudDetail[2]); } //------------------------------------------------------------------------- void LLPanelSettingsSkyCloudTab::onCloudColorChanged() { mSkySettings->setCloudColor(LLColor3(getChild(FIELD_SKY_CLOUD_COLOR)->get())); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudCoverageChanged() { mSkySettings->setCloudShadow(getChild(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudScaleChanged() { mSkySettings->setCloudScale(getChild(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudScrollChanged() { LLVector2 scroll(getChild(FIELD_SKY_CLOUD_SCROLL_XY)->getValue()); scroll += CLOUD_SCROLL_ADJUST; mSkySettings->setCloudScrollRate(scroll); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudMapChanged() { mSkySettings->setCloudNoiseTextureId(getChild(FIELD_SKY_CLOUD_MAP)->getValue().asUUID()); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudDensityChanged() { LLColor3 density(getChild(FIELD_SKY_CLOUD_DENSITY_X)->getValue().asReal(), getChild(FIELD_SKY_CLOUD_DENSITY_Y)->getValue().asReal(), getChild(FIELD_SKY_CLOUD_DENSITY_D)->getValue().asReal()); mSkySettings->setCloudPosDensity1(density); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudDetailChanged() { LLColor3 detail(getChild(FIELD_SKY_CLOUD_DETAIL_X)->getValue().asReal(), getChild(FIELD_SKY_CLOUD_DETAIL_Y)->getValue().asReal(), getChild(FIELD_SKY_CLOUD_DETAIL_D)->getValue().asReal()); mSkySettings->setCloudPosDensity2(detail); setIsDirty(); } //========================================================================== LLPanelSettingsSkySunMoonTab::LLPanelSettingsSkySunMoonTab() : LLPanelSettingsSky() { } BOOL LLPanelSettingsSkySunMoonTab::postBuild() { getChild(FIELD_SKY_SUN_MOON_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunMoonColorChanged(); }); getChild(FIELD_SKY_GLOW_FOCUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); getChild(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); getChild(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); }); getChild(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); }); getChild(FIELD_SKY_SUN_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); }); getChild(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); }); getChild(FIELD_SKY_SUN_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId()); getChild(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetBlankSunTextureId()); getChild(FIELD_SKY_SUN_IMAGE)->setAllowNoTexture(TRUE); getChild(FIELD_SKY_SUN_IMAGE)->setAllowLocalTexture(FALSE); getChild(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); getChild(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); }); getChild(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetDefaultMoonTextureId()); getChild(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId()); getChild(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE); getChild(FIELD_SKY_MOON_IMAGE)->setAllowLocalTexture(FALSE); getChild(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); }); refresh(); return TRUE; } //virtual void LLPanelSettingsSkySunMoonTab::setEnabled(BOOL enabled) { LLPanelSettingsSky::setEnabled(enabled); getChild(FIELD_SKY_GLOW_FOCUS)->setEnabled(enabled); getChild(FIELD_SKY_GLOW_SIZE)->setEnabled(enabled); getChild(FIELD_SKY_STAR_BRIGHTNESS)->setEnabled(enabled); } void LLPanelSettingsSkySunMoonTab::refresh() { if (!mSkySettings) { setAllChildrenEnabled(FALSE); setEnabled(FALSE); return; } setEnabled(TRUE); setAllChildrenEnabled(TRUE); getChild(FIELD_SKY_SUN_MOON_COLOR)->set(mSkySettings->getSunlightColor() / SLIDER_SCALE_SUN_AMBIENT); LLColor3 glow(mSkySettings->getGlow()); getChild(FIELD_SKY_GLOW_SIZE)->setValue(2.0 - (glow.mV[0] / SLIDER_SCALE_GLOW_R)); getChild(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B); getChild(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness()); getChild(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation()); getChild(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId()); getChild(FIELD_SKY_SUN_SCALE)->setValue(mSkySettings->getSunScale()); getChild(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation()); getChild(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId()); getChild(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale()); } //------------------------------------------------------------------------- void LLPanelSettingsSkySunMoonTab::onSunMoonColorChanged() { LLColor3 color(getChild(FIELD_SKY_SUN_MOON_COLOR)->get()); color *= SLIDER_SCALE_SUN_AMBIENT; mSkySettings->setSunlightColor(color); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onGlowChanged() { LLColor3 glow(getChild(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, getChild(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); glow.mV[0] = (2.0f - glow.mV[0]) * SLIDER_SCALE_GLOW_R; glow.mV[2] *= SLIDER_SCALE_GLOW_B; mSkySettings->setGlow(glow); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() { mSkySettings->setStarBrightness(getChild(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() { mSkySettings->setSunRotation(getChild(FIELD_SKY_SUN_ROTATION)->getRotation()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onSunScaleChanged() { mSkySettings->setSunScale((getChild(FIELD_SKY_SUN_SCALE)->getValue().asReal())); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onSunImageChanged() { mSkySettings->setSunTextureId(getChild(FIELD_SKY_SUN_IMAGE)->getValue().asUUID()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() { mSkySettings->setMoonRotation(getChild(FIELD_SKY_MOON_ROTATION)->getRotation()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() { mSkySettings->setMoonTextureId(getChild(FIELD_SKY_MOON_IMAGE)->getValue().asUUID()); mSkySettings->update(); setIsDirty(); } void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() { mSkySettings->setMoonScale((getChild(FIELD_SKY_MOON_SCALE)->getValue().asReal())); mSkySettings->update(); setIsDirty(); } LLPanelSettingsDensityTab::LLPanelSettingsDensityTab() { } BOOL LLPanelSettingsDensityTab::postBuild() { getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighLinearChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighConstantChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieLinearChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieConstantChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieAnisoFactorChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionLinearChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionConstantChanged(); }); getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltitudeChanged(); }); refresh(); return TRUE; } void LLPanelSettingsDensityTab::setEnabled(BOOL enabled) { LLPanelSettingsSky::setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setEnabled(enabled); } void LLPanelSettingsDensityTab::refresh() { if (!mSkySettings) { setAllChildrenEnabled(FALSE); setEnabled(FALSE); return; } setEnabled(TRUE); setAllChildrenEnabled(TRUE); LLSD rayleigh_config = mSkySettings->getRayleighConfigs(); LLSD mie_config = mSkySettings->getMieConfigs(); LLSD absorption_config = mSkySettings->getAbsorptionConfigs(); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setValue(mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR]); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH]); } void LLPanelSettingsDensityTab::updateProfile() { F32 rayleigh_exponential_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->getValueF32(); F32 rayleigh_exponential_scale = getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->getValueF32(); F32 rayleigh_linear_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->getValueF32(); F32 rayleigh_constant_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->getValueF32(); F32 mie_exponential_term = getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->getValueF32(); F32 mie_exponential_scale = getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->getValueF32(); F32 mie_linear_term = getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->getValueF32(); F32 mie_constant_term = getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->getValueF32(); F32 mie_aniso_factor = getChild(FIELD_SKY_DENSITY_MIE_ANISO)->getValueF32(); F32 absorption_exponential_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->getValueF32(); F32 absorption_exponential_scale = getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->getValueF32(); F32 absorption_linear_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->getValueF32(); F32 absorption_constant_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->getValueF32(); F32 max_alt = getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->getValueF32(); LLSD rayleigh_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, rayleigh_exponential_term, rayleigh_exponential_scale, rayleigh_linear_term, rayleigh_constant_term); LLSD mie_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, mie_exponential_term, mie_exponential_scale, mie_linear_term, mie_constant_term, mie_aniso_factor); LLSD absorption_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, absorption_exponential_term, absorption_exponential_scale, absorption_linear_term, absorption_constant_term); mSkySettings->setRayleighConfigs(rayleigh_config); mSkySettings->setMieConfigs(mie_config); mSkySettings->setAbsorptionConfigs(absorption_config); mSkySettings->update(); } void LLPanelSettingsDensityTab::onRayleighExponentialChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onRayleighExponentialScaleChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onRayleighLinearChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onRayleighConstantChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMieExponentialChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMieExponentialScaleChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMieLinearChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMieConstantChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMieAnisoFactorChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onAbsorptionExponentialChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onAbsorptionExponentialScaleChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onAbsorptionLinearChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onAbsorptionConstantChanged() { updateProfile(); } void LLPanelSettingsDensityTab::onMaxAltitudeChanged() { updateProfile(); }