Update svn properties.
parent
a1fe54baa0
commit
99cfcf405b
|
@ -1,12 +1,12 @@
|
|||
<Addin id="WindModule.Default.WindModels" version="1.0">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.Region.CoreModules.dll"/>
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/WindModule">
|
||||
<WindModel id="ConfigurableWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.ConfigurableWind" />
|
||||
<WindModel id="SimpleRandomWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.SimpleRandomWind" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
<Addin id="WindModule.Default.WindModels" version="1.0">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.Region.CoreModules.dll"/>
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/WindModule">
|
||||
<WindModel id="ConfigurableWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.ConfigurableWind" />
|
||||
<WindModel id="SimpleRandomWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.SimpleRandomWind" />
|
||||
</Extension>
|
||||
</Addin>
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind
|
||||
{
|
||||
public interface IWindModelPlugin : IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Brief description of this plugin's wind model
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides access to the wind configuration, if any.
|
||||
/// </summary>
|
||||
void WindConfig(Scene scene, IConfig windConfig);
|
||||
|
||||
/// <summary>
|
||||
/// Update wind.
|
||||
/// </summary>
|
||||
void WindUpdate(uint frame);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the wind vector at the given local region coordinates.
|
||||
/// </summary>
|
||||
Vector3 WindSpeed(float x, float y, float z);
|
||||
|
||||
/// <summary>
|
||||
/// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers
|
||||
/// </summary>
|
||||
/// <returns>Must return a Vector2[256]</returns>
|
||||
Vector2[] WindLLClientArray();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list of parameter/description pairs.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Dictionary<string, string> WindParams();
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified parameter
|
||||
/// </summary>
|
||||
void WindParamSet(string param, float value);
|
||||
|
||||
/// <summary>
|
||||
/// Get the specified parameter
|
||||
/// </summary>
|
||||
float WindParamGet(string param);
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind
|
||||
{
|
||||
public interface IWindModelPlugin : IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Brief description of this plugin's wind model
|
||||
/// </summary>
|
||||
string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Provides access to the wind configuration, if any.
|
||||
/// </summary>
|
||||
void WindConfig(Scene scene, IConfig windConfig);
|
||||
|
||||
/// <summary>
|
||||
/// Update wind.
|
||||
/// </summary>
|
||||
void WindUpdate(uint frame);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the wind vector at the given local region coordinates.
|
||||
/// </summary>
|
||||
Vector3 WindSpeed(float x, float y, float z);
|
||||
|
||||
/// <summary>
|
||||
/// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers
|
||||
/// </summary>
|
||||
/// <returns>Must return a Vector2[256]</returns>
|
||||
Vector2[] WindLLClientArray();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list of parameter/description pairs.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Dictionary<string, string> WindParams();
|
||||
|
||||
/// <summary>
|
||||
/// Set the specified parameter
|
||||
/// </summary>
|
||||
void WindParamSet(string param, float value);
|
||||
|
||||
/// <summary>
|
||||
/// Get the specified parameter
|
||||
/// </summary>
|
||||
float WindParamGet(string param);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,211 +1,211 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Region.CoreModules.World.Wind;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
{
|
||||
class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Vector2[] m_windSpeeds = new Vector2[16 * 16];
|
||||
private Random m_rndnums = new Random(Environment.TickCount);
|
||||
|
||||
private float m_avgStrength = 5.0f; // Average magnitude of the wind vector
|
||||
private float m_avgDirection = 0.0f; // Average direction of the wind in degrees
|
||||
private float m_varStrength = 5.0f; // Max Strength Variance
|
||||
private float m_varDirection = 30.0f;// Max Direction Variance
|
||||
private float m_rateChange = 1.0f; //
|
||||
|
||||
private Vector2 m_curPredominateWind = new Vector2();
|
||||
|
||||
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0.0"; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "ConfigurableWind"; }
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_windSpeeds = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig)
|
||||
{
|
||||
if( windConfig != null )
|
||||
{
|
||||
// Uses strength value if avg_strength not specified
|
||||
m_avgStrength = windConfig.GetFloat("strength", 5.0F);
|
||||
m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F);
|
||||
|
||||
m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F);
|
||||
m_varStrength = windConfig.GetFloat("var_strength", 5.0F);
|
||||
m_varDirection = windConfig.GetFloat("var_direction", 30.0F);
|
||||
m_rateChange = windConfig.GetFloat("rate_change", 1.0F);
|
||||
|
||||
LogSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
{
|
||||
double avgAng = m_avgDirection * (Math.PI/180.0f);
|
||||
double varDir = m_varDirection * (Math.PI/180.0f);
|
||||
|
||||
// Prevailing wind algorithm
|
||||
// Inspired by Kanker Greenacre
|
||||
|
||||
// TODO:
|
||||
// * This should probably be based on in-world time.
|
||||
// * should probably move all these local variables to class members and constants
|
||||
double time = DateTime.Now.TimeOfDay.Seconds / 86400;
|
||||
|
||||
double theta = time * (2 * Math.PI) * m_rateChange;
|
||||
|
||||
double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4);
|
||||
|
||||
double windDir = avgAng + (varDir * offset);
|
||||
|
||||
offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3);
|
||||
double windSpeed = m_avgStrength + (m_varStrength * offset);
|
||||
|
||||
if (windSpeed<0)
|
||||
windSpeed=0;
|
||||
|
||||
|
||||
|
||||
m_curPredominateWind.X = (float)Math.Cos(windDir);
|
||||
m_curPredominateWind.Y = (float)Math.Sin(windDir);
|
||||
|
||||
m_curPredominateWind.Normalize();
|
||||
m_curPredominateWind.X *= (float)windSpeed;
|
||||
m_curPredominateWind.Y *= (float)windSpeed;
|
||||
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
m_windSpeeds[y * 16 + x] = m_curPredominateWind;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
{
|
||||
return new Vector3(m_curPredominateWind, 0.0f);
|
||||
}
|
||||
|
||||
public Vector2[] WindLLClientArray()
|
||||
{
|
||||
return m_windSpeeds;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Provides a predominate wind direction that can change within configured variances for direction and speed.";
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<string, string> WindParams()
|
||||
{
|
||||
Dictionary<string, string> Params = new Dictionary<string, string>();
|
||||
|
||||
Params.Add("avgStrength", "average wind strength");
|
||||
Params.Add("avgDirection", "average wind direction in degrees");
|
||||
Params.Add("varStrength", "allowable variance in wind strength");
|
||||
Params.Add("varDirection", "allowable variance in wind direction in +/- degrees");
|
||||
Params.Add("rateChange", "rate of change");
|
||||
|
||||
return Params;
|
||||
}
|
||||
|
||||
public void WindParamSet(string param, float value)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "avgStrength":
|
||||
m_avgStrength = value;
|
||||
break;
|
||||
case "avgDirection":
|
||||
m_avgDirection = value;
|
||||
break;
|
||||
case "varStrength":
|
||||
m_varStrength = value;
|
||||
break;
|
||||
case "varDirection":
|
||||
m_varDirection = value;
|
||||
break;
|
||||
case "rateChange":
|
||||
m_rateChange = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public float WindParamGet(string param)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "avgStrength":
|
||||
return m_avgStrength;
|
||||
case "avgDirection":
|
||||
return m_avgDirection;
|
||||
case "varStrength":
|
||||
return m_varStrength;
|
||||
case "varDirection":
|
||||
return m_varDirection;
|
||||
case "rateChange":
|
||||
return m_rateChange;
|
||||
default:
|
||||
throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void LogSettings()
|
||||
{
|
||||
m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength);
|
||||
m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection);
|
||||
m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength);
|
||||
m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection);
|
||||
m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange);
|
||||
}
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Region.CoreModules.World.Wind;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
{
|
||||
class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Vector2[] m_windSpeeds = new Vector2[16 * 16];
|
||||
private Random m_rndnums = new Random(Environment.TickCount);
|
||||
|
||||
private float m_avgStrength = 5.0f; // Average magnitude of the wind vector
|
||||
private float m_avgDirection = 0.0f; // Average direction of the wind in degrees
|
||||
private float m_varStrength = 5.0f; // Max Strength Variance
|
||||
private float m_varDirection = 30.0f;// Max Direction Variance
|
||||
private float m_rateChange = 1.0f; //
|
||||
|
||||
private Vector2 m_curPredominateWind = new Vector2();
|
||||
|
||||
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0.0"; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "ConfigurableWind"; }
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_windSpeeds = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig)
|
||||
{
|
||||
if( windConfig != null )
|
||||
{
|
||||
// Uses strength value if avg_strength not specified
|
||||
m_avgStrength = windConfig.GetFloat("strength", 5.0F);
|
||||
m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F);
|
||||
|
||||
m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F);
|
||||
m_varStrength = windConfig.GetFloat("var_strength", 5.0F);
|
||||
m_varDirection = windConfig.GetFloat("var_direction", 30.0F);
|
||||
m_rateChange = windConfig.GetFloat("rate_change", 1.0F);
|
||||
|
||||
LogSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
{
|
||||
double avgAng = m_avgDirection * (Math.PI/180.0f);
|
||||
double varDir = m_varDirection * (Math.PI/180.0f);
|
||||
|
||||
// Prevailing wind algorithm
|
||||
// Inspired by Kanker Greenacre
|
||||
|
||||
// TODO:
|
||||
// * This should probably be based on in-world time.
|
||||
// * should probably move all these local variables to class members and constants
|
||||
double time = DateTime.Now.TimeOfDay.Seconds / 86400;
|
||||
|
||||
double theta = time * (2 * Math.PI) * m_rateChange;
|
||||
|
||||
double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4);
|
||||
|
||||
double windDir = avgAng + (varDir * offset);
|
||||
|
||||
offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3);
|
||||
double windSpeed = m_avgStrength + (m_varStrength * offset);
|
||||
|
||||
if (windSpeed<0)
|
||||
windSpeed=0;
|
||||
|
||||
|
||||
|
||||
m_curPredominateWind.X = (float)Math.Cos(windDir);
|
||||
m_curPredominateWind.Y = (float)Math.Sin(windDir);
|
||||
|
||||
m_curPredominateWind.Normalize();
|
||||
m_curPredominateWind.X *= (float)windSpeed;
|
||||
m_curPredominateWind.Y *= (float)windSpeed;
|
||||
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
m_windSpeeds[y * 16 + x] = m_curPredominateWind;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
{
|
||||
return new Vector3(m_curPredominateWind, 0.0f);
|
||||
}
|
||||
|
||||
public Vector2[] WindLLClientArray()
|
||||
{
|
||||
return m_windSpeeds;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Provides a predominate wind direction that can change within configured variances for direction and speed.";
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<string, string> WindParams()
|
||||
{
|
||||
Dictionary<string, string> Params = new Dictionary<string, string>();
|
||||
|
||||
Params.Add("avgStrength", "average wind strength");
|
||||
Params.Add("avgDirection", "average wind direction in degrees");
|
||||
Params.Add("varStrength", "allowable variance in wind strength");
|
||||
Params.Add("varDirection", "allowable variance in wind direction in +/- degrees");
|
||||
Params.Add("rateChange", "rate of change");
|
||||
|
||||
return Params;
|
||||
}
|
||||
|
||||
public void WindParamSet(string param, float value)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "avgStrength":
|
||||
m_avgStrength = value;
|
||||
break;
|
||||
case "avgDirection":
|
||||
m_avgDirection = value;
|
||||
break;
|
||||
case "varStrength":
|
||||
m_varStrength = value;
|
||||
break;
|
||||
case "varDirection":
|
||||
m_varDirection = value;
|
||||
break;
|
||||
case "rateChange":
|
||||
m_rateChange = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public float WindParamGet(string param)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "avgStrength":
|
||||
return m_avgStrength;
|
||||
case "avgDirection":
|
||||
return m_avgDirection;
|
||||
case "varStrength":
|
||||
return m_varStrength;
|
||||
case "varDirection":
|
||||
return m_varDirection;
|
||||
case "rateChange":
|
||||
return m_rateChange;
|
||||
default:
|
||||
throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void LogSettings()
|
||||
{
|
||||
m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength);
|
||||
m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection);
|
||||
m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength);
|
||||
m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection);
|
||||
m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange);
|
||||
}
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,139 +1,139 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
{
|
||||
class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin
|
||||
{
|
||||
private Vector2[] m_windSpeeds = new Vector2[16 * 16];
|
||||
private float m_strength = 1.0f;
|
||||
private Random m_rndnums = new Random(Environment.TickCount);
|
||||
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0.0"; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "SimpleRandomWind"; }
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_windSpeeds = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig)
|
||||
{
|
||||
if( windConfig != null )
|
||||
{
|
||||
if( windConfig.Contains("strength") )
|
||||
{
|
||||
m_strength = windConfig.GetFloat("strength", 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].X *= m_strength;
|
||||
m_windSpeeds[y * 16 + x].Y *= m_strength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
{
|
||||
Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
int x = (int)fX / 16;
|
||||
int y = (int)fY / 16;
|
||||
|
||||
if (x < 0) x = 0;
|
||||
if (x > 15) x = 15;
|
||||
if (y < 0) y = 0;
|
||||
if (y > 15) y = 15;
|
||||
|
||||
if (m_windSpeeds != null)
|
||||
{
|
||||
windVector.X = m_windSpeeds[y * 16 + x].X;
|
||||
windVector.Y = m_windSpeeds[y * 16 + x].Y;
|
||||
}
|
||||
|
||||
return windVector;
|
||||
|
||||
}
|
||||
|
||||
public Vector2[] WindLLClientArray()
|
||||
{
|
||||
return m_windSpeeds;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches.";
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<string, string> WindParams()
|
||||
{
|
||||
Dictionary<string, string> Params = new Dictionary<string, string>();
|
||||
|
||||
Params.Add("strength", "wind strength");
|
||||
|
||||
return Params;
|
||||
}
|
||||
|
||||
public void WindParamSet(string param, float value)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "strength":
|
||||
m_strength = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public float WindParamGet(string param)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "strength":
|
||||
return m_strength;
|
||||
default:
|
||||
throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using OpenMetaverse;
|
||||
|
||||
|
||||
namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
{
|
||||
class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin
|
||||
{
|
||||
private Vector2[] m_windSpeeds = new Vector2[16 * 16];
|
||||
private float m_strength = 1.0f;
|
||||
private Random m_rndnums = new Random(Environment.TickCount);
|
||||
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0.0"; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "SimpleRandomWind"; }
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_windSpeeds = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IWindModelPlugin Members
|
||||
|
||||
public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig)
|
||||
{
|
||||
if( windConfig != null )
|
||||
{
|
||||
if( windConfig.Contains("strength") )
|
||||
{
|
||||
m_strength = windConfig.GetFloat("strength", 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].X *= m_strength;
|
||||
m_windSpeeds[y * 16 + x].Y *= m_strength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
{
|
||||
Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
int x = (int)fX / 16;
|
||||
int y = (int)fY / 16;
|
||||
|
||||
if (x < 0) x = 0;
|
||||
if (x > 15) x = 15;
|
||||
if (y < 0) y = 0;
|
||||
if (y > 15) y = 15;
|
||||
|
||||
if (m_windSpeeds != null)
|
||||
{
|
||||
windVector.X = m_windSpeeds[y * 16 + x].X;
|
||||
windVector.Y = m_windSpeeds[y * 16 + x].Y;
|
||||
}
|
||||
|
||||
return windVector;
|
||||
|
||||
}
|
||||
|
||||
public Vector2[] WindLLClientArray()
|
||||
{
|
||||
return m_windSpeeds;
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches.";
|
||||
}
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Dictionary<string, string> WindParams()
|
||||
{
|
||||
Dictionary<string, string> Params = new Dictionary<string, string>();
|
||||
|
||||
Params.Add("strength", "wind strength");
|
||||
|
||||
return Params;
|
||||
}
|
||||
|
||||
public void WindParamSet(string param, float value)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "strength":
|
||||
m_strength = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public float WindParamGet(string param)
|
||||
{
|
||||
switch (param)
|
||||
{
|
||||
case "strength":
|
||||
return m_strength;
|
||||
default:
|
||||
throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
public interface IObjectAccessor : ICollection<IObject>
|
||||
{
|
||||
IObject this[int index] { get; }
|
||||
IObject this[uint index] { get; }
|
||||
IObject this[UUID index] { get; }
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
public interface IObjectAccessor : ICollection<IObject>
|
||||
{
|
||||
IObject this[int index] { get; }
|
||||
IObject this[uint index] { get; }
|
||||
IObject this[UUID index] { get; }
|
||||
}
|
||||
}
|
|
@ -1,132 +1,132 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using IEnumerable=System.Collections.IEnumerable;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
|
||||
internal class IObjEnum : IEnumerator<IObject>
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
private readonly IEnumerator<EntityBase> m_sogEnum;
|
||||
|
||||
public IObjEnum(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_sogEnum.Dispose();
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return m_sogEnum.MoveNext();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_sogEnum.Reset();
|
||||
}
|
||||
|
||||
public IObject Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_sogEnum.Current.LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get { return Current; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ObjectAccessor : IObjectAccessor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ObjectAccessor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
public IObject this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IObject this[uint index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IObject this[UUID index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<IObject> GetEnumerator()
|
||||
{
|
||||
return new IObjEnum(m_scene);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Add(IObject item)
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible.");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. TODO FIX.");
|
||||
}
|
||||
|
||||
public bool Contains(IObject item)
|
||||
{
|
||||
return m_scene.Entities.ContainsKey(item.LocalID);
|
||||
}
|
||||
|
||||
public void CopyTo(IObject[] array, int arrayIndex)
|
||||
{
|
||||
for (int i = arrayIndex; i < Count + arrayIndex; i++)
|
||||
{
|
||||
array[i] = this[i - arrayIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(IObject item)
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. TODO FIX.");
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return m_scene.Entities.Count; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using IEnumerable=System.Collections.IEnumerable;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
|
||||
internal class IObjEnum : IEnumerator<IObject>
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
private readonly IEnumerator<EntityBase> m_sogEnum;
|
||||
|
||||
public IObjEnum(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
m_sogEnum.Dispose();
|
||||
}
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
return m_sogEnum.MoveNext();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_sogEnum.Reset();
|
||||
}
|
||||
|
||||
public IObject Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_sogEnum.Current.LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get { return Current; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ObjectAccessor : IObjectAccessor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ObjectAccessor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
public IObject this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IObject this[uint index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IObject this[UUID index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return new SOPObject(m_scene, m_scene.Entities[index].LocalId);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<IObject> GetEnumerator()
|
||||
{
|
||||
return new IObjEnum(m_scene);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Add(IObject item)
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible.");
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. TODO FIX.");
|
||||
}
|
||||
|
||||
public bool Contains(IObject item)
|
||||
{
|
||||
return m_scene.Entities.ContainsKey(item.LocalID);
|
||||
}
|
||||
|
||||
public void CopyTo(IObject[] array, int arrayIndex)
|
||||
{
|
||||
for (int i = arrayIndex; i < Count + arrayIndex; i++)
|
||||
{
|
||||
array[i] = this[i - arrayIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(IObject item)
|
||||
{
|
||||
throw new NotSupportedException("Collection is read-only. TODO FIX.");
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return m_scene.Entities.Count; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
class SPAvatar : IAvatar
|
||||
{
|
||||
private readonly Scene m_rootScene;
|
||||
private readonly UUID m_ID;
|
||||
|
||||
public SPAvatar(Scene scene, UUID ID)
|
||||
{
|
||||
m_rootScene = scene;
|
||||
m_ID = ID;
|
||||
}
|
||||
|
||||
private ScenePresence GetSP()
|
||||
{
|
||||
return m_rootScene.GetScenePresence(m_ID);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return GetSP().Name; }
|
||||
}
|
||||
|
||||
public UUID GlobalID
|
||||
{
|
||||
get { return m_ID; }
|
||||
}
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get { return GetSP().AbsolutePosition; }
|
||||
}
|
||||
}
|
||||
}
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
||||
{
|
||||
class SPAvatar : IAvatar
|
||||
{
|
||||
private readonly Scene m_rootScene;
|
||||
private readonly UUID m_ID;
|
||||
|
||||
public SPAvatar(Scene scene, UUID ID)
|
||||
{
|
||||
m_rootScene = scene;
|
||||
m_ID = ID;
|
||||
}
|
||||
|
||||
private ScenePresence GetSP()
|
||||
{
|
||||
return m_rootScene.GetScenePresence(m_ID);
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return GetSP().Name; }
|
||||
}
|
||||
|
||||
public UUID GlobalID
|
||||
{
|
||||
get { return m_ID; }
|
||||
}
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get { return GetSP().AbsolutePosition; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
using OpenSim.Region.OptionalModules.Scripting.Minimodule;
|
||||
|
||||
namespace OpenSim
|
||||
{
|
||||
class MiniModule : MRMBase
|
||||
{
|
||||
public override void Start()
|
||||
{
|
||||
Host.Console.Info("Hello World!");
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using OpenSim.Region.OptionalModules.Scripting.Minimodule;
|
||||
|
||||
namespace OpenSim
|
||||
{
|
||||
class MiniModule : MRMBase
|
||||
{
|
||||
public override void Start()
|
||||
{
|
||||
Host.Console.Info("Hello World!");
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue