예제 #1
0
        public static void NoiseArea(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            for (int x = (int)data.West; x < (int)data.East; x++)
            {
                for (int y = (int)data.South; y < (int)data.North; y++)
                {
                    if (!scene.CanTerraform(agentOwner, new Vector3(x, y, 0)))
                    {
                        continue;
                    }

                    double noise = PerlinNoise2D((double)x / scene.SizeX,
                                                 (double)y / scene.SizeY, 8, 1);

                    LayerPatch lp = scene.Terrain.AdjustTerrain((uint)x, (uint)y, noise * modify.Size);
                    if (lp != null && !changed.Contains(lp))
                    {
                        changed.Add(lp);
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                    scene.Terrain.UpdateTerrainListeners(lp);
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
예제 #2
0
 public NotecardCache(SceneInterface scene)
 {
     m_Scene          = scene;
     m_Timer.Elapsed += OnTimer;
     m_Timer.Interval = 1000;
     m_Timer.Enabled  = true;
 }
예제 #3
0
        private static double GetBilinearInterpolate(double x, double y, SceneInterface scene)
        {
            var w = (int)scene.SizeX;
            var h = (int)scene.SizeY;

            if (x > w - 2)
            {
                x = w - 2;
            }
            if (y > h - 2)
            {
                y = h - 2;
            }

            x = x.Clamp(1f, scene.SizeX - 2);
            y = y.Clamp(1f, scene.SizeY - 2);

            const int stepSize = 1;
            double    h00      = scene.Terrain[(uint)x, (uint)y];
            double    h10      = scene.Terrain[(uint)x + stepSize, (uint)y];
            double    h01      = scene.Terrain[(uint)x, (uint)y + stepSize];
            double    h11      = scene.Terrain[(uint)x + stepSize, (uint)y + stepSize];
            double    h1       = h00;
            double    h2       = h10;
            double    h3       = h01;
            double    h4       = h11;
            double    a00      = h1;
            double    a10      = h2 - h1;
            double    a01      = h3 - h1;
            double    a11      = h1 - h2 - h3 + h4;
            double    partialx = x - (uint)x;
            double    partialz = y - (uint)y;

            return(a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz));
        }
예제 #4
0
 public AddToObjectTransferItem(
     IAgent agent,
     SceneInterface scene,
     UUID assetid,
     ObjectPart part,
     ObjectPartInventoryItem item)
     : base(scene.AssetService, agent.AssetService, assetid, ReferenceSource.Source)
 {
     m_Part    = part;
     m_Item    = item;
     m_Part    = part;
     m_SceneID = scene.ID;
 }
예제 #5
0
 public ObjectBuyTransferItem(
     IAgent agent,
     SceneInterface scene,
     List <UUID> assetids,
     List <InventoryItem> items,
     string destinationFolder,
     UUID sellingPrimitiveID,
     IActiveTransaction transaction = null)
     : base(agent, scene, assetids, items, destinationFolder)
 {
     m_SellingPrimitiveID = sellingPrimitiveID;
     m_Transaction        = transaction;
 }
예제 #6
0
        public static void FlattenArea(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            double sum   = 0;
            double steps = 0;

            for (var x = (int)data.West; x < (int)data.East; x++)
            {
                for (var y = (int)data.South; y < (int)data.North; y++)
                {
                    if (!scene.CanTerraform(agentOwner, new Vector3(x, y, 0)))
                    {
                        continue;
                    }
                    sum += scene.Terrain[(uint)x, (uint)y];
                    steps++;
                }
            }

            double avg = sum / steps;

            double str = 0.1f * modify.Size; // == 0.2 in the default client

            for (var x = (int)data.West; x < (int)data.East; x++)
            {
                for (var y = (int)data.South; y < (int)data.North; y++)
                {
                    if (scene.CanTerraform(agentOwner, new Vector3(x, y, 0)))
                    {
                        LayerPatch lp = scene.Terrain.BlendTerrain((uint)x, (uint)y, avg, str);
                        if (lp != null && !changed.Contains(lp))
                        {
                            changed.Add(lp);
                        }
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                    scene.Terrain.UpdateTerrainListeners(lp);
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
예제 #7
0
 public ObjectTransferItem(
     IAgent agent,
     SceneInterface scene,
     UUID assetid,
     List <InventoryItem> items,
     string destinationFolder = "")
     : base(agent.AssetService, scene.AssetService, assetid, ReferenceSource.Source)
 {
     m_InventoryService  = agent.InventoryService;
     m_DestinationAgent  = agent.Owner;
     m_SceneID           = scene.ID;
     m_Items             = items;
     m_DestinationFolder = destinationFolder;
     TryGetScene         = scene.TryGetScene;
 }
예제 #8
0
        public static void SmoothArea(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            double area = modify.Size;
            double step = area / 4;

            for (int x = (int)data.West; x < (int)data.East; x++)
            {
                for (int y = (int)data.South; y < (int)data.North; y++)
                {
                    if (!scene.CanTerraform(agentOwner, new Vector3(x, y, 0)))
                    {
                        continue;
                    }

                    double average  = 0;
                    int    avgsteps = 0;

                    for (double n = 0 - area; n < area; n += step)
                    {
                        for (double l = 0 - area; l < area; l += step)
                        {
                            avgsteps++;
                            average += GetBilinearInterpolate(x + n, y + l, scene);
                        }
                    }

                    LayerPatch lp = scene.Terrain.BlendTerrain((uint)x, (uint)y, average / avgsteps, 1);
                    if (lp != null && !changed.Contains(lp))
                    {
                        changed.Add(lp);
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                    scene.Terrain.UpdateTerrainListeners(lp);
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
예제 #9
0
 public ObjectTransferItem(
     InventoryServiceInterface inventoryService,
     AssetServiceInterface assetService,
     UGUI agentOwner,
     SceneInterface scene,
     List <UUID> assetids,
     List <InventoryItem> items,
     AssetType destinationFolderType)
     : base(assetService, scene.AssetService, assetids, ReferenceSource.Source)
 {
     m_InventoryService      = inventoryService;
     m_DestinationAgent      = agentOwner;
     m_SceneID               = scene.ID;
     m_Items                 = items;
     m_DestinationFolderType = destinationFolderType;
     TryGetScene             = scene.TryGetScene;
 }
예제 #10
0
        public static void LowerSphere(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            int xFrom = (int)(data.West - data.BrushSize + 0.5);
            int xTo   = (int)(data.West + data.BrushSize + 0.5);
            int yFrom = (int)(data.South - data.BrushSize + 0.5);
            int yTo   = (int)(data.South + data.BrushSize + 0.5);

            if (xFrom < 0)
            {
                xFrom = 0;
            }

            if (yFrom < 0)
            {
                yFrom = 0;
            }

            if (xTo >= scene.SizeX)
            {
                xTo = (int)scene.SizeX - 1;
            }

            if (yTo >= scene.SizeY)
            {
                yTo = (int)scene.SizeY - 1;
            }

            for (int x = xFrom; x <= xTo; x++)
            {
                for (int y = yFrom; y <= yTo; y++)
                {
                    Vector3 pos = new Vector3(x, y, 0);
                    if (!scene.CanTerraform(agentOwner, pos))
                    {
                        continue;
                    }

                    // Calculate a cos-sphere and add it to the heightmap
                    double r = Math.Sqrt((x - data.West) * (x - data.West) + ((y - data.South) * (y - data.South)));
                    double z = Math.Cos(r * Math.PI / (data.BrushSize * 2));
                    if (z > 0.0)
                    {
                        LayerPatch lp = scene.Terrain.AdjustTerrain((uint)x, (uint)y, -z * modify.Seconds);
                        if (lp != null && !changed.Contains(lp))
                        {
                            changed.Add(lp);
                        }
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                    scene.Terrain.UpdateTerrainListeners(lp);
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
예제 #11
0
        public static void NoiseSphere(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            int n = (int)(data.BrushSize + 0.5f);

            if (data.BrushSize > 6)
            {
                data.BrushSize = 6;
            }

            double strength = MetersToSphericalStrength(data.BrushSize);

            double area     = data.BrushSize;
            double step     = data.BrushSize / 4;
            double duration = modify.Seconds * 0.01f;

            int zx = (int)(data.West + 0.5);
            int zy = (int)(data.South + 0.5);

            double average  = 0;
            int    avgsteps = 0;

            for (double nn = 0 - area; nn < area; nn += step)
            {
                for (double l = 0 - area; l < area; l += step)
                {
                    avgsteps++;
                    average += GetBilinearInterpolate(data.West + nn, data.South + l, scene);
                }
            }

            for (int dx = -n; dx <= n; dx++)
            {
                for (int dy = -n; dy <= n; dy++)
                {
                    int x = zx + dx;
                    int y = zy + dy;
                    if (x >= 0 && y >= 0 && x < scene.SizeX && y < scene.SizeY)
                    {
                        Vector3 pos = new Vector3(x, y, 0);
                        if (!scene.CanTerraform(agentOwner, pos))
                        {
                            continue;
                        }

                        double z = SphericalFactor(x, y, data.West, data.South, strength) / (strength);
                        if (z > 0) // add in non-zero amount
                        {
                            double a = scene.Terrain[(uint)x, (uint)y] - (average / avgsteps);

                            LayerPatch lp = scene.Terrain.AdjustTerrain((uint)x, (uint)y, a * duration);
                            if (lp != null && !changed.Contains(lp))
                            {
                                changed.Add(lp);
                            }
                        }
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                    scene.Terrain.UpdateTerrainListeners(lp);
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
예제 #12
0
            public override void AssetTransferComplete()
            {
                InventoryFolder folder;
                SceneInterface  scene = null;
                IAgent          agent = null;

                if (!TryGetScene(m_SceneID, out scene) ||
                    !scene.Agents.TryGetValue(m_DestinationAgent.ID, out agent))
                {
                    agent = null;
                }

                if (m_DestinationFolder.Length == 0)
                {
                    if (!(m_DestinationFolderID != UUID.Zero && m_InventoryService.Folder.TryGetValue(m_DestinationAgent.ID, m_DestinationFolderID, out folder)) &&
                        !m_InventoryService.Folder.TryGetValue(m_DestinationAgent.ID, m_DestinationFolderType, out folder))
                    {
                        return;
                    }
                }
                else
                {
                    if (!m_InventoryService.Folder.TryGetValue(m_DestinationAgent.ID, m_DestinationFolderType, out folder))
                    {
                        return;
                    }
                    var rootFolderID = folder.ID;
                    folder = new InventoryFolder
                    {
                        Owner          = m_DestinationAgent,
                        ParentFolderID = rootFolderID,
                        DefaultType    = AssetType.Unknown,
                        Version        = 1,
                        Name           = m_DestinationFolder,
                        ID             = UUID.Random
                    };
                    m_InventoryService.Folder.Add(folder);

                    if (agent != null)
                    {
                        var msg = new BulkUpdateInventory
                        {
                            AgentID       = m_DestinationAgent.ID,
                            TransactionID = UUID.Zero
                        };
                        msg.AddInventoryFolder(folder);
                        agent.SendMessageAlways(msg, m_SceneID);
                    }
                }

                foreach (var sellItem in m_Items)
                {
                    var item = new InventoryItem(UUID.Random, sellItem);
                    item.LastOwner      = item.Owner;
                    item.Owner          = m_DestinationAgent;
                    item.ParentFolderID = folder.ID;
                    item.IsGroupOwned   = false;
                    m_InventoryService.Item.Add(item);
                    if (agent != null)
                    {
                        var msg = new UpdateCreateInventoryItem
                        {
                            AgentID     = m_DestinationAgent.ID,
                            SimApproved = true
                        };
                        msg.AddItem(item, 0);
                        agent.SendMessageAlways(msg, m_SceneID);
                    }
                }
            }
 internal DefaultAssetService(SceneInterface si)
 {
     m_Scene             = si;
     m_ReferencesService = new DefaultAssetReferencesService(si);
 }
 internal DefaultAssetReferencesService(SceneInterface scene)
 {
     m_Scene = scene;
 }
 public DefaultSceneObjectGroupInterface(SceneInterface scene)
 {
     m_Scene = scene;
 }
예제 #16
0
        public static void FlattenSphere(UGUI agentOwner, SceneInterface scene, ModifyLand modify, ModifyLand.Data data)
        {
            var changed = new List <LayerPatch>();

            double strength = MetersToSphericalStrength(data.BrushSize);

            int xFrom = (int)(data.West - data.BrushSize + 0.5);
            int xTo   = (int)(data.West + data.BrushSize + 0.5);
            int yFrom = (int)(data.South - data.BrushSize + 0.5);
            int yTo   = (int)(data.South + data.BrushSize + 0.5);

            if (xFrom < 0)
            {
                xFrom = 0;
            }

            if (yFrom < 0)
            {
                yFrom = 0;
            }

            if (xTo >= scene.SizeX)
            {
                xTo = (int)scene.SizeX - 1;
            }

            if (yTo > scene.SizeY)
            {
                yTo = (int)scene.SizeY - 1;
            }

            for (int x = xFrom; x <= xTo; x++)
            {
                for (int y = yFrom; y <= yTo; y++)
                {
                    var pos = new Vector3(x, y, 0);
                    if (!scene.CanTerraform(agentOwner, pos))
                    {
                        continue;
                    }

                    double z = (modify.Seconds < 4.0) ?
                               SphericalFactor(x, y, data.West, data.South, strength) * modify.Seconds * 0.25f :
                               1;

                    double delta = modify.Height - scene.Terrain[(uint)x, (uint)y];
                    if (Math.Abs(delta) > 0.1)
                    {
                        if (z > 1)
                        {
                            z = 1;
                        }
                        else if (z < 0)
                        {
                            z = 0;
                        }
                        delta *= z;
                    }

                    if (Math.Abs(delta) >= Double.Epsilon) // add in non-zero amount
                    {
                        LayerPatch lp = scene.Terrain.AdjustTerrain((uint)x, (uint)y, delta);
                        if (lp != null && !changed.Contains(lp))
                        {
                            changed.Add(lp);
                        }
                    }
                }
            }

            if (changed.Count != 0)
            {
                foreach (LayerPatch lp in changed)
                {
                    lp.IncrementSerial();
                }
                scene.Terrain.UpdateTerrainDataToClients();
            }
        }
 public LoginController(SceneInterface scene)
 {
     m_Scene = scene;
 }