diff options
author | Charles Krinke | 2009-03-31 02:33:19 +0000 |
---|---|---|
committer | Charles Krinke | 2009-03-31 02:33:19 +0000 |
commit | 54a27f9f5c556e518c2ba18b9a5494d517dfd041 (patch) | |
tree | 5da9db44878c217e0c1872da0f963d88575ef8ff /OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |
parent | Update svn properties, add copyright header, formatting cleanup. (diff) | |
download | opensim-SC_OLD-54a27f9f5c556e518c2ba18b9a5494d517dfd041.zip opensim-SC_OLD-54a27f9f5c556e518c2ba18b9a5494d517dfd041.tar.gz opensim-SC_OLD-54a27f9f5c556e518c2ba18b9a5494d517dfd041.tar.bz2 opensim-SC_OLD-54a27f9f5c556e518c2ba18b9a5494d517dfd041.tar.xz |
Thank you kindly, MCortez for a patch that:
With some support from HomerH, this patch adds support for Wind
Model plugins via the mono.Addin framework.
* Adds console & OSSL access to Wind Parameters
* Adds plug-in support for custom wind models
* Provides two example Wind Model plug-ins
Documentation for the wind module is temporarily located at http://code.google.com/p/flotsam/wiki/CoreWindModule [^]
-- will move this documentation to http://opensimulator.org [^]
after the patch has been committed.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs new file mode 100644 index 0000000..040a3c4 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |||
@@ -0,0 +1,139 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | |||
4 | using OpenMetaverse; | ||
5 | |||
6 | |||
7 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins | ||
8 | { | ||
9 | class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin | ||
10 | { | ||
11 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; | ||
12 | private float m_strength = 1.0f; | ||
13 | private Random m_rndnums = new Random(Environment.TickCount); | ||
14 | |||
15 | |||
16 | #region IPlugin Members | ||
17 | |||
18 | public string Version | ||
19 | { | ||
20 | get { return "1.0.0.0"; } | ||
21 | } | ||
22 | |||
23 | public string Name | ||
24 | { | ||
25 | get { return "SimpleRandomWind"; } | ||
26 | } | ||
27 | |||
28 | public void Initialise() | ||
29 | { | ||
30 | |||
31 | } | ||
32 | |||
33 | #endregion | ||
34 | |||
35 | #region IDisposable Members | ||
36 | |||
37 | public void Dispose() | ||
38 | { | ||
39 | m_windSpeeds = null; | ||
40 | } | ||
41 | |||
42 | #endregion | ||
43 | |||
44 | #region IWindModelPlugin Members | ||
45 | |||
46 | public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) | ||
47 | { | ||
48 | if( windConfig != null ) | ||
49 | { | ||
50 | if( windConfig.Contains("strength") ) | ||
51 | { | ||
52 | m_strength = windConfig.GetFloat("strength", 1.0F); | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | |||
57 | public void WindUpdate(uint frame) | ||
58 | { | ||
59 | for (int y = 0; y < 16; y++) | ||
60 | { | ||
61 | for (int x = 0; x < 16; x++) | ||
62 | { | ||
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 | ||
65 | m_windSpeeds[y * 16 + x].X *= m_strength; | ||
66 | m_windSpeeds[y * 16 + x].Y *= m_strength; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public Vector3 WindSpeed(float fX, float fY, float fZ) | ||
72 | { | ||
73 | Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f); | ||
74 | |||
75 | int x = (int)fX / 16; | ||
76 | int y = (int)fY / 16; | ||
77 | |||
78 | if (x < 0) x = 0; | ||
79 | if (x > 15) x = 15; | ||
80 | if (y < 0) y = 0; | ||
81 | if (y > 15) y = 15; | ||
82 | |||
83 | if (m_windSpeeds != null) | ||
84 | { | ||
85 | windVector.X = m_windSpeeds[y * 16 + x].X; | ||
86 | windVector.Y = m_windSpeeds[y * 16 + x].Y; | ||
87 | } | ||
88 | |||
89 | return windVector; | ||
90 | |||
91 | } | ||
92 | |||
93 | public Vector2[] WindLLClientArray() | ||
94 | { | ||
95 | return m_windSpeeds; | ||
96 | } | ||
97 | |||
98 | public string Description | ||
99 | { | ||
100 | get | ||
101 | { | ||
102 | return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches."; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | public System.Collections.Generic.Dictionary<string, string> WindParams() | ||
107 | { | ||
108 | Dictionary<string, string> Params = new Dictionary<string, string>(); | ||
109 | |||
110 | Params.Add("strength", "wind strength"); | ||
111 | |||
112 | return Params; | ||
113 | } | ||
114 | |||
115 | public void WindParamSet(string param, float value) | ||
116 | { | ||
117 | switch (param) | ||
118 | { | ||
119 | case "strength": | ||
120 | m_strength = value; | ||
121 | break; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public float WindParamGet(string param) | ||
126 | { | ||
127 | switch (param) | ||
128 | { | ||
129 | case "strength": | ||
130 | return m_strength; | ||
131 | default: | ||
132 | throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | #endregion | ||
137 | |||
138 | } | ||
139 | } | ||