aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHomer Horwitz2009-04-04 15:43:02 +0000
committerHomer Horwitz2009-04-04 15:43:02 +0000
commit8136cf4075216d09738b8707258581e6db755759 (patch)
tree0d1a595c9301801750180624aeb04e839cf8f583
parentDST setting wasn't transferred to client, leading to wrong time display. (diff)
downloadopensim-SC-8136cf4075216d09738b8707258581e6db755759.zip
opensim-SC-8136cf4075216d09738b8707258581e6db755759.tar.gz
opensim-SC-8136cf4075216d09738b8707258581e6db755759.tar.bz2
opensim-SC-8136cf4075216d09738b8707258581e6db755759.tar.xz
Thanks jonc, for a patch that adds rendering of classic clouds.
First part of Mantis #964, the necessary clouds image will follow separately.
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs5
-rw-r--r--OpenSim/Framework/IClientAPI.cs1
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs39
-rw-r--r--OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs190
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/ICloudModule.cs38
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs13
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
-rw-r--r--bin/OpenSim.ini.example8
10 files changed, 295 insertions, 5 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 91661ee..2284ab8 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -909,6 +909,11 @@ namespace OpenSim.Client.MXP.ClientStack
909 // Need to translate to MXP somehow 909 // Need to translate to MXP somehow
910 } 910 }
911 911
912 public void SendCloudData(float[] cloudCover)
913 {
914 // Need to translate to MXP somehow
915 }
916
912 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 917 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
913 { 918 {
914 //throw new System.NotImplementedException(); 919 //throw new System.NotImplementedException();
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 79fb763..2c153a9 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -827,6 +827,7 @@ namespace OpenSim.Framework
827 void SendLayerData(int px, int py, float[] map); 827 void SendLayerData(int px, int py, float[] map);
828 828
829 void SendWindData(Vector2[] windSpeeds); 829 void SendWindData(Vector2[] windSpeeds);
830 void SendCloudData(float[] cloudCover);
830 831
831 void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); 832 void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
832 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); 833 void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 5c86964..9b2f0ef 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1360,7 +1360,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1360 } 1360 }
1361 1361
1362 /// <summary> 1362 /// <summary>
1363 /// Send the region heightmap to the client 1363 /// Send the wind matrix to the client
1364 /// </summary> 1364 /// </summary>
1365 /// <param name="windSpeeds">16x16 array of wind speeds</param> 1365 /// <param name="windSpeeds">16x16 array of wind speeds</param>
1366 public virtual void SendWindData(Vector2[] windSpeeds) 1366 public virtual void SendWindData(Vector2[] windSpeeds)
@@ -1369,13 +1369,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1369 } 1369 }
1370 1370
1371 /// <summary> 1371 /// <summary>
1372 /// Send terrain layer information to the client. 1372 /// Send the cloud matrix to the client
1373 /// </summary>
1374 /// <param name="windSpeeds">16x16 array of cloud densities</param>
1375 public virtual void SendCloudData(float[] cloudDensity)
1376 {
1377 ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendCloudData), (object)cloudDensity);
1378 }
1379
1380 /// <summary>
1381 /// Send wind layer information to the client.
1373 /// </summary> 1382 /// </summary>
1374 /// <param name="o"></param> 1383 /// <param name="o"></param>
1375 private void DoSendWindData(object o) 1384 private void DoSendWindData(object o)
1376 { 1385 {
1377 Vector2[] windSpeeds = (Vector2[])o; 1386 Vector2[] windSpeeds = (Vector2[])o;
1378
1379 TerrainPatch[] patches = new TerrainPatch[2]; 1387 TerrainPatch[] patches = new TerrainPatch[2];
1380 patches[0] = new TerrainPatch(); 1388 patches[0] = new TerrainPatch();
1381 patches[0].Data = new float[16 * 16]; 1389 patches[0].Data = new float[16 * 16];
@@ -1393,11 +1401,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1393 1401
1394 LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind); 1402 LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
1395 layerpack.Header.Zerocoded = true; 1403 layerpack.Header.Zerocoded = true;
1396
1397 OutPacket(layerpack, ThrottleOutPacketType.Wind); 1404 OutPacket(layerpack, ThrottleOutPacketType.Wind);
1398 } 1405 }
1399 1406
1400 /// <summary> 1407 /// <summary>
1408 /// Send cloud layer information to the client.
1409 /// </summary>
1410 /// <param name="o"></param>
1411 private void DoSendCloudData(object o)
1412 {
1413 float[] cloudCover = (float[])o;
1414 TerrainPatch[] patches = new TerrainPatch[1];
1415 patches[0] = new TerrainPatch();
1416 patches[0].Data = new float[16 * 16];
1417
1418 for (int y = 0; y < 16; y++)
1419 {
1420 for (int x = 0; x < 16; x++)
1421 {
1422 patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
1423 }
1424 }
1425
1426 LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
1427 layerpack.Header.Zerocoded = true;
1428 OutPacket(layerpack, ThrottleOutPacketType.Cloud);
1429 }
1430
1431 /// <summary>
1401 /// Tell the client that the given neighbour region is ready to receive a child agent. 1432 /// Tell the client that the given neighbour region is ready to receive a child agent.
1402 /// </summary> 1433 /// </summary>
1403 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) 1434 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
new file mode 100644
index 0000000..e164f08
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
@@ -0,0 +1,190 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.CoreModules
37{
38 public class CloudModule : ICloudModule
39 {
40 private static readonly log4net.ILog m_log
41 = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42
43 private Random m_rndnums = new Random(Environment.TickCount);
44 private Scene m_scene = null;
45 private bool m_ready = false;
46 private bool m_enabled = false;
47 private float m_cloudDensity = 1.0F;
48 private float[] cloudCover = new float[16 * 16];
49
50 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
51
52 public void Initialise(Scene scene, IConfigSource config)
53 {
54 IConfig cloudConfig = config.Configs["Cloud"];
55
56 if (cloudConfig != null)
57 {
58 m_enabled = cloudConfig.GetBoolean("enabled", false);
59 m_cloudDensity = cloudConfig.GetFloat("density", 0.5F);
60 }
61
62 if (m_enabled)
63 {
64
65 m_scene = scene;
66
67 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
68 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
69 scene.EventManager.OnClientClosed += ClientLoggedOut;
70 scene.RegisterModuleInterface<ICloudModule>(this);
71
72 GenerateCloudCover();
73
74 m_ready = true;
75
76 }
77
78 }
79
80 public void PostInitialise()
81 {
82 }
83
84 public void Close()
85 {
86 if (m_enabled)
87 {
88 m_ready = false;
89 // Remove our hooks
90 m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
91 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
92 m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
93 }
94 }
95
96 public string Name
97 {
98 get { return "CloudModule"; }
99 }
100
101 public bool IsSharedModule
102 {
103 get { return false; }
104 }
105
106
107 public float CloudCover(int x, int y, int z)
108 {
109 float cover = 0f;
110 x /= 16;
111 y /= 16;
112 if (x < 0) x = 0;
113 if (x > 15) x = 15;
114 if (y < 0) y = 0;
115 if (y > 15) y = 15;
116
117 if (cloudCover != null)
118 {
119 cover = cloudCover[y * 16 + x];
120 }
121
122 return cover;
123 }
124
125 public void CloudsToClient(IClientAPI client)
126 {
127 if (m_ready)
128 {
129 client.SendCloudData(cloudCover);
130 }
131 }
132
133
134 /// <summary>
135 /// Calculate the cloud cover over the region.
136 /// </summary>
137 private void GenerateCloudCover()
138 {
139 for (int y = 0; y < 16; y++)
140 {
141 for (int x = 0; x < 16; x++)
142 {
143 cloudCover[y * 16 + x] = (float)(m_rndnums.NextDouble()); // 0 to 1
144 cloudCover[y * 16 + x] *= m_cloudDensity;
145 }
146 }
147 }
148
149 private void ClientLoggedOut(UUID AgentId)
150 {
151 lock (m_rootAgents)
152 {
153 if (m_rootAgents.ContainsKey(AgentId))
154 {
155 m_rootAgents.Remove(AgentId);
156 }
157 }
158 }
159
160 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
161 {
162 lock (m_rootAgents)
163 {
164 if (m_rootAgents.ContainsKey(avatar.UUID))
165 {
166 m_rootAgents[avatar.UUID] = avatar.RegionHandle;
167 }
168 else
169 {
170 m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
171 CloudsToClient(avatar.ControllingClient);
172 }
173 }
174 }
175
176 private void MakeChildAgent(ScenePresence avatar)
177 {
178 lock (m_rootAgents)
179 {
180 if (m_rootAgents.ContainsKey(avatar.UUID))
181 {
182 if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
183 {
184 m_rootAgents.Remove(avatar.UUID);
185 }
186 }
187 }
188 }
189 }
190}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 5bd9412..dc63b05 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -439,6 +439,8 @@ namespace OpenSim.Region.Examples.SimpleModule
439 439
440 public virtual void SendWindData(Vector2[] windSpeeds) { } 440 public virtual void SendWindData(Vector2[] windSpeeds) { }
441 441
442 public virtual void SendCloudData(float[] cloudCover) { }
443
442 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 444 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
443 { 445 {
444 } 446 }
diff --git a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
new file mode 100644
index 0000000..3db72b1
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs
@@ -0,0 +1,38 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28
29namespace OpenSim.Region.Framework.Interfaces
30{
31 public interface ICloudModule : IRegionModule
32 {
33 /// <summary>
34 /// Retrieves the cloud density at the given region coordinates
35 /// </summary>
36 float CloudCover(int x, int y, int z);
37 }
38}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 0b0c55d..4de6793 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -528,6 +528,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
528 528
529 public virtual void SendWindData(Vector2[] windSpeeds) { } 529 public virtual void SendWindData(Vector2[] windSpeeds) { }
530 530
531 public virtual void SendCloudData(float[] cloudCover) { }
532
531 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 533 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
532 { 534 {
533 } 535 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index edaa3e9..bcbfe96 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1027,7 +1027,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1027 public LSL_Float llCloud(LSL_Vector offset) 1027 public LSL_Float llCloud(LSL_Vector offset)
1028 { 1028 {
1029 m_host.AddScriptLPS(1); 1029 m_host.AddScriptLPS(1);
1030 return 0; 1030 float cloudCover = 0f;
1031 ICloudModule module = World.RequestModuleInterface<ICloudModule>();
1032 if (module != null)
1033 {
1034 Vector3 pos = m_host.GetWorldPosition();
1035 int x = (int)(pos.X + offset.x);
1036 int y = (int)(pos.Y + offset.y);
1037
1038 cloudCover = module.CloudCover(x, y, 0);
1039
1040 }
1041 return cloudCover;
1031 } 1042 }
1032 1043
1033 public LSL_Vector llWind(LSL_Vector offset) 1044 public LSL_Vector llWind(LSL_Vector offset)
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index b47e48d..33f080f 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -491,6 +491,8 @@ namespace OpenSim.Tests.Common.Mock
491 491
492 public virtual void SendWindData(Vector2[] windSpeeds) { } 492 public virtual void SendWindData(Vector2[] windSpeeds) { }
493 493
494 public virtual void SendCloudData(float[] cloudCover) { }
495
494 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 496 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
495 { 497 {
496 } 498 }
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index a31d27a..fe49549 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -702,6 +702,14 @@
702 ; Adjusts wind strength. 0.0 = no wind, 1.0 = normal wind. Default is 1.0 702 ; Adjusts wind strength. 0.0 = no wind, 1.0 = normal wind. Default is 1.0
703 strength = 1.0 703 strength = 1.0
704 704
705[Cloud]
706 ; Enable this to generate classic particle clouds above the sim.
707 ; default is disabled - turn it on here
708 enabled = true
709
710 ; Density of cloud cover 0.0 to 1.0
711 density = 0.5
712
705 713
706[Trees] 714[Trees]
707 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying 715 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying