diff options
Diffstat (limited to '')
8 files changed, 615 insertions, 615 deletions
diff --git a/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml b/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml index 972f795..7735826 100644 --- a/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml | |||
@@ -1,12 +1,12 @@ | |||
1 | <Addin id="WindModule.Default.WindModels" version="1.0"> | 1 | <Addin id="WindModule.Default.WindModels" version="1.0"> |
2 | <Runtime> | 2 | <Runtime> |
3 | <Import assembly="OpenSim.Region.CoreModules.dll"/> | 3 | <Import assembly="OpenSim.Region.CoreModules.dll"/> |
4 | </Runtime> | 4 | </Runtime> |
5 | <Dependencies> | 5 | <Dependencies> |
6 | <Addin id="OpenSim" version="0.5" /> | 6 | <Addin id="OpenSim" version="0.5" /> |
7 | </Dependencies> | 7 | </Dependencies> |
8 | <Extension path = "/OpenSim/WindModule"> | 8 | <Extension path = "/OpenSim/WindModule"> |
9 | <WindModel id="ConfigurableWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.ConfigurableWind" /> | 9 | <WindModel id="ConfigurableWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.ConfigurableWind" /> |
10 | <WindModel id="SimpleRandomWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.SimpleRandomWind" /> | 10 | <WindModel id="SimpleRandomWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.SimpleRandomWind" /> |
11 | </Extension> | 11 | </Extension> |
12 | </Addin> | 12 | </Addin> |
diff --git a/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs b/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs index 29b0ed5..6b495da 100644 --- a/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs +++ b/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs | |||
@@ -1,56 +1,56 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | 3 | ||
4 | using Nini.Config; | 4 | using Nini.Config; |
5 | using OpenSim.Framework; | 5 | using OpenSim.Framework; |
6 | using OpenMetaverse; | 6 | using OpenMetaverse; |
7 | using OpenSim.Region.Framework.Scenes; | 7 | using OpenSim.Region.Framework.Scenes; |
8 | 8 | ||
9 | namespace OpenSim.Region.CoreModules.World.Wind | 9 | namespace OpenSim.Region.CoreModules.World.Wind |
10 | { | 10 | { |
11 | public interface IWindModelPlugin : IPlugin | 11 | public interface IWindModelPlugin : IPlugin |
12 | { | 12 | { |
13 | /// <summary> | 13 | /// <summary> |
14 | /// Brief description of this plugin's wind model | 14 | /// Brief description of this plugin's wind model |
15 | /// </summary> | 15 | /// </summary> |
16 | string Description { get; } | 16 | string Description { get; } |
17 | 17 | ||
18 | /// <summary> | 18 | /// <summary> |
19 | /// Provides access to the wind configuration, if any. | 19 | /// Provides access to the wind configuration, if any. |
20 | /// </summary> | 20 | /// </summary> |
21 | void WindConfig(Scene scene, IConfig windConfig); | 21 | void WindConfig(Scene scene, IConfig windConfig); |
22 | 22 | ||
23 | /// <summary> | 23 | /// <summary> |
24 | /// Update wind. | 24 | /// Update wind. |
25 | /// </summary> | 25 | /// </summary> |
26 | void WindUpdate(uint frame); | 26 | void WindUpdate(uint frame); |
27 | 27 | ||
28 | /// <summary> | 28 | /// <summary> |
29 | /// Returns the wind vector at the given local region coordinates. | 29 | /// Returns the wind vector at the given local region coordinates. |
30 | /// </summary> | 30 | /// </summary> |
31 | Vector3 WindSpeed(float x, float y, float z); | 31 | Vector3 WindSpeed(float x, float y, float z); |
32 | 32 | ||
33 | /// <summary> | 33 | /// <summary> |
34 | /// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers | 34 | /// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers |
35 | /// </summary> | 35 | /// </summary> |
36 | /// <returns>Must return a Vector2[256]</returns> | 36 | /// <returns>Must return a Vector2[256]</returns> |
37 | Vector2[] WindLLClientArray(); | 37 | Vector2[] WindLLClientArray(); |
38 | 38 | ||
39 | /// <summary> | 39 | /// <summary> |
40 | /// Retrieve a list of parameter/description pairs. | 40 | /// Retrieve a list of parameter/description pairs. |
41 | /// </summary> | 41 | /// </summary> |
42 | /// <returns></returns> | 42 | /// <returns></returns> |
43 | Dictionary<string, string> WindParams(); | 43 | Dictionary<string, string> WindParams(); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Set the specified parameter | 46 | /// Set the specified parameter |
47 | /// </summary> | 47 | /// </summary> |
48 | void WindParamSet(string param, float value); | 48 | void WindParamSet(string param, float value); |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Get the specified parameter | 51 | /// Get the specified parameter |
52 | /// </summary> | 52 | /// </summary> |
53 | float WindParamGet(string param); | 53 | float WindParamGet(string param); |
54 | 54 | ||
55 | } | 55 | } |
56 | } | 56 | } |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs index 2f5cc31..2a0bb73 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs | |||
@@ -1,211 +1,211 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Reflection; | 3 | using System.Reflection; |
4 | 4 | ||
5 | using log4net; | 5 | using log4net; |
6 | using OpenMetaverse; | 6 | using OpenMetaverse; |
7 | 7 | ||
8 | using OpenSim.Region.CoreModules.World.Wind; | 8 | using OpenSim.Region.CoreModules.World.Wind; |
9 | 9 | ||
10 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins | 10 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins |
11 | { | 11 | { |
12 | class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin | 12 | class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin |
13 | { | 13 | { |
14 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 14 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
15 | 15 | ||
16 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; | 16 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; |
17 | private Random m_rndnums = new Random(Environment.TickCount); | 17 | private Random m_rndnums = new Random(Environment.TickCount); |
18 | 18 | ||
19 | private float m_avgStrength = 5.0f; // Average magnitude of the wind vector | 19 | private float m_avgStrength = 5.0f; // Average magnitude of the wind vector |
20 | private float m_avgDirection = 0.0f; // Average direction of the wind in degrees | 20 | private float m_avgDirection = 0.0f; // Average direction of the wind in degrees |
21 | private float m_varStrength = 5.0f; // Max Strength Variance | 21 | private float m_varStrength = 5.0f; // Max Strength Variance |
22 | private float m_varDirection = 30.0f;// Max Direction Variance | 22 | private float m_varDirection = 30.0f;// Max Direction Variance |
23 | private float m_rateChange = 1.0f; // | 23 | private float m_rateChange = 1.0f; // |
24 | 24 | ||
25 | private Vector2 m_curPredominateWind = new Vector2(); | 25 | private Vector2 m_curPredominateWind = new Vector2(); |
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | #region IPlugin Members | 29 | #region IPlugin Members |
30 | 30 | ||
31 | public string Version | 31 | public string Version |
32 | { | 32 | { |
33 | get { return "1.0.0.0"; } | 33 | get { return "1.0.0.0"; } |
34 | } | 34 | } |
35 | 35 | ||
36 | public string Name | 36 | public string Name |
37 | { | 37 | { |
38 | get { return "ConfigurableWind"; } | 38 | get { return "ConfigurableWind"; } |
39 | } | 39 | } |
40 | 40 | ||
41 | public void Initialise() | 41 | public void Initialise() |
42 | { | 42 | { |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | #endregion | 46 | #endregion |
47 | 47 | ||
48 | #region IDisposable Members | 48 | #region IDisposable Members |
49 | 49 | ||
50 | public void Dispose() | 50 | public void Dispose() |
51 | { | 51 | { |
52 | m_windSpeeds = null; | 52 | m_windSpeeds = null; |
53 | } | 53 | } |
54 | 54 | ||
55 | #endregion | 55 | #endregion |
56 | 56 | ||
57 | #region IWindModelPlugin Members | 57 | #region IWindModelPlugin Members |
58 | 58 | ||
59 | public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) | 59 | public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) |
60 | { | 60 | { |
61 | if( windConfig != null ) | 61 | if( windConfig != null ) |
62 | { | 62 | { |
63 | // Uses strength value if avg_strength not specified | 63 | // Uses strength value if avg_strength not specified |
64 | m_avgStrength = windConfig.GetFloat("strength", 5.0F); | 64 | m_avgStrength = windConfig.GetFloat("strength", 5.0F); |
65 | m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F); | 65 | m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F); |
66 | 66 | ||
67 | m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F); | 67 | m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F); |
68 | m_varStrength = windConfig.GetFloat("var_strength", 5.0F); | 68 | m_varStrength = windConfig.GetFloat("var_strength", 5.0F); |
69 | m_varDirection = windConfig.GetFloat("var_direction", 30.0F); | 69 | m_varDirection = windConfig.GetFloat("var_direction", 30.0F); |
70 | m_rateChange = windConfig.GetFloat("rate_change", 1.0F); | 70 | m_rateChange = windConfig.GetFloat("rate_change", 1.0F); |
71 | 71 | ||
72 | LogSettings(); | 72 | LogSettings(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | public void WindUpdate(uint frame) | 76 | public void WindUpdate(uint frame) |
77 | { | 77 | { |
78 | double avgAng = m_avgDirection * (Math.PI/180.0f); | 78 | double avgAng = m_avgDirection * (Math.PI/180.0f); |
79 | double varDir = m_varDirection * (Math.PI/180.0f); | 79 | double varDir = m_varDirection * (Math.PI/180.0f); |
80 | 80 | ||
81 | // Prevailing wind algorithm | 81 | // Prevailing wind algorithm |
82 | // Inspired by Kanker Greenacre | 82 | // Inspired by Kanker Greenacre |
83 | 83 | ||
84 | // TODO: | 84 | // TODO: |
85 | // * This should probably be based on in-world time. | 85 | // * This should probably be based on in-world time. |
86 | // * should probably move all these local variables to class members and constants | 86 | // * should probably move all these local variables to class members and constants |
87 | double time = DateTime.Now.TimeOfDay.Seconds / 86400; | 87 | double time = DateTime.Now.TimeOfDay.Seconds / 86400; |
88 | 88 | ||
89 | double theta = time * (2 * Math.PI) * m_rateChange; | 89 | double theta = time * (2 * Math.PI) * m_rateChange; |
90 | 90 | ||
91 | double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4); | 91 | double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4); |
92 | 92 | ||
93 | double windDir = avgAng + (varDir * offset); | 93 | double windDir = avgAng + (varDir * offset); |
94 | 94 | ||
95 | offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); | 95 | offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); |
96 | double windSpeed = m_avgStrength + (m_varStrength * offset); | 96 | double windSpeed = m_avgStrength + (m_varStrength * offset); |
97 | 97 | ||
98 | if (windSpeed<0) | 98 | if (windSpeed<0) |
99 | windSpeed=0; | 99 | windSpeed=0; |
100 | 100 | ||
101 | 101 | ||
102 | 102 | ||
103 | m_curPredominateWind.X = (float)Math.Cos(windDir); | 103 | m_curPredominateWind.X = (float)Math.Cos(windDir); |
104 | m_curPredominateWind.Y = (float)Math.Sin(windDir); | 104 | m_curPredominateWind.Y = (float)Math.Sin(windDir); |
105 | 105 | ||
106 | m_curPredominateWind.Normalize(); | 106 | m_curPredominateWind.Normalize(); |
107 | m_curPredominateWind.X *= (float)windSpeed; | 107 | m_curPredominateWind.X *= (float)windSpeed; |
108 | m_curPredominateWind.Y *= (float)windSpeed; | 108 | m_curPredominateWind.Y *= (float)windSpeed; |
109 | 109 | ||
110 | for (int y = 0; y < 16; y++) | 110 | for (int y = 0; y < 16; y++) |
111 | { | 111 | { |
112 | for (int x = 0; x < 16; x++) | 112 | for (int x = 0; x < 16; x++) |
113 | { | 113 | { |
114 | m_windSpeeds[y * 16 + x] = m_curPredominateWind; | 114 | m_windSpeeds[y * 16 + x] = m_curPredominateWind; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | public Vector3 WindSpeed(float fX, float fY, float fZ) | 119 | public Vector3 WindSpeed(float fX, float fY, float fZ) |
120 | { | 120 | { |
121 | return new Vector3(m_curPredominateWind, 0.0f); | 121 | return new Vector3(m_curPredominateWind, 0.0f); |
122 | } | 122 | } |
123 | 123 | ||
124 | public Vector2[] WindLLClientArray() | 124 | public Vector2[] WindLLClientArray() |
125 | { | 125 | { |
126 | return m_windSpeeds; | 126 | return m_windSpeeds; |
127 | } | 127 | } |
128 | 128 | ||
129 | public string Description | 129 | public string Description |
130 | { | 130 | { |
131 | get | 131 | get |
132 | { | 132 | { |
133 | return "Provides a predominate wind direction that can change within configured variances for direction and speed."; | 133 | return "Provides a predominate wind direction that can change within configured variances for direction and speed."; |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | public System.Collections.Generic.Dictionary<string, string> WindParams() | 137 | public System.Collections.Generic.Dictionary<string, string> WindParams() |
138 | { | 138 | { |
139 | Dictionary<string, string> Params = new Dictionary<string, string>(); | 139 | Dictionary<string, string> Params = new Dictionary<string, string>(); |
140 | 140 | ||
141 | Params.Add("avgStrength", "average wind strength"); | 141 | Params.Add("avgStrength", "average wind strength"); |
142 | Params.Add("avgDirection", "average wind direction in degrees"); | 142 | Params.Add("avgDirection", "average wind direction in degrees"); |
143 | Params.Add("varStrength", "allowable variance in wind strength"); | 143 | Params.Add("varStrength", "allowable variance in wind strength"); |
144 | Params.Add("varDirection", "allowable variance in wind direction in +/- degrees"); | 144 | Params.Add("varDirection", "allowable variance in wind direction in +/- degrees"); |
145 | Params.Add("rateChange", "rate of change"); | 145 | Params.Add("rateChange", "rate of change"); |
146 | 146 | ||
147 | return Params; | 147 | return Params; |
148 | } | 148 | } |
149 | 149 | ||
150 | public void WindParamSet(string param, float value) | 150 | public void WindParamSet(string param, float value) |
151 | { | 151 | { |
152 | switch (param) | 152 | switch (param) |
153 | { | 153 | { |
154 | case "avgStrength": | 154 | case "avgStrength": |
155 | m_avgStrength = value; | 155 | m_avgStrength = value; |
156 | break; | 156 | break; |
157 | case "avgDirection": | 157 | case "avgDirection": |
158 | m_avgDirection = value; | 158 | m_avgDirection = value; |
159 | break; | 159 | break; |
160 | case "varStrength": | 160 | case "varStrength": |
161 | m_varStrength = value; | 161 | m_varStrength = value; |
162 | break; | 162 | break; |
163 | case "varDirection": | 163 | case "varDirection": |
164 | m_varDirection = value; | 164 | m_varDirection = value; |
165 | break; | 165 | break; |
166 | case "rateChange": | 166 | case "rateChange": |
167 | m_rateChange = value; | 167 | m_rateChange = value; |
168 | break; | 168 | break; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | public float WindParamGet(string param) | 172 | public float WindParamGet(string param) |
173 | { | 173 | { |
174 | switch (param) | 174 | switch (param) |
175 | { | 175 | { |
176 | case "avgStrength": | 176 | case "avgStrength": |
177 | return m_avgStrength; | 177 | return m_avgStrength; |
178 | case "avgDirection": | 178 | case "avgDirection": |
179 | return m_avgDirection; | 179 | return m_avgDirection; |
180 | case "varStrength": | 180 | case "varStrength": |
181 | return m_varStrength; | 181 | return m_varStrength; |
182 | case "varDirection": | 182 | case "varDirection": |
183 | return m_varDirection; | 183 | return m_varDirection; |
184 | case "rateChange": | 184 | case "rateChange": |
185 | return m_rateChange; | 185 | return m_rateChange; |
186 | default: | 186 | default: |
187 | throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); | 187 | throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); |
188 | 188 | ||
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | 193 | ||
194 | #endregion | 194 | #endregion |
195 | 195 | ||
196 | 196 | ||
197 | private void LogSettings() | 197 | private void LogSettings() |
198 | { | 198 | { |
199 | m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength); | 199 | m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength); |
200 | m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection); | 200 | m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection); |
201 | m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength); | 201 | m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength); |
202 | m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection); | 202 | m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection); |
203 | m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange); | 203 | m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange); |
204 | } | 204 | } |
205 | 205 | ||
206 | #region IWindModelPlugin Members | 206 | #region IWindModelPlugin Members |
207 | 207 | ||
208 | 208 | ||
209 | #endregion | 209 | #endregion |
210 | } | 210 | } |
211 | } | 211 | } |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs index 040a3c4..837d6e7 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |||
@@ -1,139 +1,139 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | 3 | ||
4 | using OpenMetaverse; | 4 | using OpenMetaverse; |
5 | 5 | ||
6 | 6 | ||
7 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins | 7 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins |
8 | { | 8 | { |
9 | class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin | 9 | class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin |
10 | { | 10 | { |
11 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; | 11 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; |
12 | private float m_strength = 1.0f; | 12 | private float m_strength = 1.0f; |
13 | private Random m_rndnums = new Random(Environment.TickCount); | 13 | private Random m_rndnums = new Random(Environment.TickCount); |
14 | 14 | ||
15 | 15 | ||
16 | #region IPlugin Members | 16 | #region IPlugin Members |
17 | 17 | ||
18 | public string Version | 18 | public string Version |
19 | { | 19 | { |
20 | get { return "1.0.0.0"; } | 20 | get { return "1.0.0.0"; } |
21 | } | 21 | } |
22 | 22 | ||
23 | public string Name | 23 | public string Name |
24 | { | 24 | { |
25 | get { return "SimpleRandomWind"; } | 25 | get { return "SimpleRandomWind"; } |
26 | } | 26 | } |
27 | 27 | ||
28 | public void Initialise() | 28 | public void Initialise() |
29 | { | 29 | { |
30 | 30 | ||
31 | } | 31 | } |
32 | 32 | ||
33 | #endregion | 33 | #endregion |
34 | 34 | ||
35 | #region IDisposable Members | 35 | #region IDisposable Members |
36 | 36 | ||
37 | public void Dispose() | 37 | public void Dispose() |
38 | { | 38 | { |
39 | m_windSpeeds = null; | 39 | m_windSpeeds = null; |
40 | } | 40 | } |
41 | 41 | ||
42 | #endregion | 42 | #endregion |
43 | 43 | ||
44 | #region IWindModelPlugin Members | 44 | #region IWindModelPlugin Members |
45 | 45 | ||
46 | public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) | 46 | public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) |
47 | { | 47 | { |
48 | if( windConfig != null ) | 48 | if( windConfig != null ) |
49 | { | 49 | { |
50 | if( windConfig.Contains("strength") ) | 50 | if( windConfig.Contains("strength") ) |
51 | { | 51 | { |
52 | m_strength = windConfig.GetFloat("strength", 1.0F); | 52 | m_strength = windConfig.GetFloat("strength", 1.0F); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | 56 | ||
57 | public void WindUpdate(uint frame) | 57 | public void WindUpdate(uint frame) |
58 | { | 58 | { |
59 | for (int y = 0; y < 16; y++) | 59 | for (int y = 0; y < 16; y++) |
60 | { | 60 | { |
61 | for (int x = 0; x < 16; x++) | 61 | for (int x = 0; x < 16; x++) |
62 | { | 62 | { |
63 | m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 63 | m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
64 | m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 64 | m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
65 | m_windSpeeds[y * 16 + x].X *= m_strength; | 65 | m_windSpeeds[y * 16 + x].X *= m_strength; |
66 | m_windSpeeds[y * 16 + x].Y *= m_strength; | 66 | m_windSpeeds[y * 16 + x].Y *= m_strength; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | public Vector3 WindSpeed(float fX, float fY, float fZ) | 71 | public Vector3 WindSpeed(float fX, float fY, float fZ) |
72 | { | 72 | { |
73 | Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f); | 73 | Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f); |
74 | 74 | ||
75 | int x = (int)fX / 16; | 75 | int x = (int)fX / 16; |
76 | int y = (int)fY / 16; | 76 | int y = (int)fY / 16; |
77 | 77 | ||
78 | if (x < 0) x = 0; | 78 | if (x < 0) x = 0; |
79 | if (x > 15) x = 15; | 79 | if (x > 15) x = 15; |
80 | if (y < 0) y = 0; | 80 | if (y < 0) y = 0; |
81 | if (y > 15) y = 15; | 81 | if (y > 15) y = 15; |
82 | 82 | ||
83 | if (m_windSpeeds != null) | 83 | if (m_windSpeeds != null) |
84 | { | 84 | { |
85 | windVector.X = m_windSpeeds[y * 16 + x].X; | 85 | windVector.X = m_windSpeeds[y * 16 + x].X; |
86 | windVector.Y = m_windSpeeds[y * 16 + x].Y; | 86 | windVector.Y = m_windSpeeds[y * 16 + x].Y; |
87 | } | 87 | } |
88 | 88 | ||
89 | return windVector; | 89 | return windVector; |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | public Vector2[] WindLLClientArray() | 93 | public Vector2[] WindLLClientArray() |
94 | { | 94 | { |
95 | return m_windSpeeds; | 95 | return m_windSpeeds; |
96 | } | 96 | } |
97 | 97 | ||
98 | public string Description | 98 | public string Description |
99 | { | 99 | { |
100 | get | 100 | get |
101 | { | 101 | { |
102 | return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches."; | 102 | return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches."; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | public System.Collections.Generic.Dictionary<string, string> WindParams() | 106 | public System.Collections.Generic.Dictionary<string, string> WindParams() |
107 | { | 107 | { |
108 | Dictionary<string, string> Params = new Dictionary<string, string>(); | 108 | Dictionary<string, string> Params = new Dictionary<string, string>(); |
109 | 109 | ||
110 | Params.Add("strength", "wind strength"); | 110 | Params.Add("strength", "wind strength"); |
111 | 111 | ||
112 | return Params; | 112 | return Params; |
113 | } | 113 | } |
114 | 114 | ||
115 | public void WindParamSet(string param, float value) | 115 | public void WindParamSet(string param, float value) |
116 | { | 116 | { |
117 | switch (param) | 117 | switch (param) |
118 | { | 118 | { |
119 | case "strength": | 119 | case "strength": |
120 | m_strength = value; | 120 | m_strength = value; |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | public float WindParamGet(string param) | 125 | public float WindParamGet(string param) |
126 | { | 126 | { |
127 | switch (param) | 127 | switch (param) |
128 | { | 128 | { |
129 | case "strength": | 129 | case "strength": |
130 | return m_strength; | 130 | return m_strength; |
131 | default: | 131 | default: |
132 | throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); | 132 | throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | #endregion | 136 | #endregion |
137 | 137 | ||
138 | } | 138 | } |
139 | } | 139 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs index feddf67..9ad042e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs | |||
@@ -1,12 +1,12 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using OpenMetaverse; | 2 | using OpenMetaverse; |
3 | 3 | ||
4 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 4 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
5 | { | 5 | { |
6 | public interface IObjectAccessor : ICollection<IObject> | 6 | public interface IObjectAccessor : ICollection<IObject> |
7 | { | 7 | { |
8 | IObject this[int index] { get; } | 8 | IObject this[int index] { get; } |
9 | IObject this[uint index] { get; } | 9 | IObject this[uint index] { get; } |
10 | IObject this[UUID index] { get; } | 10 | IObject this[UUID index] { get; } |
11 | } | 11 | } |
12 | } \ No newline at end of file | 12 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index ad7182e..832050e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs | |||
@@ -1,132 +1,132 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using OpenMetaverse; | 4 | using OpenMetaverse; |
5 | using OpenSim.Region.Framework.Scenes; | 5 | using OpenSim.Region.Framework.Scenes; |
6 | using IEnumerable=System.Collections.IEnumerable; | 6 | using IEnumerable=System.Collections.IEnumerable; |
7 | 7 | ||
8 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 8 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
9 | { | 9 | { |
10 | 10 | ||
11 | internal class IObjEnum : IEnumerator<IObject> | 11 | internal class IObjEnum : IEnumerator<IObject> |
12 | { | 12 | { |
13 | private readonly Scene m_scene; | 13 | private readonly Scene m_scene; |
14 | private readonly IEnumerator<EntityBase> m_sogEnum; | 14 | private readonly IEnumerator<EntityBase> m_sogEnum; |
15 | 15 | ||
16 | public IObjEnum(Scene scene) | 16 | public IObjEnum(Scene scene) |
17 | { | 17 | { |
18 | m_scene = scene; | 18 | m_scene = scene; |
19 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); | 19 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); |
20 | } | 20 | } |
21 | 21 | ||
22 | public void Dispose() | 22 | public void Dispose() |
23 | { | 23 | { |
24 | m_sogEnum.Dispose(); | 24 | m_sogEnum.Dispose(); |
25 | } | 25 | } |
26 | 26 | ||
27 | public bool MoveNext() | 27 | public bool MoveNext() |
28 | { | 28 | { |
29 | return m_sogEnum.MoveNext(); | 29 | return m_sogEnum.MoveNext(); |
30 | } | 30 | } |
31 | 31 | ||
32 | public void Reset() | 32 | public void Reset() |
33 | { | 33 | { |
34 | m_sogEnum.Reset(); | 34 | m_sogEnum.Reset(); |
35 | } | 35 | } |
36 | 36 | ||
37 | public IObject Current | 37 | public IObject Current |
38 | { | 38 | { |
39 | get | 39 | get |
40 | { | 40 | { |
41 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId); | 41 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | object IEnumerator.Current | 45 | object IEnumerator.Current |
46 | { | 46 | { |
47 | get { return Current; } | 47 | get { return Current; } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | public class ObjectAccessor : IObjectAccessor | 51 | public class ObjectAccessor : IObjectAccessor |
52 | { | 52 | { |
53 | private readonly Scene m_scene; | 53 | private readonly Scene m_scene; |
54 | 54 | ||
55 | public ObjectAccessor(Scene scene) | 55 | public ObjectAccessor(Scene scene) |
56 | { | 56 | { |
57 | m_scene = scene; | 57 | m_scene = scene; |
58 | } | 58 | } |
59 | 59 | ||
60 | public IObject this[int index] | 60 | public IObject this[int index] |
61 | { | 61 | { |
62 | get | 62 | get |
63 | { | 63 | { |
64 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); | 64 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | public IObject this[uint index] | 68 | public IObject this[uint index] |
69 | { | 69 | { |
70 | get | 70 | get |
71 | { | 71 | { |
72 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 72 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | public IObject this[UUID index] | 76 | public IObject this[UUID index] |
77 | { | 77 | { |
78 | get | 78 | get |
79 | { | 79 | { |
80 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 80 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | public IEnumerator<IObject> GetEnumerator() | 84 | public IEnumerator<IObject> GetEnumerator() |
85 | { | 85 | { |
86 | return new IObjEnum(m_scene); | 86 | return new IObjEnum(m_scene); |
87 | } | 87 | } |
88 | 88 | ||
89 | IEnumerator IEnumerable.GetEnumerator() | 89 | IEnumerator IEnumerable.GetEnumerator() |
90 | { | 90 | { |
91 | return GetEnumerator(); | 91 | return GetEnumerator(); |
92 | } | 92 | } |
93 | 93 | ||
94 | public void Add(IObject item) | 94 | public void Add(IObject item) |
95 | { | 95 | { |
96 | throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); | 96 | throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); |
97 | } | 97 | } |
98 | 98 | ||
99 | public void Clear() | 99 | public void Clear() |
100 | { | 100 | { |
101 | throw new NotSupportedException("Collection is read-only. TODO FIX."); | 101 | throw new NotSupportedException("Collection is read-only. TODO FIX."); |
102 | } | 102 | } |
103 | 103 | ||
104 | public bool Contains(IObject item) | 104 | public bool Contains(IObject item) |
105 | { | 105 | { |
106 | return m_scene.Entities.ContainsKey(item.LocalID); | 106 | return m_scene.Entities.ContainsKey(item.LocalID); |
107 | } | 107 | } |
108 | 108 | ||
109 | public void CopyTo(IObject[] array, int arrayIndex) | 109 | public void CopyTo(IObject[] array, int arrayIndex) |
110 | { | 110 | { |
111 | for (int i = arrayIndex; i < Count + arrayIndex; i++) | 111 | for (int i = arrayIndex; i < Count + arrayIndex; i++) |
112 | { | 112 | { |
113 | array[i] = this[i - arrayIndex]; | 113 | array[i] = this[i - arrayIndex]; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | public bool Remove(IObject item) | 117 | public bool Remove(IObject item) |
118 | { | 118 | { |
119 | throw new NotSupportedException("Collection is read-only. TODO FIX."); | 119 | throw new NotSupportedException("Collection is read-only. TODO FIX."); |
120 | } | 120 | } |
121 | 121 | ||
122 | public int Count | 122 | public int Count |
123 | { | 123 | { |
124 | get { return m_scene.Entities.Count; } | 124 | get { return m_scene.Entities.Count; } |
125 | } | 125 | } |
126 | 126 | ||
127 | public bool IsReadOnly | 127 | public bool IsReadOnly |
128 | { | 128 | { |
129 | get { return true; } | 129 | get { return true; } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 6011e0b..03432bc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | |||
@@ -1,37 +1,37 @@ | |||
1 | using OpenMetaverse; | 1 | using OpenMetaverse; |
2 | using OpenSim.Region.Framework.Scenes; | 2 | using OpenSim.Region.Framework.Scenes; |
3 | 3 | ||
4 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 4 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
5 | { | 5 | { |
6 | class SPAvatar : IAvatar | 6 | class SPAvatar : IAvatar |
7 | { | 7 | { |
8 | private readonly Scene m_rootScene; | 8 | private readonly Scene m_rootScene; |
9 | private readonly UUID m_ID; | 9 | private readonly UUID m_ID; |
10 | 10 | ||
11 | public SPAvatar(Scene scene, UUID ID) | 11 | public SPAvatar(Scene scene, UUID ID) |
12 | { | 12 | { |
13 | m_rootScene = scene; | 13 | m_rootScene = scene; |
14 | m_ID = ID; | 14 | m_ID = ID; |
15 | } | 15 | } |
16 | 16 | ||
17 | private ScenePresence GetSP() | 17 | private ScenePresence GetSP() |
18 | { | 18 | { |
19 | return m_rootScene.GetScenePresence(m_ID); | 19 | return m_rootScene.GetScenePresence(m_ID); |
20 | } | 20 | } |
21 | 21 | ||
22 | public string Name | 22 | public string Name |
23 | { | 23 | { |
24 | get { return GetSP().Name; } | 24 | get { return GetSP().Name; } |
25 | } | 25 | } |
26 | 26 | ||
27 | public UUID GlobalID | 27 | public UUID GlobalID |
28 | { | 28 | { |
29 | get { return m_ID; } | 29 | get { return m_ID; } |
30 | } | 30 | } |
31 | 31 | ||
32 | public Vector3 Position | 32 | public Vector3 Position |
33 | { | 33 | { |
34 | get { return GetSP().AbsolutePosition; } | 34 | get { return GetSP().AbsolutePosition; } |
35 | } | 35 | } |
36 | } | 36 | } |
37 | } | 37 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index abbef0b..1e266ae 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs | |||
@@ -1,17 +1,17 @@ | |||
1 | using OpenSim.Region.OptionalModules.Scripting.Minimodule; | 1 | using OpenSim.Region.OptionalModules.Scripting.Minimodule; |
2 | 2 | ||
3 | namespace OpenSim | 3 | namespace OpenSim |
4 | { | 4 | { |
5 | class MiniModule : MRMBase | 5 | class MiniModule : MRMBase |
6 | { | 6 | { |
7 | public override void Start() | 7 | public override void Start() |
8 | { | 8 | { |
9 | Host.Console.Info("Hello World!"); | 9 | Host.Console.Info("Hello World!"); |
10 | } | 10 | } |
11 | 11 | ||
12 | public override void Stop() | 12 | public override void Stop() |
13 | { | 13 | { |
14 | 14 | ||
15 | } | 15 | } |
16 | } | 16 | } |
17 | } | 17 | } |