From ef494fdf9c24387c2d98ffde5400f93fa276aa9e Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 17 Jun 2007 18:04:35 +0000 Subject: Each Region will now generate a texture image of their terrain and this will be used by the map. Note: Currently each region generates a new image every time they start; even if the terrain is read from the database. And also they don't update it when the terrain changes. --- .../LocalBackEndServices.cs | 2 +- .../OpenSim.LocalCommunications.csproj.user | 2 +- OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs | 4 +- OpenSim/OpenSim.Region/Scenes/Avatar.cs | 18 --------- OpenSim/OpenSim.Region/Scenes/Scene.cs | 11 ++++++ OpenSim/OpenSim.RegionServer/ClientView.API.cs | 34 ++++++++--------- .../ClientView.PacketHandlers.cs | 4 +- .../ClientView.ProcessPackets.cs | 27 +------------ OpenSim/OpenSim.RegionServer/ClientView.cs | 2 - .../OpenSim.Terrain.BasicTerrain.csproj | 4 ++ .../OpenSim.Terrain.BasicTerrain.dll.build | 1 + .../OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 44 ++++++++++++++++++++++ 12 files changed, 83 insertions(+), 70 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs b/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs index 46ace9c..6e963d2 100644 --- a/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs +++ b/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs @@ -129,7 +129,7 @@ namespace OpenSim.LocalCommunications map.X = (ushort)regInfo.RegionLocX; map.Y = (ushort)regInfo.RegionLocY; map.WaterHeight =(byte) regInfo.estateSettings.waterHeight; - map.MapImageId = new LLUUID("00000000-0000-0000-9999-000000000007"); + map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007"); map.Agents = 1; map.RegionFlags = 72458694; map.Access = 13; diff --git a/OpenSim/OpenSim.LocalCommunications/OpenSim.LocalCommunications.csproj.user b/OpenSim/OpenSim.LocalCommunications/OpenSim.LocalCommunications.csproj.user index 518ce40..5941547 100644 --- a/OpenSim/OpenSim.LocalCommunications/OpenSim.LocalCommunications.csproj.user +++ b/OpenSim/OpenSim.LocalCommunications/OpenSim.LocalCommunications.csproj.user @@ -2,7 +2,7 @@ Debug AnyCPU - C:\Documents and Settings\Stefan\My Documents\source\opensim\branches\Sugilite\bin\ + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-06\Sugilite\bin\ 8.0.50727 ProjectFiles 0 diff --git a/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs b/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs index 5d70bc1..50d5a14 100644 --- a/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs +++ b/OpenSim/OpenSim.Region/Scenes/Avatar.Update.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.Scenes } } - this.CheckBorderCrossing(); + this.CheckForBorderCrossing(); } } @@ -156,7 +156,7 @@ namespace OpenSim.Region.Scenes /// /// /// - protected void CheckBorderCrossing() + protected void CheckForBorderCrossing() { LLVector3 pos2 = this.Pos; LLVector3 vel = this.Velocity; diff --git a/OpenSim/OpenSim.Region/Scenes/Avatar.cs b/OpenSim/OpenSim.Region/Scenes/Avatar.cs index d40e213..6b393a8 100644 --- a/OpenSim/OpenSim.Region/Scenes/Avatar.cs +++ b/OpenSim/OpenSim.Region/Scenes/Avatar.cs @@ -232,24 +232,6 @@ namespace OpenSim.Region.Scenes /// /// /// - public void HandleAgentUpdate(Packet pack) - { - this.HandleUpdate((AgentUpdatePacket)pack); - } - - /// - /// - /// - /// - public void HandleUpdate(AgentUpdatePacket pack) - { - - } - - /// - /// - /// - /// public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) { diff --git a/OpenSim/OpenSim.Region/Scenes/Scene.cs b/OpenSim/OpenSim.Region/Scenes/Scene.cs index eb942c2..ca9a112 100644 --- a/OpenSim/OpenSim.Region/Scenes/Scene.cs +++ b/OpenSim/OpenSim.Region/Scenes/Scene.cs @@ -424,6 +424,17 @@ namespace OpenSim.Region.Scenes { this.Terrain.setHeights1D(map); } + + //create a texture asset of the terrain + byte[] data =this.Terrain.exportJpegImage("defaultstripe.png"); + this.m_regInfo.estateSettings.terrainImageID= LLUUID.Random(); + AssetBase asset = new AssetBase(); + asset.FullID = this.m_regInfo.estateSettings.terrainImageID; + asset.Data = data; + asset.Name = "terrainImage"; + asset.Type = 0; + this.assetCache.AddAsset(asset); + } catch (Exception e) { diff --git a/OpenSim/OpenSim.RegionServer/ClientView.API.cs b/OpenSim/OpenSim.RegionServer/ClientView.API.cs index 80719d6..bb4dccd 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.API.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.API.cs @@ -365,22 +365,22 @@ namespace OpenSim public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) { - TeleportLocalPacket tpLocal2 = new TeleportLocalPacket(); - tpLocal2.Info.AgentID = this.AgentID; - tpLocal2.Info.TeleportFlags = flags; - tpLocal2.Info.LocationID = 2; - tpLocal2.Info.LookAt = lookAt; - tpLocal2.Info.Position = position; - OutPacket(tpLocal2); + TeleportLocalPacket tpLocal = new TeleportLocalPacket(); + tpLocal.Info.AgentID = this.AgentID; + tpLocal.Info.TeleportFlags = flags; + tpLocal.Info.LocationID = 2; + tpLocal.Info.LookAt = lookAt; + tpLocal.Info.Position = position; + OutPacket(tpLocal); } public void SendRegionTeleport(ulong regionHandle, byte simAccess, string ipAddress, ushort ipPort, uint locationID, uint flags) { - TeleportFinishPacket Teleport = new TeleportFinishPacket(); - Teleport.Info.AgentID = this.AgentID; - Teleport.Info.RegionHandle = regionHandle; - Teleport.Info.SimAccess = simAccess; - Teleport.Info.SeedCapability = new byte[0]; + TeleportFinishPacket teleport = new TeleportFinishPacket(); + teleport.Info.AgentID = this.AgentID; + teleport.Info.RegionHandle = regionHandle; + teleport.Info.SimAccess = simAccess; + teleport.Info.SeedCapability = new byte[0]; System.Net.IPAddress oIP = System.Net.IPAddress.Parse(ipAddress); byte[] byteIP = oIP.GetAddressBytes(); @@ -389,11 +389,11 @@ namespace OpenSim ip += (uint)byteIP[1] << 8; ip += (uint)byteIP[0]; - Teleport.Info.SimIP = ip; - Teleport.Info.SimPort = ipPort; - Teleport.Info.LocationID = 4; - Teleport.Info.TeleportFlags = 1 << 4; - OutPacket(Teleport); + teleport.Info.SimIP = ip; + teleport.Info.SimPort = ipPort; + teleport.Info.LocationID = 4; + teleport.Info.TeleportFlags = 1 << 4; + OutPacket(teleport); } /// diff --git a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs index a173c47..219cdae 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.PacketHandlers.cs @@ -190,9 +190,7 @@ namespace OpenSim mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); } this.OutPacket(mbReply); - * */ - - + */ } diff --git a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs index f8425da..601fd97 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.ProcessPackets.cs @@ -399,7 +399,6 @@ namespace OpenSim { OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); } - //this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); break; case PacketType.TeleportLandmarkRequest: TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; @@ -451,7 +450,7 @@ namespace OpenSim break; case PacketType.TeleportLocationRequest: TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; - // Console.WriteLine(tpLocReq.ToString()); + // Console.WriteLine(tpLocReq.ToString()); if (OnTeleportLocationRequest != null) { @@ -463,32 +462,8 @@ namespace OpenSim TeleportCancelPacket tpCancel = new TeleportCancelPacket(); tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; - OutPacket(tpCancel); } - - /* if (m_regionData.RegionHandle != tpLocReq.Info.RegionHandle) - { - // m_gridServer.getRegion(tpLocReq.Info.RegionHandle); - Console.WriteLine("Inter-sim teleport not yet implemented"); - TeleportCancelPacket tpCancel = new TeleportCancelPacket(); - tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; - tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; - - OutPacket(tpCancel); - } - else - { - Console.WriteLine("Local teleport"); - TeleportLocalPacket tpLocal2 = new TeleportLocalPacket(); - tpLocal2.Info.AgentID = tpLocReq.AgentData.AgentID; - tpLocal2.Info.TeleportFlags = tpStart.Info.TeleportFlags; - tpLocal2.Info.LocationID = 2; - tpLocal2.Info.LookAt = tpLocReq.Info.LookAt; - tpLocal2.Info.Position = tpLocReq.Info.Position; - OutPacket(tpLocal2); - - }*/ break; #endregion diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs index 74dbc1a..c5f0a1d 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.cs @@ -75,7 +75,6 @@ namespace OpenSim protected IWorld m_world; private Dictionary m_clientThreads; private AssetCache m_assetCache; - //private IGridServer m_gridServer; private InventoryCache m_inventoryCache; private int cachedtextureserial = 0; private RegionInfo m_regionData; @@ -95,7 +94,6 @@ namespace OpenSim cirpack = initialcirpack; userEP = remoteEP; - //this.m_child = m_authenticateSessionsHandler.GetAgentChildStatus(initialcirpack.CircuitCode.Code); this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code); PacketQueue = new BlockingQueue(); diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj index e38c879..10bc0fd 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj @@ -62,6 +62,10 @@ ..\..\bin\libTerrain-BSD.dll False + + ..\..\bin\openjpegnet.dll + False + System.dll False diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build index 6526648..51cecb9 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.dll.build @@ -20,6 +20,7 @@ + diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index ecbd078..e5831a0 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Text; using System.Drawing; using libTerrain; +using OpenJPEGNet; namespace OpenSim.Terrain { @@ -507,5 +508,48 @@ namespace OpenSim.Terrain Console.WriteLine("Failed generating terrain map: " + e.ToString()); } } + + /// + /// Exports the current heightmap in Jpeg2000 format to a byte[] + /// + /// A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal. + public byte[] exportJpegImage(string gradientmap) + { + byte[] imageData = null; + try + { + Bitmap gradientmapLd = new Bitmap(gradientmap); + + int pallete = gradientmapLd.Height; + + Bitmap bmp = new Bitmap(heightmap.w, heightmap.h); + Color[] colours = new Color[pallete]; + + for (int i = 0; i < pallete; i++) + { + colours[i] = gradientmapLd.GetPixel(0, i); + } + + Channel copy = heightmap.copy(); + for (int x = 0; x < copy.w; x++) + { + for (int y = 0; y < copy.h; y++) + { + // 512 is the largest possible height before colours clamp + int colorindex = (int)(Math.Max(Math.Min(1.0, copy.get(copy.w -x, copy.h - y) / 512.0), 0.0) * pallete); + bmp.SetPixel(x, y, colours[colorindex]); + } + } + + //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png); + imageData = OpenJPEGNet.OpenJPEG.EncodeFromImage(bmp, "map"); + + } + catch (Exception e) + { + Console.WriteLine("Failed generating terrain map: " + e.ToString()); + } + return imageData; + } } } \ No newline at end of file -- cgit v1.1