From 00ce291f013ce434b202da675bfb38431014a077 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 17 Oct 2017 12:03:26 -0700 Subject: New prototype control for moving sun and moon in sky. --- indra/newview/llfloatereditsky.cpp | 43 +++++++++++----- indra/newview/llfloatereditsky.h | 3 ++ indra/newview/lljoystickbutton.cpp | 57 +++++++++++++++++++++- indra/newview/lljoystickbutton.h | 13 +++++ .../default/xui/en/floater_edit_sky_preset.xml | 31 +++++++++++- .../skins/default/xui/en/widgets/joystick_quat.xml | 7 +++ .../default/xui/en/widgets/joystick_rotate.xml | 4 +- 7 files changed, 141 insertions(+), 17 deletions(-) create mode 100644 indra/newview/skins/default/xui/en/widgets/joystick_quat.xml (limited to 'indra/newview') 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("WLSunPos")->addSlider(12.f); +// // Create the sun position scrubber on the slider. +// getChild("WLSunPos")->addSlider(12.f); return TRUE; } @@ -175,9 +176,11 @@ void LLFloaterEditSky::initCallbacks(void) getChild("WLAmbient")->setCommitCallback(boost::bind(&LLFloaterEditSky::onColorControlMoved, this, _1, &mSkyAdapter->mAmbient)); // time of day - getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider - getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl - getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); +// getChild("WLSunPos")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); // multi-slider +// getChild("WLDayTime")->setCommitCallback(boost::bind(&LLFloaterEditSky::onTimeChanged, this)); // time ctrl +// getChild("WLEastAngle")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunMoved, this, _1, &mSkyAdapter->mLightnorm)); + getChild("WLSunRotation")->setCommitCallback(boost::bind(&LLFloaterEditSky::onSunRotationChanged, this)); + getChild("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("WLSunPos")->setCurSliderValue(time24, TRUE); - getChild("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("WLSunPos")->setCurSliderValue(time24, TRUE); +// getChild("WLDayTime")->setTime24(time24); +// childSetValue("WLEastAngle", azal.first / F_TWO_PI); + getChild("WLSunRotation")->setRotation(psky->getSunRotation()); + getChild("WLMoonRotation")->setRotation(psky->getMoonRotation()); // Clouds @@ -488,6 +493,22 @@ void LLFloaterEditSky::onTimeChanged() onSunMoved(getChild("WLSunPos"), &(mSkyAdapter->mLightnorm)); } +void LLFloaterEditSky::onSunRotationChanged() +{ + LLJoystickQuaternion* sun_spinner = getChild("WLSunRotation"); + LLQuaternion sunrot(sun_spinner->getRotation()); + + mEditSettings->setSunRotation(sunrot); +} + +void LLFloaterEditSky::onMoonRotationChanged() +{ + LLJoystickQuaternion* moon_spinner = getChild("WLMoonRotation"); + LLQuaternion moonrot(moon_spinner->getRotation()); + + mEditSettings->setMoonRotation(moonrot); +} + void LLFloaterEditSky::onStarAlphaMoved(LLUICtrl* ctrl) { LLSliderCtrl* sldr_ctrl = static_cast(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 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 - /> + + /> + + + 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 @@ - -- cgit v1.2.3