summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llvirtualtrackball.cpp15
-rw-r--r--indra/newview/llfloaterenvironmentadjust.cpp113
-rw-r--r--indra/newview/llfloaterenvironmentadjust.h2
-rw-r--r--indra/newview/llpaneleditsky.cpp4
-rw-r--r--indra/newview/skins/default/xui/en/floater_adjust_environment.xml96
5 files changed, 194 insertions, 36 deletions
diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp
index 15847a7282..728e86af08 100644
--- a/indra/llui/llvirtualtrackball.cpp
+++ b/indra/llui/llvirtualtrackball.cpp
@@ -352,7 +352,6 @@ LLQuaternion LLVirtualTrackball::getRotation() const
void LLVirtualTrackball::getAzimuthAndElevation(const LLQuaternion &quat, F32 &azimuth, F32 &elevation)
{
// LLQuaternion has own function to get azimuth, but it doesn't appear to return correct values (meant for 2d?)
- const LLVector3 VectorZero(10000.0f, 0.0f, 0.0f);
LLVector3 point = VectorZero * quat;
if (!is_approx_zero(point.mV[VX]) || !is_approx_zero(point.mV[VY]))
@@ -371,19 +370,7 @@ void LLVirtualTrackball::getAzimuthAndElevation(const LLQuaternion &quat, F32 &a
azimuth += F_PI * 2;
}
- if (abs(point.mV[VY]) > abs(point.mV[VX]) && !is_approx_zero(point.mV[VY])) // to avoid precision drop
- {
- elevation = atanl((F64)point.mV[VZ] / (F64)abs(point.mV[VY]));
- }
- else if (!is_approx_zero(point.mV[VX]))
- {
- elevation = atanl((F64)point.mV[VZ] / (F64)abs(point.mV[VX]));
- }
- else
- {
- // both VX and VY are near zero, VZ should be high
- elevation = point.mV[VZ] > 0 ? F_PI_BY_TWO : -F_PI_BY_TWO;
- }
+ elevation = asin(point.mV[VZ]); // because VectorZero is '1'
}
// static
diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp
index 4eb5e03603..95d6a2d652 100644
--- a/indra/newview/llfloaterenvironmentadjust.cpp
+++ b/indra/newview/llfloaterenvironmentadjust.cpp
@@ -53,11 +53,15 @@ namespace
const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale");
const std::string FIELD_SKY_SCENE_GAMMA("scene_gamma");
const std::string FIELD_SKY_SUN_ROTATION("sun_rotation");
+ const std::string FIELD_SKY_SUN_AZIMUTH("sun_azimuth");
+ const std::string FIELD_SKY_SUN_ELEVATION("sun_elevation");
const std::string FIELD_SKY_SUN_SCALE("sun_scale");
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_MOON_ROTATION("moon_rotation");
+ const std::string FIELD_SKY_MOON_AZIMUTH("moon_azimuth");
+ const std::string FIELD_SKY_MOON_ELEVATION("moon_elevation");
const std::string BTN_RESET("btn_reset");
const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f);
@@ -96,9 +100,13 @@ BOOL LLFloaterEnvironmentAdjust::postBuild()
getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); });
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); });
getChild<LLUICtrl>(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); });
+ getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunAzimElevChanged(); });
+ getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunAzimElevChanged(); });
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); });
getChild<LLUICtrl>(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); });
+ getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonAzimElevChanged(); });
+ getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonAzimElevChanged(); });
getChild<LLUICtrl>(BTN_RESET)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onButtonReset(); });
getChild<LLTextureCtrl>(FIELD_SKY_CLOUD_MAP)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudMapChanged(); });
@@ -169,10 +177,25 @@ void LLFloaterEnvironmentAdjust::refresh()
getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setValue(2.0 - (glow.mV[0] / SLIDER_SCALE_GLOW_R));
getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B);
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mLiveSky->getStarBrightness());
- getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(mLiveSky->getSunRotation());
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setValue(mLiveSky->getSunScale());
- getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mLiveSky->getMoonRotation());
+ // Sun rotation
+ LLQuaternion quat = mLiveSky->getSunRotation();
+ F32 azimuth;
+ F32 elevation;
+ LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
+
+ getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth);
+ getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation);
+ getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(quat);
+
+ // Moon rotation
+ quat = mLiveSky->getMoonRotation();
+ LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
+
+ getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth);
+ getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation);
+ getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(quat);
}
@@ -325,10 +348,45 @@ void LLFloaterEnvironmentAdjust::onStarBrightnessChanged()
void LLFloaterEnvironmentAdjust::onSunRotationChanged()
{
- if (!mLiveSky)
- return;
- mLiveSky->setSunRotation(getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation());
- mLiveSky->update();
+ LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation();
+ F32 azimuth;
+ F32 elevation;
+ LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
+ getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth);
+ getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation);
+ if (mLiveSky)
+ {
+ mLiveSky->setSunRotation(quat);
+ mLiveSky->update();
+ }
+}
+
+void LLFloaterEnvironmentAdjust::onSunAzimElevChanged()
+{
+ F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal();
+ F32 elevation = getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal();
+ LLQuaternion quat;
+
+ azimuth *= DEG_TO_RAD;
+ elevation *= DEG_TO_RAD;
+
+ if (is_approx_zero(elevation))
+ {
+ elevation = F_APPROXIMATELY_ZERO;
+ }
+
+ quat.setAngleAxis(-elevation, 0, 1, 0);
+ LLQuaternion az_quat;
+ az_quat.setAngleAxis(F_TWO_PI - azimuth, 0, 0, 1);
+ quat *= az_quat;
+
+ getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(quat);
+
+ if (mLiveSky)
+ {
+ mLiveSky->setSunRotation(quat);
+ mLiveSky->update();
+ }
}
void LLFloaterEnvironmentAdjust::onSunScaleChanged()
@@ -341,10 +399,45 @@ void LLFloaterEnvironmentAdjust::onSunScaleChanged()
void LLFloaterEnvironmentAdjust::onMoonRotationChanged()
{
- if (!mLiveSky)
- return;
- mLiveSky->setMoonRotation(getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation());
- mLiveSky->update();
+ LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation();
+ F32 azimuth;
+ F32 elevation;
+ LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
+ getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth);
+ getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation);
+ if (mLiveSky)
+ {
+ mLiveSky->setMoonRotation(quat);
+ mLiveSky->update();
+ }
+}
+
+void LLFloaterEnvironmentAdjust::onMoonAzimElevChanged()
+{
+ F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal();
+ F32 elevation = getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal();
+ LLQuaternion quat;
+
+ azimuth *= DEG_TO_RAD;
+ elevation *= DEG_TO_RAD;
+
+ if (is_approx_zero(elevation))
+ {
+ elevation = F_APPROXIMATELY_ZERO;
+ }
+
+ quat.setAngleAxis(-elevation, 0, 1, 0);
+ LLQuaternion az_quat;
+ az_quat.setAngleAxis(F_TWO_PI - azimuth, 0, 0, 1);
+ quat *= az_quat;
+
+ getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(quat);
+
+ if (mLiveSky)
+ {
+ mLiveSky->setMoonRotation(quat);
+ mLiveSky->update();
+ }
}
void LLFloaterEnvironmentAdjust::onCloudMapChanged()
diff --git a/indra/newview/llfloaterenvironmentadjust.h b/indra/newview/llfloaterenvironmentadjust.h
index cb38dbcfa8..05ff011be5 100644
--- a/indra/newview/llfloaterenvironmentadjust.h
+++ b/indra/newview/llfloaterenvironmentadjust.h
@@ -73,9 +73,11 @@ private:
void onGlowChanged();
void onStarBrightnessChanged();
void onSunRotationChanged();
+ void onSunAzimElevChanged();
void onSunScaleChanged();
void onMoonRotationChanged();
+ void onMoonAzimElevChanged();
void onCloudMapChanged();
void onWaterMapChanged();
diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp
index 06e406e2ab..a169712bd8 100644
--- a/indra/newview/llpaneleditsky.cpp
+++ b/indra/newview/llpaneleditsky.cpp
@@ -625,7 +625,7 @@ void LLPanelSettingsSkySunMoonTab::onSunAzimElevChanged()
{
F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal();
F32 elevation = getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal();
- LLQuaternion quat = mSkySettings->getSunRotation();
+ LLQuaternion quat;
azimuth *= DEG_TO_RAD;
elevation *= DEG_TO_RAD;
@@ -687,7 +687,7 @@ void LLPanelSettingsSkySunMoonTab::onMoonAzimElevChanged()
{
F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal();
F32 elevation = getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal();
- LLQuaternion quat = mSkySettings->getMoonRotation();
+ LLQuaternion quat;
azimuth *= DEG_TO_RAD;
elevation *= DEG_TO_RAD;
diff --git a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml
index 59589e3665..f4a686bae1 100644
--- a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml
+++ b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml
@@ -5,14 +5,14 @@
save_rect="false"
title="Personal Lighting"
width="845"
- height="240"
+ height="280"
min_width="500"
- min_height="235"
+ min_height="275"
single_instance="true"
can_resize="false">
<layout_stack name="outer_stack"
width="845"
- height="230"
+ height="275"
follows="all"
animate="false"
top="0"
@@ -276,19 +276,57 @@
height="150"
width="150"
thumb_mode="sun"/>
+ <text follows="left|top"
+ height="10"
+ layout="topleft"
+ left_delta="0"
+ top_pad="5"
+ width="200">Azimuth:</text>
+ <slider decimal_digits="2"
+ follows="left|top"
+ height="16"
+ increment="0.01"
+ initial_value="0"
+ layout="topleft"
+ left_delta="5"
+ min_val="0"
+ max_val="359.99"
+ name="sun_azimuth"
+ top_pad="5"
+ width="130"
+ can_edit_text="true"/>
+ <text follows="left|top"
+ height="10"
+ layout="topleft"
+ left_delta="-5"
+ top_pad="5"
+ width="200">Elevation:</text>
+ <slider decimal_digits="2"
+ follows="left|top"
+ height="16"
+ increment="0.01"
+ initial_value="0"
+ layout="topleft"
+ left_delta="5"
+ min_val="-90"
+ max_val="90"
+ name="sun_elevation"
+ top_pad="5"
+ width="130"
+ can_edit_text="true"/>
<check_box control_name="sunbeacon"
width="60"
height="16"
label="Show Beacon"
layout="topleft"
name="sunbeacon"
- left_delta="55"
- bottom="-20"
- follows="bottom|right"/>
+ left_delta="-5"
+ top_pad="8"
+ follows="left|top"/>
<text follows="left|top"
height="10"
layout="topleft"
- left_pad="40"
+ left_pad="95"
top="25"
width="80">Scale:</text>
<slider decimal_digits="2"
@@ -385,15 +423,53 @@
height="150"
width="150"
thumb_mode="moon"/>
+ <text follows="left|top"
+ height="10"
+ layout="topleft"
+ left_delta="0"
+ top_pad="5"
+ width="200">Azimuth:</text>
+ <slider decimal_digits="2"
+ follows="left|top"
+ height="16"
+ increment="0.01"
+ initial_value="0"
+ layout="topleft"
+ left_delta="5"
+ min_val="0"
+ max_val="359.99"
+ name="moon_azimuth"
+ top_pad="5"
+ width="130"
+ can_edit_text="true"/>
+ <text follows="left|top"
+ height="10"
+ layout="topleft"
+ left_delta="-5"
+ top_pad="5"
+ width="200">Elevation:</text>
+ <slider decimal_digits="2"
+ follows="left|top"
+ height="16"
+ increment="0.01"
+ initial_value="0"
+ layout="topleft"
+ left_delta="5"
+ min_val="-90"
+ max_val="90"
+ name="moon_elevation"
+ top_pad="5"
+ width="130"
+ can_edit_text="true"/>
<check_box control_name="moonbeacon"
+ follows="left|top"
width="60"
height="16"
label="Show Beacon"
layout="topleft"
name="moonbeacon"
- right="-50"
- bottom="-20"
- follows="bottom|right"/>
+ left_delta="0"
+ top_pad="8"/>
</layout_panel>
</layout_stack>
</layout_panel>