SL-14725 Rotation sliders for sun and moon panels
parent
5971c647e4
commit
58827cb275
|
|
@ -348,6 +348,52 @@ LLQuaternion LLVirtualTrackball::getRotation() const
|
|||
return mValue;
|
||||
}
|
||||
|
||||
// static
|
||||
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]))
|
||||
{
|
||||
azimuth = atan2f(point.mV[VX], point.mV[VY]);
|
||||
}
|
||||
else
|
||||
{
|
||||
azimuth = 0;
|
||||
}
|
||||
|
||||
azimuth -= F_PI_BY_TWO;
|
||||
|
||||
if (azimuth < 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void LLVirtualTrackball::getAzimuthAndElevationDeg(const LLQuaternion &quat, F32 &azimuth, F32 &elevation)
|
||||
{
|
||||
getAzimuthAndElevation(quat, azimuth, elevation);
|
||||
azimuth *= RAD_TO_DEG;
|
||||
elevation *= RAD_TO_DEG;
|
||||
}
|
||||
|
||||
BOOL LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask)
|
||||
{
|
||||
if (hasMouseCapture())
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ public:
|
|||
void setRotation(const LLQuaternion &value);
|
||||
LLQuaternion getRotation() const;
|
||||
|
||||
static void getAzimuthAndElevation(const LLQuaternion &quat, F32 &azimuth, F32 &elevation);
|
||||
static void getAzimuthAndElevationDeg(const LLQuaternion &quat, F32 &azimuth, F32 &elevation);
|
||||
|
||||
protected:
|
||||
friend class LLUICtrlFactory;
|
||||
LLVirtualTrackball(const Params&);
|
||||
|
|
|
|||
|
|
@ -69,11 +69,15 @@ namespace
|
|||
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_AZIMUTH("sun_azimuth");
|
||||
const std::string FIELD_SKY_SUN_ELEVATION("sun_elevation");
|
||||
const std::string FIELD_SKY_SUN_IMAGE("sun_image");
|
||||
const std::string FIELD_SKY_SUN_SCALE("sun_scale");
|
||||
const std::string FIELD_SKY_SUN_BEACON("sunbeacon");
|
||||
const std::string FIELD_SKY_MOON_BEACON("moonbeacon");
|
||||
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 FIELD_SKY_MOON_IMAGE("moon_image");
|
||||
const std::string FIELD_SKY_MOON_SCALE("moon_scale");
|
||||
const std::string FIELD_SKY_MOON_BRIGHTNESS("moon_brightness");
|
||||
|
|
@ -473,12 +477,16 @@ BOOL LLPanelSettingsSkySunMoonTab::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_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); });
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); });
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId());
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetBlankSunTextureId());
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setAllowNoTexture(TRUE);
|
||||
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>(FIELD_SKY_MOON_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonImageChanged(); });
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetDefaultMoonTextureId());
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetDefaultMoonTextureId());
|
||||
|
|
@ -537,13 +545,29 @@ void LLPanelSettingsSkySunMoonTab::refresh()
|
|||
getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B);
|
||||
|
||||
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness());
|
||||
getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation());
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId());
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setValue(mSkySettings->getSunScale());
|
||||
getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation());
|
||||
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId());
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale());
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setValue(mSkySettings->getMoonBrightness());
|
||||
|
||||
// Sun rotation values
|
||||
F32 azimuth, elevation;
|
||||
LLQuaternion quat = mSkySettings->getSunRotation();
|
||||
LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
|
||||
|
||||
getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(quat);
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth);
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation);
|
||||
|
||||
// Moon rotation values
|
||||
quat = mSkySettings->getMoonRotation();
|
||||
LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
|
||||
|
||||
getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(quat);
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth);
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation);
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
@ -583,10 +607,47 @@ void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged()
|
|||
|
||||
void LLPanelSettingsSkySunMoonTab::onSunRotationChanged()
|
||||
{
|
||||
if (!mSkySettings) return;
|
||||
mSkySettings->setSunRotation(getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation());
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->getRotation();
|
||||
|
||||
F32 azimuth, elevation;
|
||||
LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->setValue(azimuth);
|
||||
getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->setValue(elevation);
|
||||
if (mSkySettings)
|
||||
{
|
||||
mSkySettings->setSunRotation(quat);
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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 (mSkySettings)
|
||||
{
|
||||
mSkySettings->setSunRotation(quat);
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanelSettingsSkySunMoonTab::onSunScaleChanged()
|
||||
|
|
@ -607,10 +668,48 @@ void LLPanelSettingsSkySunMoonTab::onSunImageChanged()
|
|||
|
||||
void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged()
|
||||
{
|
||||
if (!mSkySettings) return;
|
||||
mSkySettings->setMoonRotation(getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation());
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
LLQuaternion quat = getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->getRotation();
|
||||
|
||||
F32 azimuth, elevation;
|
||||
LLVirtualTrackball::getAzimuthAndElevationDeg(quat, azimuth, elevation);
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->setValue(azimuth);
|
||||
getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->setValue(elevation);
|
||||
|
||||
if (mSkySettings)
|
||||
{
|
||||
mSkySettings->setMoonRotation(quat);
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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 (mSkySettings)
|
||||
{
|
||||
mSkySettings->setMoonRotation(quat);
|
||||
mSkySettings->update();
|
||||
setIsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void LLPanelSettingsSkySunMoonTab::onMoonImageChanged()
|
||||
|
|
|
|||
|
|
@ -124,9 +124,11 @@ private:
|
|||
void onGlowChanged();
|
||||
void onStarBrightnessChanged();
|
||||
void onSunRotationChanged();
|
||||
void onSunAzimElevChanged();
|
||||
void onSunScaleChanged();
|
||||
void onSunImageChanged();
|
||||
void onMoonRotationChanged();
|
||||
void onMoonAzimElevChanged();
|
||||
void onMoonScaleChanged();
|
||||
void onMoonBrightnessChanged();
|
||||
void onMoonImageChanged();
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
follows="left|top|right|bottom"
|
||||
auto_resize="false"
|
||||
user_resize="false"
|
||||
height="40"
|
||||
height="35"
|
||||
visible="true">
|
||||
<layout_stack
|
||||
follows="bottom|left|right"
|
||||
|
|
|
|||
|
|
@ -20,14 +20,6 @@
|
|||
function="Favorites.DoToSelected"
|
||||
parameter="about" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Copy SLurl"
|
||||
layout="topleft"
|
||||
name="Copy slurl">
|
||||
<menu_item_call.on_click
|
||||
function="Favorites.DoToSelected"
|
||||
parameter="copy_slurl" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Show on Map"
|
||||
layout="topleft"
|
||||
|
|
@ -36,6 +28,14 @@
|
|||
function="Favorites.DoToSelected"
|
||||
parameter="show_on_map" />
|
||||
</menu_item_call>
|
||||
<menu_item_call
|
||||
label="Copy SLurl"
|
||||
layout="topleft"
|
||||
name="Copy slurl">
|
||||
<menu_item_call.on_click
|
||||
function="Favorites.DoToSelected"
|
||||
parameter="copy_slurl" />
|
||||
</menu_item_call>
|
||||
|
||||
<menu_item_separator
|
||||
layout="topleft" />
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="10"
|
||||
top_delta="30"
|
||||
top_delta="25"
|
||||
width="100">
|
||||
Position:
|
||||
</text>
|
||||
|
|
@ -93,7 +93,7 @@
|
|||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-5"
|
||||
left_delta="65"
|
||||
top_delta="20"
|
||||
width="80">
|
||||
Color:
|
||||
|
|
@ -108,12 +108,58 @@
|
|||
name="sun_moon_color"
|
||||
top_pad="5"
|
||||
width="60" />
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-235"
|
||||
top_delta="-3"
|
||||
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_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-5"
|
||||
top_delta="22"
|
||||
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_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-160"
|
||||
top_delta="27"
|
||||
left_delta="-5"
|
||||
top_delta="22"
|
||||
width="200">
|
||||
Glow Focus:
|
||||
</text>
|
||||
|
|
@ -128,8 +174,8 @@
|
|||
min_val="-2"
|
||||
max_val="2"
|
||||
name="glow_focus"
|
||||
top_delta="15"
|
||||
width="250"
|
||||
top_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
|
|
@ -151,8 +197,8 @@
|
|||
min_val="0"
|
||||
max_val="1.99"
|
||||
name="glow_size"
|
||||
top_delta="15"
|
||||
width="250"
|
||||
top_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
|
|
@ -174,8 +220,8 @@
|
|||
min_val="0"
|
||||
max_val="500"
|
||||
name="star_brightness"
|
||||
top_delta="15"
|
||||
width="250"
|
||||
top_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
|
||||
<check_box
|
||||
|
|
@ -227,7 +273,7 @@
|
|||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="10"
|
||||
top_delta="30"
|
||||
top_delta="25"
|
||||
width="100">
|
||||
Position:
|
||||
</text>
|
||||
|
|
@ -278,30 +324,76 @@
|
|||
top_delta="15"
|
||||
width="130"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-5"
|
||||
top_delta="22"
|
||||
width="200">
|
||||
Brightness:
|
||||
</text>
|
||||
<slider
|
||||
decimal_digits="2"
|
||||
follows="left|top"
|
||||
height="16"
|
||||
increment="0.01"
|
||||
initial_value="0"
|
||||
layout="topleft"
|
||||
left_delta="5"
|
||||
min_val="0.0"
|
||||
max_val="1.0"
|
||||
name="moon_brightness"
|
||||
top_delta="15"
|
||||
width="130"
|
||||
can_edit_text="true"/>
|
||||
<check_box
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-170"
|
||||
top_delta="32"
|
||||
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_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-5"
|
||||
top_delta="22"
|
||||
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_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<text
|
||||
follows="left|top"
|
||||
height="10"
|
||||
layout="topleft"
|
||||
left_delta="-5"
|
||||
top_delta="22"
|
||||
width="200">
|
||||
Brightness:
|
||||
</text>
|
||||
<slider
|
||||
decimal_digits="2"
|
||||
follows="left|top"
|
||||
height="16"
|
||||
increment="0.01"
|
||||
initial_value="0"
|
||||
layout="topleft"
|
||||
left_delta="5"
|
||||
min_val="0.0"
|
||||
max_val="1.0"
|
||||
name="moon_brightness"
|
||||
top_delta="13"
|
||||
width="215"
|
||||
can_edit_text="true"/>
|
||||
<check_box
|
||||
control_name="moonbeacon"
|
||||
width="60"
|
||||
height="16"
|
||||
|
|
|
|||
Loading…
Reference in New Issue