summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2017-10-17 12:03:26 -0700
committerRider Linden <rider@lindenlab.com>2017-10-17 12:03:26 -0700
commit00ce291f013ce434b202da675bfb38431014a077 (patch)
treefe7d00d46dba1c763f26bed76ca34ea064303e8f /indra
parentb4d1b1c43b4cf046a4a9df1911b5edc2d92d0a7b (diff)
New prototype control for moving sun and moon in sky.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfloatereditsky.cpp43
-rw-r--r--indra/newview/llfloatereditsky.h3
-rw-r--r--indra/newview/lljoystickbutton.cpp57
-rw-r--r--indra/newview/lljoystickbutton.h13
-rw-r--r--indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml31
-rw-r--r--indra/newview/skins/default/xui/en/widgets/joystick_quat.xml7
-rw-r--r--indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml4
7 files changed, 141 insertions, 17 deletions
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp
index a6f3f1ebe7..bd83bdd9c5 100644
--- a/indra/newview/llfloatereditsky.cpp
+++ b/indra/newview/llfloatereditsky.cpp
@@ -40,6 +40,7 @@
#include "llsliderctrl.h"
#include "lltabcontainer.h"
#include "lltimectrl.h"
+#include "lljoystickbutton.h"
// newview
#include "llagent.h"
@@ -88,8 +89,8 @@ BOOL LLFloaterEditSky::postBuild()
initCallbacks();
- // Create the sun position scrubber on the slider.
- getChild<LLMultiSliderCtrl>("WLSunPos")->addSlider(12.f);
+// // Create the sun position scrubber on the slider.
+// getChild<LLMultiSliderCtrl>("WLSunPos")->addSlider(12.f);
return TRUE;
}
@@ -175,9 +176,11 @@ void LLFloaterEditSky::initCallbacks(void)
getChild<LLUICtrl>("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient));
// time of day
- getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider
- getChild<LLTimeCtrl>("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl
- getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm));
+// getChild<LLUICtrl>("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider
+// getChild<LLTimeCtrl>("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl
+// getChild<LLUICtrl>("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm));
+ getChild<LLJoystickQuaternion>("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this));
+ getChild<LLJoystickQuaternion>("WLMoonRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onMoonRotationChanged, this));
// Clouds
@@ -247,12 +250,14 @@ void LLFloaterEditSky::syncControls()
mSkyAdapter->mAmbient.setColor3( psky->getAmbientColor() );
setColorSwatch("WLAmbient", mSkyAdapter->mAmbient, WL_SUN_AMBIENT_SLIDER_SCALE);
- LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl();
-
- F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI);
- getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE);
- getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24);
- childSetValue("WLEastAngle", azal.first / F_TWO_PI);
+// LLSettingsSky::azimalt_t azal = psky->getSunRotationAzAl();
+//
+// F32 time24 = sun_pos_to_time24(azal.second / F_TWO_PI);
+// getChild<LLMultiSliderCtrl>("WLSunPos")->setCurSliderValue(time24, TRUE);
+// getChild<LLTimeCtrl>("WLDayTime")->setTime24(time24);
+// childSetValue("WLEastAngle", azal.first / F_TWO_PI);
+ getChild<LLJoystickQuaternion>("WLSunRotation")->setRotation(psky->getSunRotation());
+ getChild<LLJoystickQuaternion>("WLMoonRotation")->setRotation(psky->getMoonRotation());
// Clouds
@@ -488,6 +493,22 @@ void LLFloaterEditSky::onTimeChanged()
onSunMoved(getChild<LLUICtrl>("WLSunPos"), &(mSkyAdapter->mLightnorm));
}
+void LLFloaterEditSky::onSunRotationChanged()
+{
+ LLJoystickQuaternion* sun_spinner = getChild<LLJoystickQuaternion>("WLSunRotation");
+ LLQuaternion sunrot(sun_spinner->getRotation());
+
+ mEditSettings->setSunRotation(sunrot);
+}
+
+void LLFloaterEditSky::onMoonRotationChanged()
+{
+ LLJoystickQuaternion* moon_spinner = getChild<LLJoystickQuaternion>("WLMoonRotation");
+ LLQuaternion moonrot(moon_spinner->getRotation());
+
+ mEditSettings->setMoonRotation(moonrot);
+}
+
void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl)
{
LLSliderCtrl* sldr_ctrl = static_cast<LLSliderCtrl*>(ctrl);
diff --git a/indra/newview/llfloatereditsky.h b/indra/newview/llfloatereditsky.h
index 6aec87014d..51be50a481 100644
--- a/indra/newview/llfloatereditsky.h
+++ b/indra/newview/llfloatereditsky.h
@@ -81,6 +81,9 @@ private:
void onSunMoved(LLUICtrl* ctrl, void* userdata);
void onTimeChanged();
+ void onSunRotationChanged();
+ void onMoonRotationChanged();
+
// for handling when the star slider is moved to adjust the alpha
void onStarAlphaMoved(LLUICtrl* ctrl);
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index 5b35d5c3a5..7fcd6f4361 100644
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -660,8 +660,20 @@ LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p
mInLeft(false),
mInTop(false),
mInRight(false),
- mInBottom(false)
-{
+ mInBottom(false),
+ mVectorZero(0.0f, 0.0f, 1.0f),
+ mRotation(),
+ mUpDnAxis(1.0f, 0.0f, 0.0f),
+ mLfRtAxis(0.0f, 0.0f, 1.0f),
+ mXAxisIndex(2), // left & right across the control
+ mYAxisIndex(0), // up & down across the control
+ mZAxisIndex(1) // tested for above and below
+{
+ for (int i = 0; i < 3; ++i)
+ {
+ mLfRtAxis.mV[i] = (mXAxisIndex == i) ? 1.0 : 0.0;
+ mUpDnAxis.mV[i] = (mYAxisIndex == i) ? 1.0 : 0.0;
+ }
}
void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom)
@@ -722,6 +734,7 @@ BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask)
void LLJoystickQuaternion::onHeldDown()
{
+ LLVector3 axis;
updateSlop();
S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX;
@@ -730,18 +743,34 @@ void LLJoystickQuaternion::onHeldDown()
// left-right rotation
if (dx > mHorizSlopNear)
{
+ axis += mUpDnAxis;
}
else if (dx < -mHorizSlopNear)
{
+ axis -= mUpDnAxis;
}
// over/under rotation
if (dy > mVertSlopNear)
{
+ axis += mLfRtAxis;
}
else if (dy < -mVertSlopNear)
{
+ axis -= mLfRtAxis;
}
+
+ if (axis.isNull())
+ return;
+
+ axis.normalize();
+
+ LLQuaternion delta;
+ delta.setAngleAxis(0.0523599f, axis); // about 3deg
+
+ mRotation *= delta;
+ setValue(mRotation.getValue());
+ onCommit();
}
void LLJoystickQuaternion::draw()
@@ -770,6 +799,16 @@ void LLJoystickQuaternion::draw()
{
drawRotatedImage(getImageSelected(), 3);
}
+
+ LLVector3 draw_point = mVectorZero * mRotation;
+ S32 halfwidth = getRect().getWidth() / 2;
+ S32 halfheight = getRect().getHeight() / 2;
+ draw_point.mV[mXAxisIndex] = (draw_point.mV[mXAxisIndex] + 1.0) * halfwidth;
+ draw_point.mV[mYAxisIndex] = (draw_point.mV[mYAxisIndex] + 1.0) * halfheight;
+
+ gl_circle_2d(draw_point.mV[mXAxisIndex], draw_point.mV[mYAxisIndex], 4, 8,
+ draw_point.mV[mZAxisIndex] >= 0.f);
+
}
F32 LLJoystickQuaternion::getOrbitRate()
@@ -826,5 +865,19 @@ void LLJoystickQuaternion::drawRotatedImage(LLPointer<LLUIImage> image, S32 rota
gGL.end();
}
+void LLJoystickQuaternion::setRotation(const LLQuaternion &value)
+{
+ if (value != mRotation)
+ {
+ mRotation = value;
+ mRotation.normalize();
+ LLJoystick::setValue(mRotation.getValue());
+ }
+}
+
+LLQuaternion LLJoystickQuaternion::getRotation() const
+{
+ return mRotation;
+}
diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h
index ae8de1bf32..ee66088b56 100644
--- a/indra/newview/lljoystickbutton.h
+++ b/indra/newview/lljoystickbutton.h
@@ -30,6 +30,7 @@
#include "llbutton.h"
#include "llcoord.h"
#include "llviewertexture.h"
+#include "llquaternion.h"
typedef enum e_joystick_quadrant
{
@@ -198,6 +199,9 @@ public:
virtual void onHeldDown();
virtual void draw();
+ void setRotation(const LLQuaternion &value);
+ LLQuaternion getRotation() const;
+
protected:
F32 getOrbitRate();
virtual void updateSlop();
@@ -207,6 +211,15 @@ protected:
BOOL mInTop;
BOOL mInRight;
BOOL mInBottom;
+
+ S32 mXAxisIndex;
+ S32 mYAxisIndex;
+ S32 mZAxisIndex;
+
+ LLVector3 mVectorZero;
+ LLQuaternion mRotation;
+ LLVector3 mUpDnAxis;
+ LLVector3 mLfRtAxis;
};
#endif // LL_LLJOYSTICKBUTTON_H
diff --git a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml
index 56233d91ee..c03a206e88 100644
--- a/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_edit_sky_preset.xml
@@ -454,7 +454,34 @@
width="200">
Sun/Moon Position
</text>
- <multi_slider
+
+ <joystick_quat
+ follows="left|top"
+ height="78"
+ layout="topleft"
+ left_delta="0"
+ name="WLSunRotation"
+ quadrant="left"
+ sound_flags="3"
+ visible="true"
+ tool_tip="Move sun in sky"
+ top="44"
+ width="78" /> />
+
+ <joystick_quat
+ follows="left|top"
+ height="78"
+ layout="topleft"
+ left_delta="96"
+ name="WLMoonRotation"
+ quadrant="left"
+ sound_flags="3"
+ visible="true"
+ tool_tip="Move moon in sky"
+ top="44"
+ width="78" /> />
+
+ <!-- multi_slider
can_edit_text="true"
control_name="WLSunPos"
decimal_digits="0"
@@ -644,7 +671,7 @@
left_delta="10"
name="WLEastAngle"
top_pad="6"
- width="200" />
+ width="200" / -->
</panel>
<panel
diff --git a/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml b/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml
new file mode 100644
index 0000000000..a190da3909
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/widgets/joystick_quat.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<joystick_rotate
+ image_selected="Cam_Rotate_In"
+ image_unselected="Cam_Rotate_Out"
+ scale_image="false"
+ mouse_opaque="false"
+ held_down_delay.seconds="0"/>
diff --git a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml
index a190da3909..cbf721b346 100644
--- a/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml
+++ b/indra/newview/skins/default/xui/en/widgets/joystick_rotate.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<joystick_rotate
+<joystick_quat
image_selected="Cam_Rotate_In"
image_unselected="Cam_Rotate_Out"
- scale_image="false"
+ scale_image="true"
mouse_opaque="false"
held_down_delay.seconds="0"/>