public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { m_colors.Clear(); int width = viewport.Width; int height = viewport.Height; WarpRenderer renderer = new WarpRenderer(); if (!renderer.CreateScene(width, height)) { return(new Bitmap(width, height)); } #region Camera warp_Vector pos = ConvertVector(viewport.Position); 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.setOrthographic(true, viewport.OrthoWindowWidth, 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(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)); CreateWater(renderer); CreateTerrain(renderer, m_textureTerrain); if (m_drawPrimVolume) { CreateAllPrims(renderer, useTextures); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); renderer.Scene.destroy(); renderer.Reset(); renderer = null; viewport = null; m_colors.Clear(); GC.Collect(); m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); return(bitmap); }
public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { 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("[WARP 3D IMAGE MODULE]: Failed to load StartupConfig"); } m_colors.Clear(); 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(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)); CreateWater(renderer); CreateTerrain(renderer, textureTerrain); if (drawPrimVolume) { CreateAllPrims(renderer, useTextures); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) { using (Bitmap origBitmap = bitmap) bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); } // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating // this map tile simply takes a lot of memory. GC.Collect(); m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); return(bitmap); }
public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { 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(); 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) { CreateAllPrims(renderer, useTextures); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) { bitmap = ImageUtils.ResizeImage(bitmap, viewport.Width, viewport.Height); } return(bitmap); }
public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { 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("[WARP 3D IMAGE MODULE]: Failed to load StartupConfig"); } m_colors.Clear(); 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(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)); CreateWater(renderer); CreateTerrain(renderer, textureTerrain); if (drawPrimVolume) CreateAllPrims(renderer, useTextures); renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) { using (Bitmap origBitmap = bitmap) bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); } // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating // this map tile simply takes a lot of memory. GC.Collect(); m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); return bitmap; }
public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { 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(); 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(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)); CreateWater(renderer); CreateTerrain(renderer, textureTerrain); if (drawPrimVolume) CreateAllPrims(renderer, useTextures); renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) bitmap = ImageUtils.ResizeImage(bitmap, viewport.Width, viewport.Height); return bitmap; }
public Bitmap TerrainToBitmap (System.Drawing.Bitmap mapbmp) { List<string> renderers = RenderingLoader.ListRenderers (Util.ExecutingDirectory ()); if (renderers.Count > 0) { m_primMesher = RenderingLoader.LoadRenderer (renderers[0]); m_log.Debug ("[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_texturePrims = m_config.Configs["MapModule"].GetBoolean("WarpTexturePrims", false); m_colors.Clear (); 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; if (m_useAntiAliasing) { width *= 2; height *= 2; } 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 (ISceneEntity ent in m_scene.Entities.GetEntities ()) foreach (ISceneChildEntity part in ent.ChildrenEntities ()) CreatePrim (renderer, part); } catch(Exception ex) { m_log.Warn ("[Warp3D]: Exception in the map generation, " + ex.ToString ()); } renderer.Render (); Bitmap bitmap = renderer.Scene.getImage (); bitmap = ImageUtils.ResizeImage (bitmap, Constants.RegionSize, Constants.RegionSize); renderer.Scene.removeAllObjects (); renderer = null; viewport = null; m_primMesher = null; terrainObj.fastvertex = null; terrainObj.fasttriangle = null; terrainObj = null; m_colors.Clear (); //Force GC to try to clean this mess up GC.GetTotalMemory (true); return bitmap; }
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; }
public Bitmap CreateMapTile(Viewport viewport, bool useTextures) { m_colors.Clear(); 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(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)); CreateWater(renderer); CreateTerrain(renderer, m_textureTerrain); if (m_drawPrimVolume) CreateAllPrims(renderer, useTextures); renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) { using (Bitmap origBitmap = bitmap) { bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); origBitmap.Dispose(); } } // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating // this map tile simply takes a lot of memory. 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_colors.Clear(); GC.Collect(); m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); return bitmap; }
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); }
public Image Render(IScene scene, Viewport viewport) { IPrimMesher primMesher = scene.GetSceneModule <IPrimMesher>(); m_colors.Clear(); 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)); ITerrain terrain = scene.GetSceneModule <ITerrain>(); RegionInfo regionInfo = scene.GetSceneModule <RegionInfo>(); CreateWater(scene, renderer, terrain); CreateTerrain(scene, renderer, terrain, regionInfo); if (primMesher != null) { CreateAllPrims(scene, renderer, primMesher); } renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) { bitmap = Util.ResizeImage(bitmap, viewport.Width, viewport.Height); } return(bitmap); }
private bool m_useAntiAliasing = true; // TODO: Make this a config option #endregion Fields #region Methods public Image Render(IScene scene, Viewport viewport) { IPrimMesher primMesher = scene.GetSceneModule<IPrimMesher>(); m_colors.Clear(); 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)); ITerrain terrain = scene.GetSceneModule<ITerrain>(); RegionInfo regionInfo = scene.GetSceneModule<RegionInfo>(); CreateWater(scene, renderer, terrain); CreateTerrain(scene, renderer, terrain, regionInfo); if (primMesher != null) CreateAllPrims(scene, renderer, primMesher); renderer.Render(); Bitmap bitmap = renderer.Scene.getImage(); if (m_useAntiAliasing) bitmap = Util.ResizeImage(bitmap, viewport.Width, viewport.Height); return bitmap; }