/// <summary>Raises the LandPatchReceived event</summary>
        /// <param name="e">A LandPatchReceivedEventArgs object containing the
        /// data returned from the simulator</param>
        protected virtual void OnLandPatchReceived(LandPatchReceivedEventArgs e)
        {
            EventHandler <LandPatchReceivedEventArgs> handler = m_LandPatchReceivedEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Beispiel #2
0
 void Terrain_LandPatchReceived(object sender, LandPatchReceivedEventArgs e)
 {
     if (e.Simulator.Handle == Client.Network.CurrentSim.Handle)
     {
         terrainModified = true;
     }
 }
        private void UpdateHeightmap(LandPatchReceivedEventArgs e)
        {
            ulong handle = e.Simulator.Handle;

            lock (mMappedParcels) {
                if (!mMappedParcels.ContainsKey(handle))
                    mMappedParcels.Add(handle, new HashSet<string>());
                mMappedParcels[handle].Add(e.X + "," + e.Y);
            }

            int x = e.X * 16;
            int y = e.Y * 16;

            uint globalX, globalY;
            Utils.LongToUInts(handle, out globalX, out globalY);

            float[,] terrainHeight = new float[16, 16];
            for (int j = 0; j < 16; j++) {
                for (int i = 0; i < 16; i++) {
                    terrainHeight[i, j] = e.HeightMap[j * 16 + i];
                }
            }

            while (!mLoggedIn)
                Thread.Sleep(500);

            x += (int) globalX - mStartLocation.X;
            y += (int) globalY - mStartLocation.Y;
            mCoordinator.SetHeightmapSection(terrainHeight, x, y, mMappedParcels[handle].Count > 250);

            int w = mCoordinator.Heightmap.GetLength(0) / 256;
            int h = mCoordinator.Heightmap.GetLength(1) / 256;
            int numRegions = w * h;

            lock (mMappedParcels) {
                if (mMappedParcels[handle].Count == 256) {
                    mFinishedRegions.Add(handle);
                    ThisLogger.Info("Finished mapping " + e.Simulator.Name);
                } if (mFinishedRegions.Count == numRegions && mConfig.AutoLogout)
                    Logout();
            }
        }
        void Terrain_LandPatchReceived(object sender, LandPatchReceivedEventArgs e)
        {
            DateTime start = DateTime.Now;
            if (e.X >= 16 || e.Y >= 16) {
                Logger.Log(String.Format("Bad patch coordinates, x = {0}, y = {1}", e.X, e.Y), Helpers.LogLevel.Warning);
                return;
            }

            if (e.PatchSize != 16) {
                Logger.Log(String.Format("Unhandled patch size {0} x {1}", e.PatchSize, +e.PatchSize), Helpers.LogLevel.Warning);
                return;
            }

            string simName = e.Simulator.Name;

            UpdateHeightmap(e);
        }
 /// <summary>Raises the LandPatchReceived event</summary>
 /// <param name="e">A LandPatchReceivedEventArgs object containing the
 /// data returned from the simulator</param>
 protected virtual void OnLandPatchReceived(LandPatchReceivedEventArgs e)
 {
     EventHandler<LandPatchReceivedEventArgs> handler = m_LandPatchReceivedEvent;
     if (handler != null)
         handler(this, e);
 }
Beispiel #6
0
        public void Terrain_LandPatchReceived(object sender, LandPatchReceivedEventArgs e)
        {
            if (e.X >= 16 || e.Y >= 16)
            {
                Console.WriteLine("Bad patch coordinates, (" + e.X + ", " + e.Y + ")");
                return;
            }

            if (e.PatchSize != 16)
            {
                Console.WriteLine("Unhandled patch size " + e.PatchSize + "x" + e.PatchSize);
                return;
            }
            Hashtable hash = new Hashtable();
            hash.Add("MessageType", "LandPatch");
            hash.Add("OffsetX", e.X * 16);
            hash.Add("OffsetY", e.Y * 16);
            hash.Add("Region", e.Simulator.Name);
            hash.Add("WaterLevel", e.Simulator.WaterHeight); // Is there anywhere better to put this?

            float[,] landscape = new float[16, 16];
            for (int i = 0; i < 16; ++i)
            {
                for (int j = 0; j < 16; ++j)
                {
                    landscape[i, j] = e.HeightMap[i * 16 + j];
                }
            }
            // Ugly hack to fix the JSON encoding.
            float[][] resp = new float[16][];
            for (int i = 0; i < 16; ++i)
            {
                resp[i] = new float[16];
                for (int j = 0; j < 16; ++j)
                {
                    resp[i][j] = landscape[i, j];
                }
            }
            hash.Add("Patch", resp);
            enqueue(hash);
        }
Beispiel #7
0
        /// <summary>Raises the LandPatchReceived event</summary>
        /// <param name="e">A LandPatchReceivedEventArgs object containing the
        /// data returned from the simulator</param>
        protected virtual void OnLandPatchReceived(LandPatchReceivedEventArgs e)
        {
            EventHandler <LandPatchReceivedEventArgs> handler = m_LandPatchReceivedEvent;

            handler?.Invoke(this, e);
        }
Beispiel #8
0
        void Terrain_LandPatchReceived(object sender, LandPatchReceivedEventArgs e)
        {
            if (e.X >= 16 || e.Y >= 16)
            {
                Console.WriteLine("Bad patch coordinates, x = " + e.X + ", y = " + e.Y);
                return;
            }

            if (e.PatchSize != 16)
            {
                Console.WriteLine("Unhandled patch size " + e.PatchSize + "x" + e.PatchSize);
                return;
            }

            Bitmap patch = new Bitmap(16, 16, PixelFormat.Format24bppRgb);

            for (int yp = 0; yp < 16; yp++)
            {
                for (int xp = 0; xp < 16; xp++)
                {
                    float height = e.HeightMap[(15-yp) * 16 + xp]; // data[0] is south west
                    Color color;
                    if (height >= e.Simulator.WaterHeight)
                    {
                        float maxVal = (float)Math.Log(Math.Abs(512+1-e.Simulator.WaterHeight),2);
                        float lgHeight = (float)Math.Log(Math.Abs(height + 1 - e.Simulator.WaterHeight), 2);
                        int colorVal1 = Utils.FloatToByte(lgHeight, e.Simulator.WaterHeight, maxVal);
                        int colorVal2 = Utils.FloatToByte(height, e.Simulator.WaterHeight, 25.0f);
                        color = Color.FromArgb(255, colorVal2, colorVal1);
                    }
                    else
                    {
                        const float minVal = -5.0f;
                        float maxVal = e.Simulator.WaterHeight;
                        int colorVal1 = Utils.FloatToByte(height, -5.0f, minVal + (maxVal - minVal) * 1.5f);
                        int colorVal2 = Utils.FloatToByte(height, -5.0f, maxVal);
                        color = Color.FromArgb(colorVal1, colorVal2, 255);
                    }
                    patch.SetPixel(xp, yp, color); // 0, 0 is top left
                }
            }

            Boxes[e.X, 15-e.Y].Image = (System.Drawing.Image)patch;
        }
Beispiel #9
0
 public virtual void Terrain_OnLandPatch(object sender, LandPatchReceivedEventArgs e) { OnEvent("On-Land-Patch", paramNamesOnLandPatch, paramTypesOnLandPatch, e.Simulator, e.X, e.Y, e.PatchSize, e.HeightMap); }
 void Terrain_LandPatchReceived(object sender, LandPatchReceivedEventArgs e)
 {
     //leave other regions out temporarily
     if (e.Simulator.Handle != Client.Network.CurrentSim.Handle) return;
     //Debug.Log ("LandPatchReceive");
     terrainModified = true;
 }
        public override void Terrain_OnLandPatch(object sender, LandPatchReceivedEventArgs e)
        {
            //client.Terrain.LandPatchReceived -= Terrain_OnLandPatch;
            //Simulator simulator, int x, int y, int width, float[] data
            //Console.Write(",");
            //SimRegion R = SimRegion.GetRegion(simulator);
            //base.Terrain_OnLandPatch(simulator, x, y, width, null);

            //throw new NotImplementedException();
            //   SendNewEvent("On-Land-Patch", x, y, width, BVHData);
            //            WriteLine("ClientManager Terrain_OnLandPatch: "+simulator.ToString()+"/"+x.ToString()+"/"+y.ToString()+" w="+width.ToString());
        }