29 using System.Collections.Generic;
30 using System.Reflection;
36 using OpenSim.Region.Framework.Interfaces;
37 using OpenSim.Region.CoreModules.World.Wind;
41 [Extension(Path =
"/OpenSim/WindModule", NodeName =
"WindModel", Id =
"ConfigurableWind")]
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private Vector2[] m_windSpeeds =
new Vector2[16 * 16];
49 private float m_avgStrength = 5.0f;
50 private float m_avgDirection = 0.0f;
51 private float m_varStrength = 5.0f;
52 private float m_varDirection = 30.0f;
53 private float m_rateChange = 1.0f;
55 private Vector2 m_curPredominateWind =
new Vector2();
59 #region IPlugin Members
63 get {
return "1.0.0.0"; }
68 get {
return "ConfigurableWind"; }
78 #region IDisposable Members
87 #region IWindModelPlugin Members
91 if (windConfig != null)
94 m_avgStrength = windConfig.GetFloat(
"strength", 5.0F);
95 m_avgStrength = windConfig.GetFloat(
"avg_strength", 5.0F);
97 m_avgDirection = windConfig.GetFloat(
"avg_direction", 0.0F);
98 m_varStrength = windConfig.GetFloat(
"var_strength", 5.0F);
99 m_varDirection = windConfig.GetFloat(
"var_direction", 30.0F);
100 m_rateChange = windConfig.GetFloat(
"rate_change", 1.0F);
108 double avgAng = m_avgDirection * (Math.PI/180.0f);
109 double varDir = m_varDirection * (Math.PI/180.0f);
117 double time = DateTime.Now.TimeOfDay.Seconds / 86400.0f;
119 double theta = time * (2 * Math.PI) * m_rateChange;
121 double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4);
123 double windDir = avgAng + (varDir * offset);
125 offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3);
126 double windSpeed = m_avgStrength + (m_varStrength * offset);
133 m_curPredominateWind.X = (float)Math.Cos(windDir);
134 m_curPredominateWind.Y = (float)Math.Sin(windDir);
136 m_curPredominateWind.Normalize();
137 m_curPredominateWind.X *= (float)windSpeed;
138 m_curPredominateWind.Y *= (float)windSpeed;
140 for (
int y = 0; y < 16; y++)
142 for (
int x = 0; x < 16; x++)
144 m_windSpeeds[y * 16 + x] = m_curPredominateWind;
151 return new Vector3(m_curPredominateWind, 0.0f);
159 public string Description
163 return "Provides a predominate wind direction that can change within configured variances for direction and speed.";
167 public System.Collections.Generic.Dictionary<string,
string>
WindParams()
169 Dictionary<string, string> Params =
new Dictionary<string, string>();
171 Params.Add(
"avgStrength",
"average wind strength");
172 Params.Add(
"avgDirection",
"average wind direction in degrees");
173 Params.Add(
"varStrength",
"allowable variance in wind strength");
174 Params.Add(
"varDirection",
"allowable variance in wind direction in +/- degrees");
175 Params.Add(
"rateChange",
"rate of change");
185 m_avgStrength = value;
188 m_avgDirection = value;
191 m_varStrength = value;
194 m_varDirection = value;
197 m_rateChange = value;
207 return m_avgStrength;
209 return m_avgDirection;
211 return m_varStrength;
213 return m_varDirection;
217 throw new Exception(
String.Format(
"Unknown {0} parameter {1}",
this.Name, param));
227 private void LogSettings()
229 m_log.InfoFormat(
"[ConfigurableWind] Average Strength : {0}", m_avgStrength);
230 m_log.InfoFormat(
"[ConfigurableWind] Average Direction : {0}", m_avgDirection);
231 m_log.InfoFormat(
"[ConfigurableWind] Varience Strength : {0}", m_varStrength);
232 m_log.InfoFormat(
"[ConfigurableWind] Varience Direction : {0}", m_varDirection);
233 m_log.InfoFormat(
"[ConfigurableWind] Rate Change : {0}", m_rateChange);
236 #region IWindModelPlugin Members
Vector3 WindSpeed(float fX, float fY, float fZ)
Returns the wind vector at the given local region coordinates.
float WindParamGet(string param)
Get the specified parameter
void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig)
void WindUpdate(uint frame)
Update wind.
void WindParamSet(string param, float value)
Set the specified parameter
void Initialise()
Default-initialises the plugin
Interactive OpenSim region server
Vector2[] WindLLClientArray()
Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers
System.Collections.Generic.Dictionary< string, string > WindParams()
Retrieve a list of parameter/description pairs.