Exemplo n.º 1
0
        public byte[] WriteJpeg2000Image()
        {
            if (terrainRenderer != null)
            {
                terrainRenderer.TerrainToBitmap(mapbmp);
            }

            if (drawPrimVolume)
            {
                DrawObjectVolume(m_scene, mapbmp);
            }

            int t = Environment.TickCount;

            try
            {
                imageData = OpenJPEG.EncodeFromImage(mapbmp.Bitmap, true);
            }
            catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
            {
                m_log.Error("Failed generating terrain map: " + e);
            }
            t = Environment.TickCount - t;
            m_log.InfoFormat("[MAPTILE] encoding of image needed {0}ms", t);

            return(imageData);
        }
Exemplo n.º 2
0
        public Bitmap CreateMapTile()
        {
            bool   drawPrimVolume = true;
            string tileRenderer   = "WarpTileRenderer";

            if (m_config.Configs["MapModule"] != null)
            {
                drawPrimVolume = m_config.Configs["MapModule"].GetBoolean("DrawPrimOnMapTile", drawPrimVolume);
                tileRenderer   = m_config.Configs["MapModule"].GetString("TerrainTileRenderer", tileRenderer);
            }

            if (tileRenderer == "TexturedMapTileRenderer")
            {
                terrainRenderer = new TexturedMapTileRenderer();
            }
            else if (tileRenderer == "ShadedMapTileRenderer")
            {
                terrainRenderer = new ShadedMapTileRenderer();
            }
            else
            {
                terrainRenderer = new WarpTileRenderer();
                //It does this automatically
                drawPrimVolume = false;
            }

            terrainRenderer.Initialise(m_scene, m_config);

            Bitmap mapbmp = new Bitmap(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            terrainRenderer.TerrainToBitmap(mapbmp);

            if (drawPrimVolume)
            {
                if (mapbmp != null) //If something goes seriously wrong, this DOES happen
                {
                    DrawObjectVolume(m_scene, mapbmp);
                }
            }
            if (m_mapping != null)
            {
                m_mapping.Clear();
            }
            return(mapbmp);
        }
Exemplo n.º 3
0
        public byte[] WriteJpeg2000Image(string gradientmap)
        {
            byte[] imageData = null;

            bool drawPrimVolume = true;
            bool textureTerrain = false;

            try
            {
                IConfig startupConfig = m_config.Configs["Startup"];
                drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume);
                textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain);
            }
            catch
            {
                m_log.Warn("[MAPTILE]: Failed to load StartupConfig");
            }

            if (textureTerrain)
            {
                terrainRenderer = new TexturedMapTileRenderer();
            }
            else
            {
                terrainRenderer = new ShadedMapTileRenderer();
            }
            terrainRenderer.Initialise(m_scene, m_config);

            Bitmap mapbmp = new Bitmap(256, 256);

            //long t = System.Environment.TickCount;
            //for (int i = 0; i < 10; ++i) {
            terrainRenderer.TerrainToBitmap(mapbmp);
            //}
            //t = System.Environment.TickCount - t;
            //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);


            if (drawPrimVolume)
            {
                DrawObjectVolume(m_scene, mapbmp);
            }

            try
            {
                imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
            }
            catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
            {
                m_log.Error("Failed generating terrain map: " + e);
            }

            return(imageData);
        }
Exemplo n.º 4
0
        public void CreateMapTile(out Bitmap terrainBMP, out Bitmap mapBMP)
        {
            int    start          = Environment.TickCount;
            bool   drawPrimVolume = true;
            string tileRenderer   = "WarpTileRenderer";

            if (m_config.Configs["MapModule"] != null)
            {
                drawPrimVolume = m_config.Configs["MapModule"].GetBoolean("DrawPrimOnMapTile", drawPrimVolume);
                tileRenderer   = m_config.Configs["MapModule"].GetString("TerrainTileRenderer", tileRenderer);
            }

            if (tileRenderer == "TexturedMapTileRenderer")
            {
                terrainRenderer = new TexturedMapTileRenderer();
            }
            else if (tileRenderer == "ShadedMapTileRenderer")
            {
                terrainRenderer = new ShadedMapTileRenderer();
            }
            else
            {
                tileRenderer    = "WarpTileRenderer";
                terrainRenderer = new WarpTileRenderer();
                drawPrimVolume  = false;
            }

            terrainRenderer.Initialise(m_scene, m_config);

            mapBMP     = null;
            terrainBMP = new Bitmap(Constants.RegionSize, Constants.RegionSize, PixelFormat.Format24bppRgb);
            terrainBMP = terrainRenderer.TerrainToBitmap(terrainBMP);

            if (drawPrimVolume && terrainBMP != null)
            {
                mapBMP = new Bitmap(terrainBMP);
                mapBMP = DrawObjectVolume(m_scene, mapBMP);
            }
            else
            {
                if (terrainBMP != null)
                {
                    mapBMP = new Bitmap(terrainBMP);
                }
            }

            if (m_mapping != null)
            {
                SaveCache();
                m_mapping.Clear();
            }
            MainConsole.Instance.InfoFormat("[MapTileGenerator]: Generating Maptile using {0} took {1} ms", tileRenderer, (Environment.TickCount - start));
        }
        public Bitmap CreateMapTile()
        {
            bool   drawPrimVolume   = true;
            bool   textureTerrain   = false;
            bool   generateMaptiles = true;
            Bitmap mapbmp;

            string[] configSections = new string[] { "Map", "Startup" };

            drawPrimVolume
                = Util.GetConfigVarFromSections <bool>(m_config, "DrawPrimOnMapTile", configSections, drawPrimVolume);
            textureTerrain
                = Util.GetConfigVarFromSections <bool>(m_config, "TextureOnMapTile", configSections, textureTerrain);
            generateMaptiles
                = Util.GetConfigVarFromSections <bool>(m_config, "GenerateMaptiles", configSections, generateMaptiles);

            if (generateMaptiles)
            {
                if (textureTerrain)
                {
                    terrainRenderer = new TexturedMapTileRenderer();
                }
                else
                {
                    terrainRenderer = new ShadedMapTileRenderer();
                }

                terrainRenderer.Initialise(m_scene, m_config);

                mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                //long t = System.Environment.TickCount;
                //for (int i = 0; i < 10; ++i) {
                terrainRenderer.TerrainToBitmap(mapbmp);
                //}
                //t = System.Environment.TickCount - t;
                //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);

                if (drawPrimVolume)
                {
                    DrawObjectVolume(m_scene, mapbmp);
                }
            }
            else
            {
                mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
            }
            return(mapbmp);
        }
Exemplo n.º 6
0
        public Bitmap CreateMapTile()
        {
            bool drawPrimVolume = true;
            bool textureTerrain = false;

            try
            {
                IConfig startupConfig = m_config.Configs["Startup"];
                drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume);
                textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain);
            }
            catch
            {
                m_log.Warn("[MAPTILE]: Failed to load StartupConfig");
            }

            if (textureTerrain)
            {
                terrainRenderer = new TexturedMapTileRenderer();
            }
            else
            {
                terrainRenderer = new ShadedMapTileRenderer();
            }
            terrainRenderer.Initialise(m_scene, m_config);

            Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            //long t = System.Environment.TickCount;
            //for (int i = 0; i < 10; ++i) {
            terrainRenderer.TerrainToBitmap(mapbmp);
            //}
            //t = System.Environment.TickCount - t;
            //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);


            if (drawPrimVolume)
            {
                DrawObjectVolume(m_scene, mapbmp);
            }

            return(mapbmp);
        }
Exemplo n.º 7
0
        public Bitmap CreateMapTile()
        {
            bool   drawPrimVolume   = true;
            bool   textureTerrain   = false;
            bool   generateMaptiles = true;
            Bitmap mapbmp;

            string[] configSections = new string[] { "Map", "Startup" };

            drawPrimVolume
                = Util.GetConfigVarFromSections <bool>(m_config, "DrawPrimOnMapTile", configSections, drawPrimVolume);
            textureTerrain
                = Util.GetConfigVarFromSections <bool>(m_config, "TextureOnMapTile", configSections, textureTerrain);
            generateMaptiles
                = Util.GetConfigVarFromSections <bool>(m_config, "GenerateMaptiles", configSections, generateMaptiles);

            if (generateMaptiles)
            {
                if (String.IsNullOrEmpty(m_scene.RegionInfo.MaptileStaticFile))
                {
                    if (textureTerrain)
                    {
                        terrainRenderer = new TexturedMapTileRenderer();
                    }
                    else
                    {
                        terrainRenderer = new ShadedMapTileRenderer();
                    }

                    terrainRenderer.Initialise(m_scene, m_config);

                    mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height,
                                        System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                    //long t = System.Environment.TickCount;
                    //for (int i = 0; i < 10; ++i) {
                    terrainRenderer.TerrainToBitmap(mapbmp);
                    //}
                    //t = System.Environment.TickCount - t;
                    //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);

                    if (drawPrimVolume)
                    {
                        DrawObjectVolume(m_scene, mapbmp);
                    }
                }
                else
                {
                    try
                    {
                        mapbmp = new Bitmap(m_scene.RegionInfo.MaptileStaticFile);
                    }
                    catch (Exception)
                    {
                        m_log.ErrorFormat(
                            "[MAPTILE]: Failed to load Static map image texture file: {0} for {1}",
                            m_scene.RegionInfo.MaptileStaticFile, m_scene.Name);
                        //mapbmp = new Bitmap((int)m_scene.Heightmap.Width, (int)m_scene.Heightmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                        mapbmp = null;
                    }

                    if (mapbmp != null)
                    {
                        m_log.DebugFormat(
                            "[MAPTILE]: Static map image texture file {0} found for {1}",
                            m_scene.RegionInfo.MaptileStaticFile, m_scene.Name);
                    }
                }
            }
            else
            {
                mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
            }

            return(mapbmp);
        }