当前位置: 首页>>代码示例>>C#>>正文


C# Scenes.TerrainChannel类代码示例

本文整理汇总了C#中OpenSim.Region.Framework.Scenes.TerrainChannel的典型用法代码示例。如果您正苦于以下问题:C# TerrainChannel类的具体用法?C# TerrainChannel怎么用?C# TerrainChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TerrainChannel类属于OpenSim.Region.Framework.Scenes命名空间,在下文中一共展示了TerrainChannel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadStream

        public ITerrainChannel LoadStream(Stream s)
        {
            TerrainChannel retval = new TerrainChannel();

            BinaryReader bs = new BinaryReader(s);

            bool eof = false;
            if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
            {
                int w = 256;
                int h = 256;

                // Terragen file
                while (eof == false)
                {
                    string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4));
                    switch (tmp)
                    {
                        case "SIZE":
                            int sztmp = bs.ReadInt16() + 1;
                            w = sztmp;
                            h = sztmp;
                            bs.ReadInt16();
                            break;
                        case "XPTS":
                            w = bs.ReadInt16();
                            bs.ReadInt16();
                            break;
                        case "YPTS":
                            h = bs.ReadInt16();
                            bs.ReadInt16();
                            break;
                        case "ALTW":
                            eof = true;
                            Int16 heightScale = bs.ReadInt16();
                            Int16 baseHeight = bs.ReadInt16();
                            retval = new TerrainChannel(w, h);
                            int x;
                            for (x = 0; x < w; x++)
                            {
                                int y;
                                for (y = 0; y < h; y++)
                                {
                                    retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0;
                                }
                            }
                            break;
                        default:
                            bs.ReadInt32();
                            break;
                    }
                }
            }

            bs.Close();

            return retval;
        }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:58,代码来源:Terragen.cs

示例2: BrushTest

        public void BrushTest()
        {
            int midRegion = (int)Constants.RegionSize / 2;

            // Create a mask that covers only the left half of the region
            bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
            int x;
            int y;
            for (x = 0; x < midRegion; x++)
            {
                for (y = 0; y < (int)Constants.RegionSize; y++)
                {
                    allowMask[x,y] = true;
                }
            }

            //
            // Test RaiseSphere
            //
            TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
            ITerrainPaintableEffect effect = new RaiseSphere();

            effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
                0, midRegion - 1,0, (int)Constants.RegionSize -1);
            Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
            Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
            Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
            Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128).");
//            Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128).");
            //
            // Test LowerSphere
            //
            map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
            for (x=0; x<map.Width; x++)
            {
                for (y=0; y<map.Height; y++)
                {
                    map[x,y] = 1.0;
                }
            }
            effect = new LowerSphere();

            effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
                0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1);
            Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
            Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
            Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
            Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128).");
            Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128).");
//            Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128).");
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:51,代码来源:TerrainTest.cs

示例3: LoadFile

        public virtual ITerrainChannel LoadFile(string filename, int offsetX, int offsetY, int fileWidth, int fileHeight, int w, int h)
        {
            Bitmap bitmap = new Bitmap(filename);
            ITerrainChannel retval = new TerrainChannel(true);

            for (int x = 0; x < retval.Width; x++)
            {
                for (int y = 0; y < retval.Height; y++)
                {
                    retval[x, y] = bitmap.GetPixel(offsetX * retval.Width + x, (bitmap.Height - (retval.Height * (offsetY + 1))) + retval.Height - y - 1).GetBrightness() * 128;
                }
            }

            return retval;
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:15,代码来源:GenericSystemDrawing.cs

示例4: LoadBitmap

        protected virtual ITerrainChannel LoadBitmap(Bitmap bitmap)
        {
            ITerrainChannel retval = new TerrainChannel(bitmap.Width, bitmap.Height);

            int x;
            for (x = 0; x < bitmap.Width; x++)
            {
                int y;
                for (y = 0; y < bitmap.Height; y++)
                {
                    retval[x, y] = bitmap.GetPixel(x, bitmap.Height - y - 1).GetBrightness() * 128;
                }
            }

            return retval;
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:16,代码来源:GenericSystemDrawing.cs

示例5: BrushTest

        public void BrushTest()
        {
            bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
            int x;
            int y;
            for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++)
            {
                for (y = 0; y < (int)Constants.RegionSize; y++)
                {
                    allowMask[x,y] = true;
                }
            }

            //
            // Test RaiseSphere
            //
            TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
            ITerrainPaintableEffect effect = new RaiseSphere();

            effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1);
            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128).");
            Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128).");
            Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128).");
            Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128).");
            Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128).");

            //
            // Test LowerSphere
            //
            map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
            for (x=0; x<map.Width; x++)
            {
                for (y=0; y<map.Height; y++)
                {
                    map[x,y] = 1.0;
                }
            }
            effect = new LowerSphere();

            effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0);
            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
            Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128).");
            Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128).");
            Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128).");
            Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128).");
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:47,代码来源:TerrainTest.cs

示例6: BrushTest

        public void BrushTest()
        {
            bool[,] allowMask = new bool[256, 256];
            int x;
            int y;
            for (x=0; x<128; x++)
            {
                for (y=0; y<256; y++)
                {
                    allowMask[x,y] = true;
                }
            }

            //
            // Test RaiseSphere
            //
            TerrainChannel map = new TerrainChannel(256, 256);
            ITerrainPaintableEffect effect = new RaiseSphere();

            effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 0.1);
            Assert.That(map[127, 128] > 0.0, "Raise brush should raising value at this point (127,128).");
            Assert.That(map[124, 128] > 0.0, "Raise brush should raising value at this point (124,128).");
            Assert.That(map[123, 128] == 0.0, "Raise brush should not change value at this point (123,128).");
            Assert.That(map[128, 128] == 0.0, "Raise brush should not change value at this point (128,128).");
            Assert.That(map[0, 128] == 0.0, "Raise brush should not change value at this point (0,128).");

            //
            // Test LowerSphere
            //
            map = new TerrainChannel(256, 256);
            for (x=0; x<map.Width; x++)
            {
                for (y=0; y<map.Height; y++)
                {
                    map[x,y] = 1.0;
                }
            }
            effect = new LowerSphere();

            effect.PaintEffect(map, allowMask, 128.0, 128.0, -1.0, 2, 6.0);
            Assert.That(map[127, 128] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
            Assert.That(map[127, 128] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
            Assert.That(map[124, 128] < 1.0, "Lower brush should lowering value at this point (124,128).");
            Assert.That(map[123, 128] == 1.0, "Lower brush should not change value at this point (123,128).");
            Assert.That(map[128, 128] == 1.0, "Lower brush should not change value at this point (128,128).");
            Assert.That(map[0, 128] == 1.0, "Lower brush should not change value at this point (0,128).");
        }
开发者ID:Ideia-Boa,项目名称:opensim,代码行数:47,代码来源:TerrainTest.cs

示例7: LoadWorldMap

        /// <summary>
        /// Loads the World heightmap
        /// </summary>
        public override void LoadWorldMap()
        {
            try
            {
                double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID);
                if (map == null)
                {
                    // This should be in the Terrain module, but it isn't because
                    // the heightmap is needed _way_ before the modules are initialized...
                    IConfig terrainConfig = m_config.Configs["Terrain"];
                    String m_InitialTerrain = "pinhead-island";
                    if (terrainConfig != null)
                        m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);

                    m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
                    Heightmap = new TerrainChannel(m_InitialTerrain);

                    SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
                }
                else
                {
                    Heightmap = new TerrainChannel(map);
                }
            }
            catch (IOException e)
            {
                m_log.WarnFormat(
                    "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
                    e.Message, e.StackTrace);
                
                // Non standard region size.    If there's an old terrain in the database, it might read past the buffer
                #pragma warning disable 0162
                if ((int)Constants.RegionSize != 256)
                {
                    Heightmap = new TerrainChannel();

                    SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat(
                    "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
            }
        }
开发者ID:CCIR,项目名称:opensim,代码行数:48,代码来源:Scene.cs

示例8: LoadStream

        public ITerrainChannel LoadStream(Stream s)
        {
            // The raw format doesn't contain any dimension information.
            // Guess the square dimensions by using the length of the raw file.
            double dimension = Math.Sqrt((double)(s.Length / 4));
            // Regions are always multiples of 256.
            int trimmedDimension = (int)dimension - ((int)dimension % (int)Constants.RegionSize);
            if (trimmedDimension < Constants.RegionSize)
                trimmedDimension = (int)Constants.RegionSize;

            TerrainChannel retval = new TerrainChannel(trimmedDimension, trimmedDimension);

            BinaryReader bs = new BinaryReader(s);
            int y;
            for (y = 0; y < retval.Height; y++)
            {
                int x;
                for (x = 0; x < retval.Width; x++)
                {
                    retval[x, y] = bs.ReadSingle();
                }
            }

            bs.Close();

            return retval;
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:27,代码来源:RAW32.cs

示例9: LoadWorldMap

        /// <summary>
        /// Loads the World heightmap
        /// </summary>
        public override void LoadWorldMap()
        {
            try
            {
                double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID);
                if (map == null)
                {
                    m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain.");
                    Heightmap = new TerrainChannel();

                    SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
                }
                else
                {
                    Heightmap = new TerrainChannel(map);
                }
            }
            catch (IOException e)
            {
                m_log.WarnFormat(
                    "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
                    e.Message, e.StackTrace);

                // Non standard region size.    If there's an old terrain in the database, it might read past the buffer
#pragma warning disable 0162
                if ((int)Constants.RegionSize != 256)
                {
                    Heightmap = new TerrainChannel();

                    SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
                }
            }
            catch (Exception e)
            {
                m_log.WarnFormat(
                    "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
            }
        }
开发者ID:UbitUmarov,项目名称:Ubit-opensim,代码行数:41,代码来源:Scene.cs

示例10: MakeCopy

 public ITerrainChannel MakeCopy()
 {
     TerrainChannel copy = new TerrainChannel(false, m_scene);
     copy.m_map = (short[])m_map.Clone();
     copy.taint = (bool[,])taint.Clone();
     return copy;
 }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:7,代码来源:TerrainChannel.cs

示例11: ResetWater

 /// <summary>
 /// Reset the terrain of this region to the default
 /// </summary>
 public void ResetWater()
 {
     TerrainChannel channel = new TerrainChannel(m_scene);
     m_waterChannel = channel;
     SaveRevertWater(m_waterChannel);
     CheckForTerrainUpdates(false, true, true);
 }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:10,代码来源:TerrainModule.cs

示例12: LoadTerrain

        public virtual short[] LoadTerrain(IScene scene, bool RevertMap, int RegionSizeX, int RegionSizeY)
        {
            if (!m_loaded)
            {
                m_loaded = true;
                ReadConfig(scene, scene.Config.Configs["FileBasedSimulationData"]);
                ReadBackup(scene);
            }
            ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>();
            if (RevertMap)
            {
                ITerrainChannel channel = new TerrainChannel(false, scene);
                if (m_revertTerrain == null)
                {
                    if (m_shortrevertTerrain != null) //OpenSim style
                        terrainModule.TerrainRevertMap = new TerrainChannel(m_shortrevertTerrain, scene);
                    else if (m_oldstylerevertTerrain != null)
                    {
                        MemoryStream ms = new MemoryStream(m_oldstylerevertTerrain);
                        if (terrainModule != null)
                            terrainModule.LoadRevertMapFromStream(".r32", ms, 0, 0);
                    }
                }
                else
                    //New style
                    terrainModule.TerrainRevertMap = ReadFromData(m_revertTerrain, scene);
                //Make sure the size is right!
                if (terrainModule.TerrainRevertMap != null &&
                    terrainModule.TerrainRevertMap.Height != scene.RegionInfo.RegionSizeX)
                    terrainModule.TerrainRevertMap = null;
                m_revertTerrain = null;
                m_oldstylerevertTerrain = null;
                m_shortrevertTerrain = null;
                return null;
            }
            else
            {
                if (m_terrain == null)
                {
                    if (m_shortterrain != null) //OpenSim style
                        terrainModule.TerrainMap = new TerrainChannel(m_shortterrain, scene);
                    else if (m_oldstyleterrain != null)
                    {
//Old style
                        ITerrainChannel channel = new TerrainChannel(false, scene);
                        MemoryStream ms = new MemoryStream(m_oldstyleterrain);
                        if (terrainModule != null)
                            terrainModule.LoadFromStream(".r32", ms, 0, 0);
                    }
                }
                else
                    //New style
                    terrainModule.TerrainMap = ReadFromData(m_terrain, scene);
                //Make sure the size is right!
                if (terrainModule.TerrainMap != null &&
                    terrainModule.TerrainMap.Height != scene.RegionInfo.RegionSizeX)
                    terrainModule.TerrainMap = null;
                m_terrain = null;
                m_oldstyleterrain = null;
                m_shortterrain = null;
                return null;
            }
        }
开发者ID:Gnu32,项目名称:Silverfin,代码行数:63,代码来源:FileBasedSimulationData.cs

示例13: ResetTerrain

 /// <summary>
 ///   Reset the terrain of this region to the default
 /// </summary>
 public void ResetTerrain()
 {
     if (!m_noTerrain)
     {
         TerrainChannel channel = new TerrainChannel(m_scene);
         m_channel = channel;
         m_scene.SimulationDataService.Tainted();
         m_scene.RegisterModuleInterface(m_channel);
         CheckForTerrainUpdates(false, true, false);
     }
 }
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:14,代码来源:TerrainModule.cs

示例14: InternalLoadFromStream

        /// <summary>
        ///   Loads a terrain file from a stream and installs it in the scene.
        /// </summary>
        /// <param name = "filename">Filename to terrain file. Type is determined by extension.</param>
        /// <param name = "stream"></param>
        public ITerrainChannel InternalLoadFromStream(string filename, Stream stream, int offsetX, int offsetY,
                                                      ITerrainChannel update)
        {
            ITerrainChannel channel = null;
#if (!ISWIN)
            foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
            {
                if (filename.EndsWith(loader.Key))
                {
                    lock (m_scene)
                    {
                        try
                        {
                            channel = loader.Value.LoadStream(stream, m_scene);
                            if (channel != null)
                            {
                                channel.Scene = m_scene;
                                if (update == null || (update.Height == channel.Height && update.Width == channel.Width))
                                {
                                    if (m_scene.RegionInfo.RegionSizeX != channel.Width || m_scene.RegionInfo.RegionSizeY != channel.Height)
                                    {
                                        if ((channel.Width) > m_scene.RegionInfo.RegionSizeX || (channel.Height) > m_scene.RegionInfo.RegionSizeY)
                                        {
                                            TerrainChannel c = new TerrainChannel(true, m_scene);
                                            for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x++)
                                            {
                                                for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y++)
                                                {
                                                    c[x, y] = channel[x, y];
                                                }
                                            }
                                            return c;
                                        }
                                        return null;
                                    }
                                }
                                else
                                {
                                    //Make sure it is in bounds
                                    if ((offsetX + channel.Width) > update.Width || (offsetY + channel.Height) > update.Height)
                                    {
                                        MainConsole.Instance.Error("[TERRAIN]: Unable to load heightmap, the terrain you have given is larger than the current region.");
                                        return null;
                                    }
                                    else
                                    {
                                        //Merge the terrains together at the specified offset
                                        for (int x = offsetX; x < offsetX + channel.Width; x++)
                                        {
                                            for (int y = offsetY; y < offsetY + channel.Height; y++)
                                            {
                                                update[x, y] = channel[x - offsetX, y - offsetY];
                                            }
                                        }
                                        return update;
                                    }
                                }
                            }
                        }
                        catch (NotImplementedException)
                        {
                            MainConsole.Instance.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value + " parser does not support file loading. (May be save only)");
                            throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
                        }
                    }

                    MainConsole.Instance.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
                    return channel;
                }
            }
#else
            foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders.Where(loader => filename.EndsWith(loader.Key)))
            {
                lock (m_scene)
                {
                    try
                    {
                        channel = loader.Value.LoadStream(stream, m_scene);
                        if (channel != null)
                        {
                            channel.Scene = m_scene;
                            if (update == null || (update.Height == channel.Height &&
                                                   update.Width == channel.Width))
                            {
                                if (m_scene.RegionInfo.RegionSizeX != channel.Width ||
                                    m_scene.RegionInfo.RegionSizeY != channel.Height)
                                {
                                    if ((channel.Width) > m_scene.RegionInfo.RegionSizeX ||
                                        (channel.Height) > m_scene.RegionInfo.RegionSizeY)
                                    {
                                        TerrainChannel c = new TerrainChannel(true, m_scene);
                                        for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x++)
                                        {
                                            for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y++)
                                            {
//.........这里部分代码省略.........
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:101,代码来源:TerrainModule.cs

示例15: ResetWater

 /// <summary>
 ///   Reset the terrain of this region to the default
 /// </summary>
 public void ResetWater()
 {
     if (!m_noTerrain)
     {
         TerrainChannel channel = new TerrainChannel(m_scene);
         m_waterChannel = channel;
         m_scene.SimulationDataService.Tainted();
         CheckForTerrainUpdates(false, true, true);
     }
 }
开发者ID:samiam123,项目名称:Aurora-Sim,代码行数:13,代码来源:TerrainModule.cs


注:本文中的OpenSim.Region.Framework.Scenes.TerrainChannel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。