Add cmSetWindlightSceneTargeted. Add restrictions on windlight script use.

avinationmerge
CasperW 2009-12-17 18:40:34 +01:00
parent 6483470ec5
commit 6dbe25360e
8 changed files with 344 additions and 249 deletions

View File

@ -20,15 +20,15 @@ CREATE TABLE `regionwindlight` (
`little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11', `little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
`little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16', `little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
`normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4', `normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
`horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.26', `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.25',
`horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.24', `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.25',
`horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.33', `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.32',
`horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.33', `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.32',
`haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19', `haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
`blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.10', `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.12',
`blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.93', `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.22',
`blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.02', `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.38',
`blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.93', `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.38',
`haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70', `haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
`density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18', `density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
`distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8', `distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
@ -37,7 +37,7 @@ CREATE TABLE `regionwindlight` (
`sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26', `sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
`sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30', `sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
`sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30', `sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
`sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.335', `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.317',
`ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35', `ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35', `ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
`ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35', `ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
@ -63,7 +63,7 @@ CREATE TABLE `regionwindlight` (
`cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
`cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01', `cloud_scroll_y` float(3,2) unsigned NOT NULL DEFAULT '0.01',
`cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0', `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
`draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '0', `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`region_id`) PRIMARY KEY (`region_id`)
); );

View File

@ -38,8 +38,8 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public class RegionMeta7WindlightData public class RegionMeta7WindlightData : ICloneable
{ {
public UUID regionID = UUID.Zero; public UUID regionID = UUID.Zero;
public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f); public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
@ -54,19 +54,19 @@ namespace OpenSim.Framework
public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f); public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f); public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4"); public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
public Vector4 horizon = new Vector4(0.26f, 0.24f, 0.34f, 0.33f); public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f);
public float hazeHorizon = 0.19f; public float hazeHorizon = 0.19f;
public Vector4 blueDensity = new Vector4(0.10f, 0.93f, 0.02f, 0.93f); public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f);
public float hazeDensity = 0.70f; public float hazeDensity = 0.70f;
public float densityMultiplier = 0.18f; public float densityMultiplier = 0.18f;
public float distanceMultiplier = 0.8f; public float distanceMultiplier = 0.8f;
public UInt16 maxAltitude = 1605; public UInt16 maxAltitude = 1605;
public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f); public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
public float sunMoonPosition = 0.335f; public float sunMoonPosition = 0.317f;
public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f); public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
public float eastAngle = 0.0f; public float eastAngle = 0.0f;
public float sunGlowFocus = 0.10f; public float sunGlowFocus = 0.10f;
public float sunGlowSize = 0.10f; public float sunGlowSize = 1.75f;
public float sceneGamma = 1.0f; public float sceneGamma = 1.0f;
public float starBrightness = 0.0f; public float starBrightness = 0.0f;
public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f); public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
@ -78,7 +78,7 @@ namespace OpenSim.Framework
public bool cloudScrollXLock = false; public bool cloudScrollXLock = false;
public float cloudScrollY = 0.01f; public float cloudScrollY = 0.01f;
public bool cloudScrollYLock = false; public bool cloudScrollYLock = false;
public bool drawClassicClouds = false; public bool drawClassicClouds = true;
public delegate void SaveDelegate(RegionMeta7WindlightData wl); public delegate void SaveDelegate(RegionMeta7WindlightData wl);
public event SaveDelegate OnSave; public event SaveDelegate OnSave;
@ -86,7 +86,12 @@ namespace OpenSim.Framework
{ {
if (OnSave != null) if (OnSave != null)
OnSave(this); OnSave(this);
} }
public object Clone()
{
return this.MemberwiseClone(); // call clone method
}
} }
[Serializable] [Serializable]

View File

@ -70,64 +70,69 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
if (m_enableWindlight) if (m_enableWindlight)
{ {
m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent;
m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile;
m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted;
} }
InstallCommands(); InstallCommands();
m_log.Debug("[WINDLIGHT]: Initialised windlight module"); m_log.Debug("[WINDLIGHT]: Initialised windlight module");
}
private List<byte[]> compileWindlightSettings(RegionMeta7WindlightData wl)
{
byte[] mBlock = new Byte[249];
int pos = 0;
wl.waterColor.ToBytes(mBlock, 0); pos += 12;
Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
wl.horizon.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
wl.ambient.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
List<byte[]> param = new List<byte[]>();
param.Add(mBlock);
return param;
} }
public void SendProfileToClient(ScenePresence presence) public void SendProfileToClient(ScenePresence presence)
{ {
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight) if (m_enableWindlight)
{ {
if (presence.IsChildAgent == false) if (presence.IsChildAgent == false)
{ {
IClientAPI client = presence.ControllingClient; List<byte[]> param = compileWindlightSettings(m_scene.RegionInfo.WindlightSettings);
RegionMeta7WindlightData wl = m_scene.RegionInfo.WindlightSettings;
byte[] mBlock = new Byte[249];
int pos = 0;
wl.waterColor.ToBytes(mBlock, 0); pos += 12;
Utils.FloatToBytes(wl.waterFogDensityExponent).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.underwaterFogModifier).CopyTo(mBlock, pos); pos += 4;
wl.reflectionWaveletScale.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.fresnelScale).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.fresnelOffset).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.refractScaleAbove).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.refractScaleBelow).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.blurMultiplier).CopyTo(mBlock, pos); pos += 4;
wl.bigWaveDirection.ToBytes(mBlock, pos); pos += 8;
wl.littleWaveDirection.ToBytes(mBlock, pos); pos += 8;
wl.normalMapTexture.ToBytes(mBlock, pos); pos += 16;
wl.horizon.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.hazeHorizon).CopyTo(mBlock, pos); pos += 4;
wl.blueDensity.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.hazeDensity).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.densityMultiplier).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.distanceMultiplier).CopyTo(mBlock, pos); pos += 4;
wl.sunMoonColor.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.sunMoonPosition).CopyTo(mBlock, pos); pos += 4;
wl.ambient.ToBytes(mBlock, pos); pos += 16;
Utils.FloatToBytes(wl.eastAngle).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sunGlowFocus).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sunGlowSize).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.sceneGamma).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.starBrightness).CopyTo(mBlock, pos); pos += 4;
wl.cloudColor.ToBytes(mBlock, pos); pos += 16;
wl.cloudXYDensity.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.cloudCoverage).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.cloudScale).CopyTo(mBlock, pos); pos += 4;
wl.cloudDetailXYDensity.ToBytes(mBlock, pos); pos += 12;
Utils.FloatToBytes(wl.cloudScrollX).CopyTo(mBlock, pos); pos += 4;
Utils.FloatToBytes(wl.cloudScrollY).CopyTo(mBlock, pos); pos += 4;
Utils.UInt16ToBytes(wl.maxAltitude).CopyTo(mBlock, pos); pos += 2;
mBlock[pos] = Convert.ToByte(wl.cloudScrollXLock); pos++;
mBlock[pos] = Convert.ToByte(wl.cloudScrollYLock); pos++;
mBlock[pos] = Convert.ToByte(wl.drawClassicClouds); pos++;
List<byte[]> param = new List<byte[]>();
param.Add(mBlock);
client.SendGenericMessage("Windlight", param); client.SendGenericMessage("Windlight", param);
} }
} }
@ -136,13 +141,37 @@ namespace OpenSim.Region.CoreModules.World.Meta7Windlight
//We probably don't want to spam chat with this.. probably //We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled"); //m_log.Debug("[WINDLIGHT]: Module disabled");
} }
}
public void SendProfileToClient(ScenePresence presence, RegionMeta7WindlightData wl)
{
IClientAPI client = presence.ControllingClient;
if (m_enableWindlight)
{
if (presence.IsChildAgent == false)
{
List<byte[]> param = compileWindlightSettings(wl);
client.SendGenericMessage("Windlight", param);
}
}
else
{
//We probably don't want to spam chat with this.. probably
//m_log.Debug("[WINDLIGHT]: Module disabled");
}
} }
private void EventManager_OnMakeRootAgent(ScenePresence presence) private void EventManager_OnMakeRootAgent(ScenePresence presence)
{ {
m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
SendProfileToClient(presence); SendProfileToClient(presence);
}
private void EventManager_OnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID pUUID)
{
ScenePresence Sc;
if (m_scene.TryGetAvatar(pUUID,out Sc))
{
SendProfileToClient(Sc,wl);
}
} }
private void EventManager_OnSaveNewWindlightProfile() private void EventManager_OnSaveNewWindlightProfile()
{ {
m_scene.ForEachScenePresence(SendProfileToClient); m_scene.ForEachScenePresence(SendProfileToClient);

View File

@ -194,7 +194,9 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void OnMakeRootAgentDelegate(ScenePresence presence); public delegate void OnMakeRootAgentDelegate(ScenePresence presence);
public delegate void OnSaveNewWindlightProfileDelegate(); public delegate void OnSaveNewWindlightProfileDelegate();
public delegate void OnSendNewWindlightProfileTargetedDelegate(RegionMeta7WindlightData wl, UUID user);
public event OnMakeRootAgentDelegate OnMakeRootAgent; public event OnMakeRootAgentDelegate OnMakeRootAgent;
public event OnSendNewWindlightProfileTargetedDelegate OnSendNewWindlightProfileTargeted;
public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile; public event OnSaveNewWindlightProfileDelegate OnSaveNewWindlightProfile;
public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
@ -414,6 +416,7 @@ namespace OpenSim.Region.Framework.Scenes
private ClientClosed handlerClientClosed = null; //OnClientClosed; private ClientClosed handlerClientClosed = null; //OnClientClosed;
private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; private OnMakeChildAgentDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile; private OnSaveNewWindlightProfileDelegate handlerSaveNewWindlightProfile = null; //OnSaveNewWindlightProfile;
private OnSendNewWindlightProfileTargetedDelegate handlerSendNewWindlightProfileTargeted = null; //OnSendNewWindlightProfileTargeted;
private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent; private OnMakeRootAgentDelegate handlerMakeRootAgent = null; //OnMakeRootAgent;
private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick; private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps; private RegisterCapsEvent handlerRegisterCaps = null; // OnRegisterCaps;
@ -775,6 +778,15 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user)
{
handlerSendNewWindlightProfileTargeted = OnSendNewWindlightProfileTargeted;
if (handlerSendNewWindlightProfileTargeted != null)
{
handlerSendNewWindlightProfileTargeted(wl, user);
}
}
public void TriggerOnSaveNewWindlightProfile() public void TriggerOnSaveNewWindlightProfile()
{ {
handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile; handlerSaveNewWindlightProfile = OnSaveNewWindlightProfile;

View File

@ -1519,8 +1519,8 @@ namespace OpenSim.Region.Framework.Scenes
public void SaveTerrain() public void SaveTerrain()
{ {
m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
} }
public void StoreWindlightProfile(RegionMeta7WindlightData wl) public void StoreWindlightProfile(RegionMeta7WindlightData wl)
{ {
m_regInfo.WindlightSettings = wl; m_regInfo.WindlightSettings = wl;

View File

@ -229,8 +229,181 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return values; return values;
} }
private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
{
RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
LSL_List values = new LSL_List();
int idx = 0;
while (idx < rules.Length)
{
uint rule = (uint)rules.GetLSLIntegerItem(idx);
LSL_Types.Quaternion iQ;
LSL_Types.Vector3 iV;
switch (rule)
{
case (int)ScriptBaseClass.WL_AMBIENT:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
idx++;
iV = rules.GetVector3Item(idx);
wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
break;
case (int)ScriptBaseClass.WL_BLUE_DENSITY:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
idx++;
wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_COLOR:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
idx++;
wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCALE:
idx++;
wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
idx++;
wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
idx++;
wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
idx++;
wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
idx++;
wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
idx++;
wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
idx++;
wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
idx++;
wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_EAST_ANGLE:
idx++;
wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
idx++;
wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
idx++;
wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HAZE_DENSITY:
idx++;
wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HAZE_HORIZON:
idx++;
wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HORIZON:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
idx++;
iV = rules.GetVector3Item(idx);
wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
break;
case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
idx++;
wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
break;
case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
idx++;
wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
break;
case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
idx++;
iV = rules.GetVector3Item(idx);
wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
idx++;
wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
idx++;
wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SCENE_GAMMA:
idx++;
wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
idx++;
wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
idx++;
wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
idx++;
wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
idx++;
wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_WATER_COLOR:
idx++;
iV = rules.GetVector3Item(idx);
wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
idx++;
wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
break;
}
idx++;
}
return wl;
}
/// <summary> /// <summary>
/// Set the current Windlight scene /// Set the current Windlight scene
/// </summary> /// </summary>
@ -242,188 +415,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CMShoutError("Careminster functions are not enabled."); CMShoutError("Careminster functions are not enabled.");
return 0; return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
return 0;
} }
int success = 0; int success = 0;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight) if (Meta7WindlightModule.EnableWindlight)
{ {
RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
LSL_List values = new LSL_List(); success = 1;
int idx = 0; }
success = 1; else
while (idx < rules.Length) {
{ CMShoutError("Windlight module is disabled");
uint rule = (uint)rules.GetLSLIntegerItem(idx); return 0;
LSL_Types.Quaternion iQ;
LSL_Types.Vector3 iV;
switch (rule)
{
case (int)ScriptBaseClass.WL_AMBIENT:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
idx++;
iV = rules.GetVector3Item(idx);
wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
break;
case (int)ScriptBaseClass.WL_BLUE_DENSITY:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
idx++;
wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_COLOR:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
idx++;
wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCALE:
idx++;
wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
idx++;
wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
idx++;
wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
idx++;
wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
idx++;
wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
idx++;
wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
idx++;
wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
idx++;
wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
break;
case (int)ScriptBaseClass.WL_EAST_ANGLE:
idx++;
wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
idx++;
wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
idx++;
wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HAZE_DENSITY:
idx++;
wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HAZE_HORIZON:
idx++;
wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_HORIZON:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
idx++;
iV = rules.GetVector3Item(idx);
wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
break;
case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
idx++;
wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
break;
case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
idx++;
wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
break;
case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
idx++;
iV = rules.GetVector3Item(idx);
wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
idx++;
wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
idx++;
wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SCENE_GAMMA:
idx++;
wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
idx++;
wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
idx++;
wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
idx++;
wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
idx++;
iQ = rules.GetQuaternionItem(idx);
wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
break;
case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
idx++;
wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_WATER_COLOR:
idx++;
iV = rules.GetVector3Item(idx);
wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
break;
case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
idx++;
wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
break;
default:
success = 0;
break;
}
idx++;
}
m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
} }
return success; return success;
}
/// <summary>
/// Set the current Windlight scene to a target avatar
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
}
return success;
} }
} }

View File

@ -15,6 +15,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{ {
// Windlight Functions // Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules); LSL_List cmGetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules); int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightSceneTargeted(LSL_List rules, key target);
} }
} }

View File

@ -66,6 +66,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public int cmSetWindlightScene(LSL_List rules) public int cmSetWindlightScene(LSL_List rules)
{ {
return m_CM_Functions.cmSetWindlightScene(rules); return m_CM_Functions.cmSetWindlightScene(rules);
}
public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
} }
} }
} }