Thanks jonc, for a patch that adds rendering of classic clouds.
First part of Mantis #964, the necessary clouds image will follow separately.0.6.5-rc1
parent
7acec9860d
commit
8136cf4075
|
@ -909,6 +909,11 @@ namespace OpenSim.Client.MXP.ClientStack
|
||||||
// Need to translate to MXP somehow
|
// Need to translate to MXP somehow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendCloudData(float[] cloudCover)
|
||||||
|
{
|
||||||
|
// Need to translate to MXP somehow
|
||||||
|
}
|
||||||
|
|
||||||
public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
||||||
{
|
{
|
||||||
//throw new System.NotImplementedException();
|
//throw new System.NotImplementedException();
|
||||||
|
|
|
@ -827,6 +827,7 @@ namespace OpenSim.Framework
|
||||||
void SendLayerData(int px, int py, float[] map);
|
void SendLayerData(int px, int py, float[] map);
|
||||||
|
|
||||||
void SendWindData(Vector2[] windSpeeds);
|
void SendWindData(Vector2[] windSpeeds);
|
||||||
|
void SendCloudData(float[] cloudCover);
|
||||||
|
|
||||||
void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
|
void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
|
||||||
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
|
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);
|
||||||
|
|
|
@ -1360,7 +1360,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send the region heightmap to the client
|
/// Send the wind matrix to the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="windSpeeds">16x16 array of wind speeds</param>
|
/// <param name="windSpeeds">16x16 array of wind speeds</param>
|
||||||
public virtual void SendWindData(Vector2[] windSpeeds)
|
public virtual void SendWindData(Vector2[] windSpeeds)
|
||||||
|
@ -1369,13 +1369,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send terrain layer information to the client.
|
/// Send the cloud matrix to the client
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windSpeeds">16x16 array of cloud densities</param>
|
||||||
|
public virtual void SendCloudData(float[] cloudDensity)
|
||||||
|
{
|
||||||
|
ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendCloudData), (object)cloudDensity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send wind layer information to the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="o"></param>
|
/// <param name="o"></param>
|
||||||
private void DoSendWindData(object o)
|
private void DoSendWindData(object o)
|
||||||
{
|
{
|
||||||
Vector2[] windSpeeds = (Vector2[])o;
|
Vector2[] windSpeeds = (Vector2[])o;
|
||||||
|
|
||||||
TerrainPatch[] patches = new TerrainPatch[2];
|
TerrainPatch[] patches = new TerrainPatch[2];
|
||||||
patches[0] = new TerrainPatch();
|
patches[0] = new TerrainPatch();
|
||||||
patches[0].Data = new float[16 * 16];
|
patches[0].Data = new float[16 * 16];
|
||||||
|
@ -1393,10 +1401,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
|
LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
|
||||||
layerpack.Header.Zerocoded = true;
|
layerpack.Header.Zerocoded = true;
|
||||||
|
|
||||||
OutPacket(layerpack, ThrottleOutPacketType.Wind);
|
OutPacket(layerpack, ThrottleOutPacketType.Wind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send cloud layer information to the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
|
private void DoSendCloudData(object o)
|
||||||
|
{
|
||||||
|
float[] cloudCover = (float[])o;
|
||||||
|
TerrainPatch[] patches = new TerrainPatch[1];
|
||||||
|
patches[0] = new TerrainPatch();
|
||||||
|
patches[0].Data = new float[16 * 16];
|
||||||
|
|
||||||
|
for (int y = 0; y < 16; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
|
||||||
|
layerpack.Header.Zerocoded = true;
|
||||||
|
OutPacket(layerpack, ThrottleOutPacketType.Cloud);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tell the client that the given neighbour region is ready to receive a child agent.
|
/// Tell the client that the given neighbour region is ready to receive a child agent.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -0,0 +1,190 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Nini.Config;
|
||||||
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.CoreModules
|
||||||
|
{
|
||||||
|
public class CloudModule : ICloudModule
|
||||||
|
{
|
||||||
|
private static readonly log4net.ILog m_log
|
||||||
|
= log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private Random m_rndnums = new Random(Environment.TickCount);
|
||||||
|
private Scene m_scene = null;
|
||||||
|
private bool m_ready = false;
|
||||||
|
private bool m_enabled = false;
|
||||||
|
private float m_cloudDensity = 1.0F;
|
||||||
|
private float[] cloudCover = new float[16 * 16];
|
||||||
|
|
||||||
|
private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
|
||||||
|
|
||||||
|
public void Initialise(Scene scene, IConfigSource config)
|
||||||
|
{
|
||||||
|
IConfig cloudConfig = config.Configs["Cloud"];
|
||||||
|
|
||||||
|
if (cloudConfig != null)
|
||||||
|
{
|
||||||
|
m_enabled = cloudConfig.GetBoolean("enabled", false);
|
||||||
|
m_cloudDensity = cloudConfig.GetFloat("density", 0.5F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_enabled)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_scene = scene;
|
||||||
|
|
||||||
|
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
||||||
|
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||||
|
scene.EventManager.OnClientClosed += ClientLoggedOut;
|
||||||
|
scene.RegisterModuleInterface<ICloudModule>(this);
|
||||||
|
|
||||||
|
GenerateCloudCover();
|
||||||
|
|
||||||
|
m_ready = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PostInitialise()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
if (m_enabled)
|
||||||
|
{
|
||||||
|
m_ready = false;
|
||||||
|
// Remove our hooks
|
||||||
|
m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
|
||||||
|
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
|
||||||
|
m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "CloudModule"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSharedModule
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public float CloudCover(int x, int y, int z)
|
||||||
|
{
|
||||||
|
float cover = 0f;
|
||||||
|
x /= 16;
|
||||||
|
y /= 16;
|
||||||
|
if (x < 0) x = 0;
|
||||||
|
if (x > 15) x = 15;
|
||||||
|
if (y < 0) y = 0;
|
||||||
|
if (y > 15) y = 15;
|
||||||
|
|
||||||
|
if (cloudCover != null)
|
||||||
|
{
|
||||||
|
cover = cloudCover[y * 16 + x];
|
||||||
|
}
|
||||||
|
|
||||||
|
return cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloudsToClient(IClientAPI client)
|
||||||
|
{
|
||||||
|
if (m_ready)
|
||||||
|
{
|
||||||
|
client.SendCloudData(cloudCover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculate the cloud cover over the region.
|
||||||
|
/// </summary>
|
||||||
|
private void GenerateCloudCover()
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 16; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
cloudCover[y * 16 + x] = (float)(m_rndnums.NextDouble()); // 0 to 1
|
||||||
|
cloudCover[y * 16 + x] *= m_cloudDensity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClientLoggedOut(UUID AgentId)
|
||||||
|
{
|
||||||
|
lock (m_rootAgents)
|
||||||
|
{
|
||||||
|
if (m_rootAgents.ContainsKey(AgentId))
|
||||||
|
{
|
||||||
|
m_rootAgents.Remove(AgentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
|
||||||
|
{
|
||||||
|
lock (m_rootAgents)
|
||||||
|
{
|
||||||
|
if (m_rootAgents.ContainsKey(avatar.UUID))
|
||||||
|
{
|
||||||
|
m_rootAgents[avatar.UUID] = avatar.RegionHandle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_rootAgents.Add(avatar.UUID, avatar.RegionHandle);
|
||||||
|
CloudsToClient(avatar.ControllingClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MakeChildAgent(ScenePresence avatar)
|
||||||
|
{
|
||||||
|
lock (m_rootAgents)
|
||||||
|
{
|
||||||
|
if (m_rootAgents.ContainsKey(avatar.UUID))
|
||||||
|
{
|
||||||
|
if (m_rootAgents[avatar.UUID] == avatar.RegionHandle)
|
||||||
|
{
|
||||||
|
m_rootAgents.Remove(avatar.UUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -439,6 +439,8 @@ namespace OpenSim.Region.Examples.SimpleModule
|
||||||
|
|
||||||
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
||||||
|
|
||||||
|
public virtual void SendCloudData(float[] cloudCover) { }
|
||||||
|
|
||||||
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Framework.Interfaces
|
||||||
|
{
|
||||||
|
public interface ICloudModule : IRegionModule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the cloud density at the given region coordinates
|
||||||
|
/// </summary>
|
||||||
|
float CloudCover(int x, int y, int z);
|
||||||
|
}
|
||||||
|
}
|
|
@ -528,6 +528,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
|
|
||||||
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
||||||
|
|
||||||
|
public virtual void SendCloudData(float[] cloudCover) { }
|
||||||
|
|
||||||
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1027,7 +1027,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
public LSL_Float llCloud(LSL_Vector offset)
|
public LSL_Float llCloud(LSL_Vector offset)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
return 0;
|
float cloudCover = 0f;
|
||||||
|
ICloudModule module = World.RequestModuleInterface<ICloudModule>();
|
||||||
|
if (module != null)
|
||||||
|
{
|
||||||
|
Vector3 pos = m_host.GetWorldPosition();
|
||||||
|
int x = (int)(pos.X + offset.x);
|
||||||
|
int y = (int)(pos.Y + offset.y);
|
||||||
|
|
||||||
|
cloudCover = module.CloudCover(x, y, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
return cloudCover;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LSL_Vector llWind(LSL_Vector offset)
|
public LSL_Vector llWind(LSL_Vector offset)
|
||||||
|
|
|
@ -491,6 +491,8 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
|
|
||||||
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
public virtual void SendWindData(Vector2[] windSpeeds) { }
|
||||||
|
|
||||||
|
public virtual void SendCloudData(float[] cloudCover) { }
|
||||||
|
|
||||||
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -702,6 +702,14 @@
|
||||||
; Adjusts wind strength. 0.0 = no wind, 1.0 = normal wind. Default is 1.0
|
; Adjusts wind strength. 0.0 = no wind, 1.0 = normal wind. Default is 1.0
|
||||||
strength = 1.0
|
strength = 1.0
|
||||||
|
|
||||||
|
[Cloud]
|
||||||
|
; Enable this to generate classic particle clouds above the sim.
|
||||||
|
; default is disabled - turn it on here
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
; Density of cloud cover 0.0 to 1.0
|
||||||
|
density = 0.5
|
||||||
|
|
||||||
|
|
||||||
[Trees]
|
[Trees]
|
||||||
; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying
|
; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying
|
||||||
|
|
Loading…
Reference in New Issue