From cc22ffc6d799544e8f2a9dfed6813081d908c88d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 13 Oct 2017 17:17:49 -0700 Subject: Watter settings active and start of new joystick button type. --- indra/newview/lljoystickbutton.cpp | 184 ++++++++++++++++++++++++++++++++++++- 1 file changed, 183 insertions(+), 1 deletion(-) (limited to 'indra/newview/lljoystickbutton.cpp') diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 59e14e6cc0..5b35d5c3a5 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -48,7 +48,7 @@ static LLDefaultChildRegistry::Register r1("joystick_slide static LLDefaultChildRegistry::Register r2("joystick_turn"); static LLDefaultChildRegistry::Register r3("joystick_rotate"); static LLDefaultChildRegistry::Register r5("joystick_track"); - +static LLDefaultChildRegistry::Register r6("joystick_quat"); const F32 NUDGE_TIME = 0.25f; // in seconds @@ -646,3 +646,185 @@ void LLJoystickCameraTrack::onHeldDown() gAgentCamera.setPanDownKey(getOrbitRate()); } } + +//------------------------------------------------------------------------------- +// LLJoystickQuaternion +//------------------------------------------------------------------------------- + +LLJoystickQuaternion::Params::Params() +{ +} + +LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p): + LLJoystick(p), + mInLeft(false), + mInTop(false), + mInRight(false), + mInBottom(false) +{ +} + +void LLJoystickQuaternion::setToggleState(BOOL left, BOOL top, BOOL right, BOOL bottom) +{ + mInLeft = left; + mInTop = top; + mInRight = right; + mInBottom = bottom; +} + +BOOL LLJoystickQuaternion::handleMouseDown(S32 x, S32 y, MASK mask) +{ + updateSlop(); + + // Set initial offset based on initial click location + S32 horiz_center = getRect().getWidth() / 2; + S32 vert_center = getRect().getHeight() / 2; + + S32 dx = x - horiz_center; + S32 dy = y - vert_center; + + if (dy > dx && dy > -dx) + { + // top + mInitialOffset.mX = 0; + mInitialOffset.mY = (mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_UP; + } + else if (dy > dx && dy <= -dx) + { + // left + mInitialOffset.mX = -(mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_LEFT; + } + else if (dy <= dx && dy <= -dx) + { + // bottom + mInitialOffset.mX = 0; + mInitialOffset.mY = -(mVertSlopNear + mVertSlopFar) / 2; + mInitialQuadrant = JQ_DOWN; + } + else + { + // right + mInitialOffset.mX = (mHorizSlopNear + mHorizSlopFar) / 2; + mInitialOffset.mY = 0; + mInitialQuadrant = JQ_RIGHT; + } + + return LLJoystick::handleMouseDown(x, y, mask); +} + +BOOL LLJoystickQuaternion::handleMouseUp(S32 x, S32 y, MASK mask) +{ + return LLJoystick::handleMouseUp(x, y, mask); +} + +void LLJoystickQuaternion::onHeldDown() +{ + updateSlop(); + + S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX; + S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY; + + // left-right rotation + if (dx > mHorizSlopNear) + { + } + else if (dx < -mHorizSlopNear) + { + } + + // over/under rotation + if (dy > mVertSlopNear) + { + } + else if (dy < -mVertSlopNear) + { + } +} + +void LLJoystickQuaternion::draw() +{ + LLGLSUIDefault gls_ui; + + getImageUnselected()->draw(0, 0); + LLPointer image = getImageSelected(); + + if (mInTop) + { + drawRotatedImage(getImageSelected(), 0); + } + + if (mInRight) + { + drawRotatedImage(getImageSelected(), 1); + } + + if (mInBottom) + { + drawRotatedImage(getImageSelected(), 2); + } + + if (mInLeft) + { + drawRotatedImage(getImageSelected(), 3); + } +} + +F32 LLJoystickQuaternion::getOrbitRate() +{ + return 1; +} + +void LLJoystickQuaternion::updateSlop() +{ + // small fixed slop region + mVertSlopNear = 16; + mVertSlopFar = 32; + + mHorizSlopNear = 16; + mHorizSlopFar = 32; +} + +void LLJoystickQuaternion::drawRotatedImage(LLPointer image, S32 rotations) +{ + S32 width = image->getWidth(); + S32 height = image->getHeight(); + LLTexture* texture = image->getImage(); + + /* + * Scale texture coordinate system + * to handle the different between image size and size of texture. + */ + F32 uv[][2] = + { + { (F32)width / texture->getWidth(), (F32)height / texture->getHeight() }, + { 0.f, (F32)height / texture->getHeight() }, + { 0.f, 0.f }, + { (F32)width / texture->getWidth(), 0.f } + }; + + gGL.getTexUnit(0)->bind(texture); + + gGL.color4fv(UI_VERTEX_COLOR.mV); + + gGL.begin(LLRender::QUADS); + { + gGL.texCoord2fv(uv[(rotations + 0) % 4]); + gGL.vertex2i(width, height); + + gGL.texCoord2fv(uv[(rotations + 1) % 4]); + gGL.vertex2i(0, height); + + gGL.texCoord2fv(uv[(rotations + 2) % 4]); + gGL.vertex2i(0, 0); + + gGL.texCoord2fv(uv[(rotations + 3) % 4]); + gGL.vertex2i(width, 0); + } + gGL.end(); +} + + + -- cgit v1.3 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/lljoystickbutton.cpp') 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.3