From ec637e2b8c089efc16bbb9faae0a1e3cf939db41 Mon Sep 17 00:00:00 2001
From: Melanie
Date: Wed, 31 Mar 2010 04:20:20 +0100
Subject: Committing the LightShare code, which was developed by TomMeta of
Meta7. This allows scripts to set WindLight parameters for clients connecting
to a region. Currently, this is only supported by the Meta7 viewer.
---
OpenSim/Framework/RegionInfo.cs | 305 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 304 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Framework/RegionInfo.cs')
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 5d63da7..5eacd73 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -36,8 +36,295 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework.Console;
+
namespace OpenSim.Framework
-{
+{
+ public class RegionLightShareData : ICloneable
+ {
+ public UUID regionID = UUID.Zero;
+ public Vector3 waterColor = new Vector3(4.0f,38.0f,64.0f);
+ public float waterFogDensityExponent = 4.0f;
+ public float underwaterFogModifier = 0.25f;
+ public Vector3 reflectionWaveletScale = new Vector3(2.0f,2.0f,2.0f);
+ public float fresnelScale = 0.40f;
+ public float fresnelOffset = 0.50f;
+ public float refractScaleAbove = 0.03f;
+ public float refractScaleBelow = 0.20f;
+ public float blurMultiplier = 0.040f;
+ public Vector2 bigWaveDirection = new Vector2(1.05f,-0.42f);
+ public Vector2 littleWaveDirection = new Vector2(1.11f,-1.16f);
+ public UUID normalMapTexture = new UUID("822ded49-9a6c-f61c-cb89-6df54f42cdf4");
+ public Vector4 horizon = new Vector4(0.25f, 0.25f, 0.32f, 0.32f);
+ public float hazeHorizon = 0.19f;
+ public Vector4 blueDensity = new Vector4(0.12f, 0.22f, 0.38f, 0.38f);
+ public float hazeDensity = 0.70f;
+ public float densityMultiplier = 0.18f;
+ public float distanceMultiplier = 0.8f;
+ public UInt16 maxAltitude = 1605;
+ public Vector4 sunMoonColor = new Vector4(0.24f, 0.26f, 0.30f, 0.30f);
+ public float sunMoonPosition = 0.317f;
+ public Vector4 ambient = new Vector4(0.35f,0.35f,0.35f,0.35f);
+ public float eastAngle = 0.0f;
+ public float sunGlowFocus = 0.10f;
+ public float sunGlowSize = 1.75f;
+ public float sceneGamma = 1.0f;
+ public float starBrightness = 0.0f;
+ public Vector4 cloudColor = new Vector4(0.41f, 0.41f, 0.41f, 0.41f);
+ public Vector3 cloudXYDensity = new Vector3(1.00f, 0.53f, 1.00f);
+ public float cloudCoverage = 0.27f;
+ public float cloudScale = 0.42f;
+ public Vector3 cloudDetailXYDensity = new Vector3(1.00f, 0.53f, 0.12f);
+ public float cloudScrollX = 0.20f;
+ public bool cloudScrollXLock = false;
+ public float cloudScrollY = 0.01f;
+ public bool cloudScrollYLock = false;
+ public bool drawClassicClouds = true;
+
+ public delegate void SaveDelegate(RegionLightShareData wl);
+ public event SaveDelegate OnSave;
+ public void Save()
+ {
+ if (OnSave != null)
+ OnSave(this);
+ }
+ public object Clone()
+ {
+ return this.MemberwiseClone(); // call clone method
+ }
+
+ }
+
+ [Serializable]
+ public class SimpleRegionInfo
+ {
+ // private static readonly log4net.ILog m_log
+ // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// The port by which http communication occurs with the region (most noticeably, CAPS communication)
+ ///
+ public uint HttpPort
+ {
+ get { return m_httpPort; }
+ set { m_httpPort = value; }
+ }
+ protected uint m_httpPort;
+
+ ///
+ /// A well-formed URI for the host region server (namely "http://" + ExternalHostName)
+ ///
+ public string ServerURI
+ {
+ get { return m_serverURI; }
+ set { m_serverURI = value; }
+ }
+ protected string m_serverURI;
+
+ public string RegionName
+ {
+ get { return m_regionName; }
+ set { m_regionName = value; }
+ }
+ protected string m_regionName = String.Empty;
+
+ protected bool Allow_Alternate_Ports;
+ public bool m_allow_alternate_ports;
+ protected string m_externalHostName;
+
+ protected IPEndPoint m_internalEndPoint;
+ protected uint? m_regionLocX;
+ protected uint? m_regionLocY;
+ protected uint m_remotingPort;
+ public UUID RegionID = UUID.Zero;
+ public string RemotingAddress;
+ public UUID ScopeID = UUID.Zero;
+
+ public SimpleRegionInfo()
+ {
+ }
+
+ public SimpleRegionInfo(uint regionLocX, uint regionLocY, IPEndPoint internalEndPoint, string externalUri)
+ {
+ m_regionLocX = regionLocX;
+ m_regionLocY = regionLocY;
+
+ m_internalEndPoint = internalEndPoint;
+ m_externalHostName = externalUri;
+ }
+
+ public SimpleRegionInfo(uint regionLocX, uint regionLocY, string externalUri, uint port)
+ {
+ m_regionLocX = regionLocX;
+ m_regionLocY = regionLocY;
+
+ m_externalHostName = externalUri;
+
+ m_internalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int) port);
+ }
+
+ public SimpleRegionInfo(RegionInfo ConvertFrom)
+ {
+ m_regionName = ConvertFrom.RegionName;
+ m_regionLocX = ConvertFrom.RegionLocX;
+ m_regionLocY = ConvertFrom.RegionLocY;
+ m_internalEndPoint = ConvertFrom.InternalEndPoint;
+ m_externalHostName = ConvertFrom.ExternalHostName;
+ m_remotingPort = ConvertFrom.RemotingPort;
+ m_httpPort = ConvertFrom.HttpPort;
+ m_allow_alternate_ports = ConvertFrom.m_allow_alternate_ports;
+ RemotingAddress = ConvertFrom.RemotingAddress;
+ RegionID = UUID.Zero;
+ ServerURI = ConvertFrom.ServerURI;
+ }
+
+ public uint RemotingPort
+ {
+ get { return m_remotingPort; }
+ set { m_remotingPort = value; }
+ }
+
+ ///
+ /// This accessor can throw all the exceptions that Dns.GetHostAddresses can throw.
+ ///
+ /// XXX Isn't this really doing too much to be a simple getter, rather than an explict method?
+ ///
+ public IPEndPoint ExternalEndPoint
+ {
+ get
+ {
+ // Old one defaults to IPv6
+ //return new IPEndPoint(Dns.GetHostAddresses(m_externalHostName)[0], m_internalEndPoint.Port);
+
+ IPAddress ia = null;
+ // If it is already an IP, don't resolve it - just return directly
+ if (IPAddress.TryParse(m_externalHostName, out ia))
+ return new IPEndPoint(ia, m_internalEndPoint.Port);
+
+ // Reset for next check
+ ia = null;
+ try
+ {
+ foreach (IPAddress Adr in Dns.GetHostAddresses(m_externalHostName))
+ {
+ if (ia == null)
+ ia = Adr;
+
+ if (Adr.AddressFamily == AddressFamily.InterNetwork)
+ {
+ ia = Adr;
+ break;
+ }
+ }
+ }
+ catch (SocketException e)
+ {
+ throw new Exception(
+ "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" +
+ e + "' attached to this exception", e);
+ }
+
+ return new IPEndPoint(ia, m_internalEndPoint.Port);
+ }
+
+ set { m_externalHostName = value.ToString(); }
+ }
+
+ public string ExternalHostName
+ {
+ get { return m_externalHostName; }
+ set { m_externalHostName = value; }
+ }
+
+ public IPEndPoint InternalEndPoint
+ {
+ get { return m_internalEndPoint; }
+ set { m_internalEndPoint = value; }
+ }
+
+ public uint RegionLocX
+ {
+ get { return m_regionLocX.Value; }
+ set { m_regionLocX = value; }
+ }
+
+ public uint RegionLocY
+ {
+ get { return m_regionLocY.Value; }
+ set { m_regionLocY = value; }
+ }
+
+ public ulong RegionHandle
+ {
+ get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); }
+ }
+
+ public int getInternalEndPointPort()
+ {
+ return m_internalEndPoint.Port;
+ }
+
+ public Dictionary ToKeyValuePairs()
+ {
+ Dictionary kvp = new Dictionary();
+ kvp["uuid"] = RegionID.ToString();
+ kvp["locX"] = RegionLocX.ToString();
+ kvp["locY"] = RegionLocY.ToString();
+ kvp["external_ip_address"] = ExternalEndPoint.Address.ToString();
+ kvp["external_port"] = ExternalEndPoint.Port.ToString();
+ kvp["external_host_name"] = ExternalHostName;
+ kvp["http_port"] = HttpPort.ToString();
+ kvp["internal_ip_address"] = InternalEndPoint.Address.ToString();
+ kvp["internal_port"] = InternalEndPoint.Port.ToString();
+ kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
+ kvp["server_uri"] = ServerURI;
+
+ return kvp;
+ }
+
+ public SimpleRegionInfo(Dictionary kvp)
+ {
+ if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null))
+ {
+ int port = 0;
+ Int32.TryParse((string)kvp["external_port"], out port);
+ IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
+ ExternalEndPoint = ep;
+ }
+ else
+ ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
+
+ if (kvp["external_host_name"] != null)
+ ExternalHostName = (string)kvp["external_host_name"];
+
+ if (kvp["http_port"] != null)
+ {
+ UInt32 port = 0;
+ UInt32.TryParse((string)kvp["http_port"], out port);
+ HttpPort = port;
+ }
+
+ if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null))
+ {
+ int port = 0;
+ Int32.TryParse((string)kvp["internal_port"], out port);
+ IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port);
+ InternalEndPoint = ep;
+ }
+ else
+ InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
+
+ if (kvp["alternate_ports"] != null)
+ {
+ bool alts = false;
+ Boolean.TryParse((string)kvp["alternate_ports"], out alts);
+ m_allow_alternate_ports = alts;
+ }
+
+ if (kvp["server_uri"] != null)
+ ServerURI = (string)kvp["server_uri"];
+ }
+ }
+
public class RegionInfo
{
// private static readonly log4net.ILog m_log
@@ -69,6 +356,7 @@ namespace OpenSim.Framework
private bool m_clampPrimSize = false;
private int m_objectCapacity = 0;
private string m_regionType = String.Empty;
+ private RegionLightShareData m_windlight = new RegionLightShareData();
protected uint m_httpPort;
protected string m_serverURI;
protected string m_regionName = String.Empty;
@@ -207,6 +495,21 @@ namespace OpenSim.Framework
set { m_regionSettings = value; }
}
+ public RegionLightShareData WindlightSettings
+ {
+ get
+ {
+ if (m_windlight == null)
+ {
+ m_windlight = new RegionLightShareData();
+ }
+
+ return m_windlight;
+ }
+
+ set { m_windlight = value; }
+ }
+
public int NonphysPrimMax
{
get { return m_nonphysPrimMax; }
--
cgit v1.1