bool m_renderMeshes = true; // true if to render meshes rather than just bounding boxes #region IMapTileTerrainRenderer Members public void Initialize(IScene scene, IConfigSource config) { m_scene = scene; m_imgDecoder = m_scene.RequestModuleInterface <IJ2KDecoder> (); m_config = config; m_assetCacheDir = m_config.Configs ["AssetCache"].GetString("CacheDirectory", m_assetCacheDir); if (m_assetCacheDir == "") { var defpath = scene.RequestModuleInterface <ISimulationBase> ().DefaultDataPath; m_assetCacheDir = System.IO.Path.Combine(defpath, Constants.DEFAULT_ASSETCACHE_DIR); } List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers [0]); MainConsole.Instance.Debug("[WarpTile generator]: Loaded prim mesher " + m_primMesher); } else { MainConsole.Instance.Info("[WarpTile generator]: No prim mesher loaded, prim rendering will be disabled"); } var mapConfig = m_config.Configs ["MapModule"]; if (mapConfig != null) { m_texturePrimSize = mapConfig.GetFloat("TexturePrimSize", m_texturePrimSize); m_renderMeshes = mapConfig.GetBoolean("RenderMeshes", m_renderMeshes); } ReadCacheMap(); }
public Bitmap CreateMapTile() { List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); } cameraPos = new Vector3( (m_scene.RegionInfo.RegionSizeX) * 0.5f, (m_scene.RegionInfo.RegionSizeY) * 0.5f, m_cameraHeight); cameraDir = -Vector3.UnitZ; viewWitdh = (int)m_scene.RegionInfo.RegionSizeX; viewHeight = (int)m_scene.RegionInfo.RegionSizeY; orto = true; Bitmap tile = GenImage(); // image may be reloaded elsewhere, so no compression format string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png"; tile.Save(filename, ImageFormat.Png); m_primMesher = null; return(tile); }
public void Start(Simian server) { this.server = server; // Search for a the best available OpenMetaverse.Rendering plugin List <string> renderers = RenderingLoader.ListRenderers(AppDomain.CurrentDomain.BaseDirectory); string renderer = renderers.Find( delegate(string current) { return(current.Contains("OpenMetaverse.Rendering.GPL.dll")); }); if (String.IsNullOrEmpty(renderer)) { if (renderers.Count > 0) { renderer = renderers[0]; } else { Logger.Log("No suitable OpenMetaverse.Rendering plugins found", Helpers.LogLevel.Error); return; } } Renderer = RenderingLoader.LoadRenderer(renderer); }
bool m_renderMeshes = true; // true if to render meshes rather than just bounding boxes #region IMapTileTerrainRenderer Members public void Initialise(IScene scene, IConfigSource config) { m_scene = scene; m_imgDecoder = m_scene.RequestModuleInterface <IJ2KDecoder>(); m_config = config; m_assetCacheDir = m_config.Configs ["AssetCache"].GetString("CacheDirectory", m_assetCacheDir); List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); MainConsole.Instance.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher); } else { MainConsole.Instance.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } var mapConfig = m_config.Configs ["MapModule"]; if (mapConfig != null) { m_texturePrimSize = mapConfig.GetFloat("TexturePrimSize", m_texturePrimSize); m_renderMeshes = mapConfig.GetBoolean("RenderMeshes", m_renderMeshes); } ReadCacheMap(); }
public void Start(IScene scene) { m_assetClient = scene.Simian.GetAppModule <IAssetClient>(); m_meshCache = scene.Simian.GetAppModule <MeshCache>(); List <string> rendererNames = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (rendererNames.Count == 0) { m_log.Error("PrimMesher could not find a valid OpenMetaverse.Rendering.*.dll plugin"); return; } // TODO: Add a config option to allow a preferred renderer to be selected m_renderer = RenderingLoader.LoadRenderer(rendererNames[0]); m_log.Debug(scene.Name + " is meshing prims with " + m_renderer); }
public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float pfov, int width, int height, bool useTextures) { List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); } cameraPos = camPos; cameraDir = camDir; viewWitdh = width; viewHeight = height; fov = pfov; orto = false; Bitmap tile = GenImage(); m_primMesher = null; return(tile); }
public void AddRegion(Scene scene) { if (!m_Enabled) { return; } m_scene = scene; List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); } else { m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } m_scene.RegisterModuleInterface <IMapImageGenerator>(this); }
public void AddRegion(Scene scene) { if (!m_Enabled) { return; } m_scene = scene; List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher); } else { m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled"); } m_scene.RegisterModuleInterface <IMapImageGenerator>(this); }
private void frmPrimWorkshop_Shown(object sender, EventArgs e) { // Get a list of rendering plugins List <string> renderers = RenderingLoader.ListRenderers("."); foreach (string r in renderers) { DialogResult result = MessageBox.Show( String.Format("Use renderer {0}?", r), "Select Rendering Plugin", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Render.Plugin = RenderingLoader.LoadRenderer(r); break; } } if (Render.Plugin == null) { MessageBox.Show("No valid rendering plugin loaded, exiting..."); Application.Exit(); } }
public Bitmap CreateMapTile() { /* this must be on all map, not just its image * if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) * { * return (Bitmap)lastImage.Clone(); * } */ List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); } Vector3 camPos = new Vector3( m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, m_scene.RegionInfo.RegionSizeY / 2 - 0.5f, 221.7025033688163f); // Viewport viewing down onto the region Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY, (float)m_scene.RegionInfo.RegionSizeX, (float)m_scene.RegionInfo.RegionSizeY); Bitmap tile = CreateMapTile(viewport, false); m_primMesher = null; return(tile); /* * lastImage = tile; * lastImageTime = DateTime.Now; * return (Bitmap)lastImage.Clone(); */ }
public Bitmap TerrainToBitmap(Bitmap mapbmp) { List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); MainConsole.Instance.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher); } else { MainConsole.Instance.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } bool drawPrimVolume = true; bool textureTerrain = true; try { IConfig startupConfig = m_config.Configs["Startup"]; drawPrimVolume = startupConfig.GetBoolean("DrawPrimOnMapTile", drawPrimVolume); textureTerrain = startupConfig.GetBoolean("TextureOnMapTile", textureTerrain); } catch { MainConsole.Instance.Warn("[MAPTILE]: Failed to load StartupConfig"); } m_texturePrims = m_config.Configs["MapModule"].GetBoolean("WarpTexturePrims", false); int scaledRemovalFactor = m_scene.RegionInfo.RegionSizeX / (Constants.RegionSize / 2); Vector3 camPos = new Vector3(m_scene.RegionInfo.RegionSizeX / 2 - 0.5f, m_scene.RegionInfo.RegionSizeY / 2 - 0.5f, 221.7025033688163f); Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, m_scene.RegionInfo.RegionSizeX - scaledRemovalFactor, m_scene.RegionInfo.RegionSizeY - scaledRemovalFactor, m_scene.RegionInfo.RegionSizeX - scaledRemovalFactor, m_scene.RegionInfo.RegionSizeY - scaledRemovalFactor); int width = viewport.Width; int height = viewport.Height; WarpRenderer renderer = new WarpRenderer(); warp_Object terrainObj = null; renderer.CreateScene(width, height); renderer.Scene.autoCalcNormals = false; #region Camera warp_Vector pos = ConvertVector(viewport.Position); pos.z -= 0.001f; // Works around an issue with the Warp3D camera warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection)); renderer.Scene.defaultCamera.setPos(pos); renderer.Scene.defaultCamera.lookAt(lookat); if (viewport.Orthographic) { renderer.Scene.defaultCamera.isOrthographic = true; renderer.Scene.defaultCamera.orthoViewWidth = viewport.OrthoWindowWidth; renderer.Scene.defaultCamera.orthoViewHeight = viewport.OrthoWindowHeight; } else { viewport.Orthographic = false; float fov = 256; //fov *= 1.75f; // FIXME: ??? renderer.Scene.defaultCamera.setFov(fov); } #endregion Camera renderer.Scene.addLight("Light1", new warp_Light(new warp_Vector(1.0f, 0.5f, 1f), 0xffffff, 0, 320, 40)); renderer.Scene.addLight("Light2", new warp_Light(new warp_Vector(-1f, -1f, 1f), 0xffffff, 0, 100, 40)); try { CreateWater(renderer); terrainObj = CreateTerrain(renderer, textureTerrain); if (drawPrimVolume && m_primMesher != null) { foreach (ISceneChildEntity part in m_scene.Entities.GetEntities().SelectMany(ent => ent.ChildrenEntities())) { CreatePrim(renderer, part); } } } catch (Exception ex) { MainConsole.Instance.Warn("[Warp3D]: Exception in the map generation, " + ex); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); bitmap = ImageUtils.ResizeImage(bitmap, Constants.RegionSize, Constants.RegionSize); foreach (var o in renderer.Scene.objectData.Values) { warp_Object obj = (warp_Object)o; obj.vertexData = null; obj.triangleData = null; } renderer.Scene.removeAllObjects(); renderer = null; viewport = null; m_primMesher = null; terrainObj.fastvertex = null; terrainObj.fasttriangle = null; terrainObj = null; SaveCache(); m_colors.Clear(); //Force GC to try to clean this mess up GC.Collect(); return(bitmap); }
public Bitmap CreateMapTile() { if ((File.GetCreationTime(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + "." + m_scene.RegionInfo.RegionSizeX + ".bmp")).Month != DateTime.Now.Month) && m_enable_refreshEveryMonth == true) { File.Delete(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + "." + m_scene.RegionInfo.RegionSizeX + ".bmp")); } if (File.Exists(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + "." + m_scene.RegionInfo.RegionSizeX + ".bmp"))) { return(new Bitmap(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + "." + m_scene.RegionInfo.RegionSizeX + ".bmp"))); } else { List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); } cameraPos = new Vector3( (m_scene.RegionInfo.RegionSizeX) * 0.5f, (m_scene.RegionInfo.RegionSizeY) * 0.5f, m_cameraHeight); cameraDir = -Vector3.UnitZ; viewWitdh = (int)m_scene.RegionInfo.RegionSizeX; viewHeight = (int)m_scene.RegionInfo.RegionSizeY; orto = true; // fov = warp_Math.rad2deg(2f * (float)Math.Atan2(viewWitdh, 4096f)); // orto = false; Bitmap tile = GenImage(); if (m_enable_date) { writeDateOnMap(ref tile); } if (m_enable_regionName) { writeNameOnMap(ref tile); } if (m_enable_regionPosition) { writePositionOnMap(ref tile); } if (m_enable_HostedBy) { writeHostedByOnMap(ref tile); } tile.Save(System.IO.Path.Combine(m_cacheDirectory, m_scene.RegionInfo.RegionID + "." + m_scene.RegionInfo.RegionSizeX + ".bmp")); // image may be reloaded elsewhere, so no compression format string filename = "MAP-" + m_scene.RegionInfo.RegionID.ToString() + ".png"; tile.Save(filename, ImageFormat.Png); m_primMesher = null; return(tile); } }
public Bitmap TerrainToBitmap(System.Drawing.Bitmap mapbmp) { mapbmp = new Bitmap(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY); List <string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); } else { m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); } bool drawPrimVolume = true; bool textureTerrain = true; 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"); } m_colors.Clear(); Vector3 camPos = new Vector3(m_scene.RegionInfo.RegionSizeX / 2, m_scene.RegionInfo.RegionSizeY / 2, 221.7025033688163f); Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY, m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY); int width = viewport.Width; int height = viewport.Height; if (m_useAntiAliasing) { width *= 2; height *= 2; } WarpRenderer renderer = new WarpRenderer(); renderer.CreateScene(width, height); renderer.Scene.autoCalcNormals = false; #region Camera warp_Vector pos = ConvertVector(viewport.Position); pos.z -= 0.001f; // Works around an issue with the Warp3D camera warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection)); renderer.Scene.defaultCamera.setPos(pos); renderer.Scene.defaultCamera.lookAt(lookat); if (viewport.Orthographic) { renderer.Scene.defaultCamera.isOrthographic = true; renderer.Scene.defaultCamera.orthoViewWidth = viewport.OrthoWindowWidth; renderer.Scene.defaultCamera.orthoViewHeight = viewport.OrthoWindowHeight; } else { float fov = viewport.FieldOfView; fov *= 1.75f; // FIXME: ??? renderer.Scene.defaultCamera.setFov(fov); } #endregion Camera renderer.Scene.addLight("Light1", new warp_Light(new warp_Vector(0.2f, 0.2f, 1f), 0xffffff, 320, 80)); renderer.Scene.addLight("Light2", new warp_Light(new warp_Vector(-1f, -1f, 1f), 0xffffff, 100, 40)); CreateWater(renderer); CreateTerrain(renderer, textureTerrain); if (drawPrimVolume && m_primMesher != null) { m_scene.ForEachSOG(delegate(SceneObjectGroup group) { group.ForEachPart(delegate(SceneObjectPart part) { CreatePrim(renderer, part); }); }); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); renderer.Scene.removeAllObjects(); renderer = null; viewport = null; m_primMesher = null; m_colors.Clear(); //Force GC to try to clean this mess up GC.GetTotalMemory(true); if (m_useAntiAliasing) { bitmap = ImageUtils.ResizeImage(bitmap, width / 2, height / 2); } return(bitmap); }