diff options
author | Jeff Ames | 2009-04-01 14:50:18 +0000 |
---|---|---|
committer | Jeff Ames | 2009-04-01 14:50:18 +0000 |
commit | 99cfcf405b6da42dac29d60141685e3852f41836 (patch) | |
tree | 2c91a2445af2256dc7927df18e7d2126aaa972fb /OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |
parent | Add a "user" config option to the IRC module config. Like all other IRC (diff) | |
download | opensim-SC_OLD-99cfcf405b6da42dac29d60141685e3852f41836.zip opensim-SC_OLD-99cfcf405b6da42dac29d60141685e3852f41836.tar.gz opensim-SC_OLD-99cfcf405b6da42dac29d60141685e3852f41836.tar.bz2 opensim-SC_OLD-99cfcf405b6da42dac29d60141685e3852f41836.tar.xz |
Update svn properties.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | 278 |
1 files changed, 139 insertions, 139 deletions
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 | } |