From ba9bd7d41ebdb655da54bf8b7f3e44a554228a8d Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sat, 26 Mar 2011 16:47:16 +0100 Subject: [PATCH] meta7 LightShare --- indra/newview/app_settings/keywords.ini | 37 +++++++ indra/newview/app_settings/settings.xml | 13 +++ indra/newview/llfloaterenvsettings.cpp | 18 +++- indra/newview/llfloaterenvsettings.h | 3 + indra/newview/llviewergenericmessage.cpp | 130 +++++++++++++++++++--- indra/newview/llviewergenericmessage.h | 2 +- indra/newview/llviewermessage.cpp | 9 ++ indra/newview/meta7windlight.h | 131 +++++++++++++++++++++++ 8 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 indra/newview/meta7windlight.h diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index cd7b533e7..022017247 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -512,6 +512,43 @@ TOUCH_INVALID_TEXCOORD Value returned by llDetectedTouchUV() and llDetectedTouc TOUCH_INVALID_VECTOR Value returned by llDetectedTouchPos(), llDetectedTouchNormal(), and llDetectedTouchBinormal() when the touch position is not valid. TOUCH_INVALID_FACE Value returned by llDetectedTouchFace() when the touch position is not valid. +WL_WATER_COLOR Windlight Water Colour +WL_WATER_FOG_DENSITY_EXPONENT Windlight Water Fog Density Exponent +WL_UNDERWATER_FOG_MODIFIER Windlight Underwater Fog Modifier +WL_REFLECTION_WAVELET_SCALE Windlight Reflection Wavelet Scale +WL_FRESNEL_SCALE Windlight Fresnel Scale +WL_FRESNEL_OFFSET Windlight Fresnel Offset +WL_REFRACT_SCALE_ABOVE Windlight Refract Scale Above +WL_REFRACT_SCALE_BELOW Windlight Refract Scale Below +WL_BLUR_MULTIPLIER Windlight Blur Multiplier +WL_BIG_WAVE_DIRECTION Windlight Big Wave Direction +WL_LITTLE_WAVE_DIRECTION Windlight Little Wave Direction +WL_NORMAL_MAP_TEXTURE Windlight Normal Map Texture +WL_HORIZON Windlight Horizon Colour +WL_HAZE_HORIZON Windlight Haze Horizon +WL_BLUE_DENSITY Windlight Blue Density +WL_HAZE_DENSITY Windlight Haze Density +WL_DENSITY_MULTIPLIER Windlight Density Multiplier +WL_DISTANCE_MULTIPLIER Windlight Distance Multiplier +WL_MAX_ALTITUDE Windlight Max Altitude +WL_SUN_MOON_COLOR Windlight Sun/Moon Colour +WL_AMBIENT Windlight Ambient Colour +WL_EAST_ANGLE Windlight Sun/Position East +WL_SUN_GLOW_FOCUS Windlight Sun Glow Focus +WL_SUN_GLOW_SIZE Windlight Sun Glow Size +WL_SCENE_GAMMA Windlight Scene Gamma +WL_STAR_BRIGHTNESS Windlight Star Brightness +WL_CLOUD_COLOR Windlight Cloud Colour +WL_CLOUD_XY_DENSITY Windlight Cloud X/Y/Density +WL_CLOUD_COVERAGE Windlight Cloud Coverage +WL_CLOUD_SCALE Windlight Cloud Scale +WL_CLOUD_DETAIL_XY_DENSITY Windlight Cloud Detail X/Y/Density +WL_CLOUD_SCROLL_X Windlight Cloud Scroll X +WL_CLOUD_SCROLL_Y Windlight Cloud Scroll Y +WL_CLOUD_SCROLL_Y_LOCK Windlight Cloud Scroll Y Lock +WL_CLOUD_SCROLL_X_LOCK Windlight Cloud Scroll X Lock +WL_DRAW_CLASSIC_CLOUDS Windlight Draw Classic Clouds + # string constants [word .1, .3, .5] NULL_KEY Indicates an empty key diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2057d827c..4a9a0918f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9,6 +9,19 @@ settings_rlv.xml + + UseServersideWindlightSettings + + Comment + Whether or not to use Windlight settings presented by the server. + Persist + 1 + Type + Boolean + Value + 1 + + FloaterLocalbitmapbrowserRect Comment diff --git a/indra/newview/llfloaterenvsettings.cpp b/indra/newview/llfloaterenvsettings.cpp index 661c3988c..6a55b8598 100644 --- a/indra/newview/llfloaterenvsettings.cpp +++ b/indra/newview/llfloaterenvsettings.cpp @@ -41,7 +41,8 @@ #include "llcombobox.h" #include "llcolorswatch.h" #include "llwlanimator.h" - +#include "llviewergenericmessage.h" +#include "meta7windlight.h" #include "llwlparamset.h" #include "llwlparammanager.h" #include "llwaterparammanager.h" @@ -87,6 +88,7 @@ void LLFloaterEnvSettings::initCallbacks(void) // WL Top childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL); childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL); + childSetAction("EnvSubmitWindlight", onSubmitWindlight, NULL); childSetAction("EnvUseEstateTimeButton", onUseEstateTime, NULL); childSetAction("EnvSettingsHelpButton", onClickHelp, this); } @@ -284,6 +286,20 @@ void LLFloaterEnvSettings::onOpenAdvancedWater(void* userData) LLFloaterWater::show(); } +void LLFloaterEnvSettings::onSubmitWindlight(void* userData) +{ + Meta7WindlightPacket * wl = new Meta7WindlightPacket(); + + LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + wl->reflectionWaveletScale.X = param_mgr->mNormalScale.mX; + wl->reflectionWaveletScale.Y = param_mgr->mNormalScale.mY; + wl->reflectionWaveletScale.Z = param_mgr->mNormalScale.mZ; + + + std::vector strings; + strings.push_back((char*)wl); + send_generic_message("Windlight", strings); +} void LLFloaterEnvSettings::onUseEstateTime(void* userData) { diff --git a/indra/newview/llfloaterenvsettings.h b/indra/newview/llfloaterenvsettings.h index 4cdf6036c..49bf4fd0d 100644 --- a/indra/newview/llfloaterenvsettings.h +++ b/indra/newview/llfloaterenvsettings.h @@ -78,6 +78,9 @@ public: /// open the advanced water settings menu static void onOpenAdvancedWater(void* userData); + /// submit windlight settings to the estate + static void onSubmitWindlight(void* userData); + /// sync time with the server static void onUseEstateTime(void* userData); diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp index e06766bbb..b541104fd 100644 --- a/indra/newview/llviewergenericmessage.cpp +++ b/indra/newview/llviewergenericmessage.cpp @@ -34,13 +34,16 @@ #include "llviewerprecompiledheaders.h" #include "llviewergenericmessage.h" - +#include "meta7windlight.h" #include "lldispatcher.h" #include "lluuid.h" #include "message.h" - #include "llagent.h" - +#include "llwaterparamset.h" +#include "llwaterparammanager.h" +#include "llwlparamset.h" +#include "llwlparammanager.h" +#include "lluuid.h" LLDispatcher gGenericDispatcher; @@ -82,20 +85,121 @@ void process_generic_message(LLMessageSystem* msg, void**) { LLUUID agent_id; msg->getUUID("AgentData", "AgentID", agent_id); - if (agent_id != gAgent.getID()) + + std::string method; + msg->getStringFast(_PREHASH_MethodData, _PREHASH_Method, method); + + //This needs to be handled by a dispatcher really, but I'm not sure where is the best place to put it + if (method == "Windlight") + { + //Meta7 WindLight packet + //We are delivering with an agentID of NULL_KEY so as to be + //friendly and not trigger a warning for unsupporting clients. + S32 count = msg->getNumberOfBlocksFast(_PREHASH_ParamList); + for (S32 i = 0; i < count; ++i) + { + // our param is binary data) + S32 size = msg->getSizeFast(_PREHASH_ParamList, i, _PREHASH_Parameter); + if (size >= 0) + { + char buf[250]; + msg->getBinaryDataFast( + _PREHASH_ParamList, _PREHASH_Parameter, + buf, size, i, 249); + + Meta7WindlightPacket* wl = (Meta7WindlightPacket*)buf; + + LLWaterParamManager * param_mgr = LLWaterParamManager::instance(); + LLWaterParamSet & param_set = param_mgr->mCurParams; + + param_set.set("waterFogColor", wl->waterColor.red / 256.f, wl->waterColor.green / 256.f, wl->waterColor.blue / 256.f); + param_set.set("waterFogDensity", pow(2.0f, wl->waterFogDensityExponent)); + param_set.set("underWaterFogMod", wl->underwaterFogModifier); + param_set.set("normScale", wl->reflectionWaveletScale.X,wl->reflectionWaveletScale.Y,wl->reflectionWaveletScale.Z); + param_set.set("fresnelScale", wl->fresnelScale); + param_set.set("fresnelOffset", wl->fresnelOffset); + param_set.set("scaleAbove", wl->refractScaleAbove); + param_set.set("scaleBelow", wl->refractScaleBelow); + param_set.set("blurMultiplier", wl->blurMultiplier); + param_set.set("wave1Dir", wl->littleWaveDirection.X, wl->littleWaveDirection.Y); + param_set.set("wave2Dir", wl->bigWaveDirection.X, wl->bigWaveDirection.Y); + + LLUUID normalMapTexture; + + std::string out = llformat( + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + (U8)(wl->normalMapTexture[0]), + (U8)(wl->normalMapTexture[1]), + (U8)(wl->normalMapTexture[2]), + (U8)(wl->normalMapTexture[3]), + (U8)(wl->normalMapTexture[4]), + (U8)(wl->normalMapTexture[5]), + (U8)(wl->normalMapTexture[6]), + (U8)(wl->normalMapTexture[7]), + (U8)(wl->normalMapTexture[8]), + (U8)(wl->normalMapTexture[9]), + (U8)(wl->normalMapTexture[10]), + (U8)(wl->normalMapTexture[11]), + (U8)(wl->normalMapTexture[12]), + (U8)(wl->normalMapTexture[13]), + (U8)(wl->normalMapTexture[14]), + (U8)(wl->normalMapTexture[15])); + + normalMapTexture.set(out); + + param_mgr->setParamSet( "Meta7CurrentRegion", param_set); + param_mgr->setNormalMapID(normalMapTexture); + + LLWLParamManager * wl_param_mgr = LLWLParamManager::instance(); + LLWLParamSet & wl_param_set = wl_param_mgr->mCurParams; + wl_param_set.setSunAngle(F_TWO_PI * wl->sunMoonPosiiton); + wl_param_set.setEastAngle(F_TWO_PI * wl->eastAngle); + wl_param_set.set("sunlight_color", wl->sunMoonColor.red * 3.0f, wl->sunMoonColor.green * 3.0f, wl->sunMoonColor.blue * 3.0f, wl->sunMoonColor.alpha * 3.0f); + wl_param_set.set("ambient", wl->ambient.red * 3.0f, wl->ambient.green * 3.0f, wl->ambient.blue * 3.0f, wl->ambient.alpha * 3.0f); + wl_param_set.set("blue_horizon", wl->horizon.red * 2.0f, wl->horizon.green *2.0f, wl->horizon.blue * 2.0f, wl->horizon.alpha * 2.0f); + wl_param_set.set("blue_density", wl->blueDensity.red * 2.0f, wl->blueDensity.green * 2.0f, wl->blueDensity.blue * 2.0f, wl->blueDensity.alpha * 2.0f); + wl_param_set.set("haze_horizon", wl->hazeHorizon, wl->hazeHorizon, wl->hazeHorizon, 1.f); + wl_param_set.set("haze_density", wl->hazeDensity, wl->hazeDensity, wl->hazeDensity, 1.f); + wl_param_set.set("cloud_shadow", wl->cloudCoverage, wl->cloudCoverage, wl->cloudCoverage, wl->cloudCoverage); + wl_param_set.set("density_multiplier", wl->densityMultiplier / 1000.0f); + wl_param_set.set("distance_multiplier", wl->distanceMultiplier, wl->distanceMultiplier, wl->distanceMultiplier, wl->distanceMultiplier); + wl_param_set.set("max_y",(F32)wl->maxAltitude); + wl_param_set.set("cloud_color", wl->cloudColor.red, wl->cloudColor.green, wl->cloudColor.blue, wl->cloudColor.alpha); + wl_param_set.set("cloud_pos_density1", wl->cloudXYDensity.X, wl->cloudXYDensity.Y, wl->cloudXYDensity.Z); + wl_param_set.set("cloud_pos_density2", wl->cloudDetailXYDensity.X, wl->cloudDetailXYDensity.Y, wl->cloudDetailXYDensity.Z); + wl_param_set.set("cloud_scale", wl->cloudScale, 0.f, 0.f, 1.f); + wl_param_set.set("gamma", wl->sceneGamma, wl->sceneGamma, wl->sceneGamma, 0.0f); + wl_param_set.set("glow",(2 - wl->sunGlowSize) * 20 , 0.f, -wl->sunGlowFocus * 5); + wl_param_set.setCloudScrollX(wl->cloudScrollX + 10.0f); + wl_param_set.setCloudScrollY(wl->cloudScrollY + 10.0f); + wl_param_set.setEnableCloudScrollX(!wl->cloudScrollXLock); + wl_param_set.setEnableCloudScrollY(!wl->cloudScrollYLock); + wl_param_set.setStarBrightness(wl->starBrightness); + wl_param_mgr->removeParamSet("Meta7-CurrentRegion",true); + wl_param_mgr->addParamSet( "Meta7-CurrentRegion", wl_param_set); + wl_param_mgr->savePreset( "Meta7-CurrentRegion"); + LLWLParamManager::instance()->mAnimator.mIsRunning = false; + LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + wl_param_mgr->loadPreset( "Meta7-CurrentRegion",true); + } + } + } + else if (agent_id != gAgent.getID()) { llwarns << "GenericMessage for wrong agent" << llendl; return; } - - std::string request; - LLUUID invoice; - LLDispatcher::sparam_t strings; - LLDispatcher::unpackMessage(msg, request, invoice, strings); - - if(!gGenericDispatcher.dispatch(request, invoice, strings)) + else { - llwarns << "GenericMessage " << request << " failed to dispatch" - << llendl; + std::string request; + LLUUID invoice; + LLDispatcher::sparam_t strings; + LLDispatcher::unpackMessage(msg, request, invoice, strings); + + if(!gGenericDispatcher.dispatch(request, invoice, strings)) + { + llwarns << "GenericMessage " << request << " failed to dispatch" + << llendl; + } } } diff --git a/indra/newview/llviewergenericmessage.h b/indra/newview/llviewergenericmessage.h index 6e1f0945b..6f54a2814 100644 --- a/indra/newview/llviewergenericmessage.h +++ b/indra/newview/llviewergenericmessage.h @@ -30,7 +30,7 @@ * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ - +#include "lluuid.h" #ifndef LLVIEWERGENERICMESSAGE_H #define LLVIEWERGENERICMESSAGE_H diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 77ad620f6..fafe1d942 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -160,6 +160,9 @@ #include "hippofloaterxml.h" #include "llversionviewer.h" +#include "llwlparammanager.h" +#include "llwaterparammanager.h" + #include #if LL_WINDOWS // For Windows specific error handler @@ -3663,6 +3666,12 @@ void process_teleport_finish(LLMessageSystem* msg, void**) gCacheName->setUpstream(sim); */ + //Reset the windlight profile to default + LLWLParamManager::instance()->mAnimator.mIsRunning = false; + LLWLParamManager::instance()->mAnimator.mUseLindenTime = false; + LLWLParamManager::instance()->loadPreset("Default", true); + LLWaterParamManager::instance()->loadPreset("Default",true); + // now, use the circuit info to tell simulator about us! LL_INFOS("Messaging") << "process_teleport_finish() Enabling " << sim_host << " with code " << msg->mOurCircuitCode << LL_ENDL; diff --git a/indra/newview/meta7windlight.h b/indra/newview/meta7windlight.h new file mode 100644 index 000000000..04ce86d46 --- /dev/null +++ b/indra/newview/meta7windlight.h @@ -0,0 +1,131 @@ +/** + * @file lightshare.cpp + * @brief Handler for Meta7 Lightshare (region-side Windlight settings). + * + * Copyright (c) 2010, Tom Meta / Meta7 Project + * + * The source code in this file ("Source Code") is provided to you + * under the terms of the GNU General Public License, version 2.0 + * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in + * this distribution, or online at + * http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + + +#ifndef META7WINDLIGHT_H +#define META7WINDLIGHT_H + +#include "linden_common.h" + +struct M7Color3{ + M7Color3(){}; + M7Color3(F32 pRed, F32 pGreen, F32 pBlue) + { + red=pRed; + green=pGreen; + blue=pBlue; + } + F32 red; + F32 green; + F32 blue; +}; + +struct M7Vector3 { + M7Vector3(){} + M7Vector3(F32 pX, F32 pY, F32 pZ) + { + X=pX; + Y=pY; + Z=pZ; + } + F32 X; + F32 Y; + F32 Z; + +}; + +struct M7Vector2{ + M7Vector2(){} + M7Vector2(F32 pX, F32 pY) + { + X=pX; + Y=pY; + } + F32 X; + F32 Y; + +}; + +struct M7Color4 { + M7Color4(){} + M7Color4(F32 pRed, F32 pGreen, F32 pBlue, F32 pAlpha) + { + red=pRed; + green=pGreen; + blue=pBlue; + alpha=pAlpha; + } + F32 red; + F32 green; + F32 blue; + F32 alpha; +}; + +struct Meta7WindlightPacket { + Meta7WindlightPacket(){} + M7Color3 waterColor; + F32 waterFogDensityExponent; + F32 underwaterFogModifier; + M7Vector3 reflectionWaveletScale; + F32 fresnelScale; + F32 fresnelOffset; + F32 refractScaleAbove; + F32 refractScaleBelow; + F32 blurMultiplier; + M7Vector2 littleWaveDirection; + M7Vector2 bigWaveDirection; + unsigned char normalMapTexture[16]; + M7Color4 horizon; + F32 hazeHorizon; + M7Color4 blueDensity; + F32 hazeDensity; + F32 densityMultiplier; + F32 distanceMultiplier; + M7Color4 sunMoonColor; + F32 sunMoonPosiiton; + M7Color4 ambient; + F32 eastAngle; + F32 sunGlowFocus; + F32 sunGlowSize; + F32 sceneGamma; + F32 starBrightness; + M7Color4 cloudColor; + M7Vector3 cloudXYDensity; + F32 cloudCoverage; + F32 cloudScale; + M7Vector3 cloudDetailXYDensity; + F32 cloudScrollX; + F32 cloudScrollY; + unsigned short maxAltitude; + char cloudScrollXLock; + char cloudScrollYLock; + char drawClassicClouds; + + +}; + +#endif