void Init() { m_densityTexture = new RenderTarget2D(Engine.Renderer.Device, 1280, 720, false, SurfaceFormat.Single, DepthFormat.None); m_densitySprite = Sprite.CreateFromTexture(m_densityTexture); m_drawEffect = Engine.AssetManager.GetAsset <Effect>("heatmap.fx"); m_drawSpotEffect = Engine.AssetManager.GetAsset <Effect>("heatmapSpot.fx"); m_heatMapGradient = Engine.AssetManager.GetAsset <Texture2D>("System/heatMapGradient.jpg"); m_quadMesh = new DynamicMesh <VertexPositionTexture>(Engine.Renderer.Device, VertexPositionTexture.VertexDeclaration, PrimitiveType.TriangleStrip, 12); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(-1, -1, 0), new Vector2(0, 0))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(+1, -1, 0), new Vector2(1, 0))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(-1, +1, 0), new Vector2(0, 1))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(+1, +1, 0), new Vector2(1, 1))); m_quadMesh.Index(0); m_quadMesh.Index(1); m_quadMesh.Index(2); m_quadMesh.Index(3); m_quadMesh.PrepareDraw(); DrawToRT(); }
public void Draw() { m_lineMesh.PrepareDraw(); m_triangleMesh.PrepareDraw(); Engine.Renderer.Device.BlendState = BlendState.NonPremultiplied; Engine.Renderer.Device.RasterizerState = RasterizerState.CullNone; Engine.Renderer.Device.DepthStencilState = DepthStencilState.None; Engine.Renderer.DrawMesh(m_lineMesh, m_effect); Engine.Renderer.DrawMesh(m_triangleMesh, m_effect); }
public void Draw() { if (!m_active) { return; } m_mesh.PrepareDraw(); Engine.Renderer.Device.BlendState = BlendState.NonPremultiplied; Engine.Renderer.Device.RasterizerState = RasterizerState.CullNone; Engine.Renderer.Device.DepthStencilState = DepthStencilState.None; Engine.Renderer.DrawMesh(m_mesh, m_effect); }
public override void Start() { //Initialise SpriteComponent base.Start(); m_effect = ColorMaskingEffect.Create("Graphics/Shaders/ColorMasking.fx"); m_quadMesh = new DynamicMesh <VertexPositionTexture>(Engine.Renderer.Device, VertexPositionTexture.VertexDeclaration, PrimitiveType.TriangleStrip, 12); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(-1, +1, 0), new Vector2(0, 0))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(+1, +1, 0), new Vector2(1, 0))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(-1, -1, 0), new Vector2(0, 1))); m_quadMesh.Vertex(new VertexPositionTexture(new Vector3(+1, -1, 0), new Vector2(1, 1))); m_quadMesh.Index(0); m_quadMesh.Index(1); m_quadMesh.Index(2); m_quadMesh.Index(3); m_quadMesh.PrepareDraw(); }
public void Draw() { if (!Engine.Debug.Flags.RenderDebug) { return; } float textBoxMargin = 1.0f; Engine.Renderer.CurrentCamera = Engine.Renderer.Cameras[0]; //Build log debug string StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); foreach (var dbValue in Engine.Log.DebugValues) { sb.AppendLine(dbValue.Key + ": " + dbValue.Value); } String logDebugString = sb.ToString(); Vector2 logDebugOriginScreen = new Vector2(5, 5); Vector2 logDebugSize = Engine.Renderer.SpriteFont.MeasureString(logDebugString); float logDebugMinWidth = 150; logDebugSize.X = Math.Max(logDebugMinWidth, logDebugSize.X); Vector2 logDebugCenterWorld = Engine.Renderer.CurrentCamera.ScreenToWorld(logDebugOriginScreen + logDebugSize / 2); //Prepare render paramters for text boxes var underlayColor = new Color(32, 32, 32); var lineColor = new Color(16, 16, 16); Brush.DrawWireframe = true; Brush.LineColor = lineColor; Brush.LineAlpha = 1.0f; Brush.DrawSurface = true; Brush.SurfaceColor = underlayColor; Brush.SurfaceAlpha = 0.75f; //Add debug strings text boxes foreach (var msg in m_texts) { if (msg.Background) { Vector2 size = Engine.Renderer.SpriteFont.MeasureString(msg.Text); AddRectangle(msg.Position, size / 2 + new Vector2(textBoxMargin, textBoxMargin)); } } //Add log debug text box if (Engine.Log.DebugEnabled) { AddRectangle(logDebugCenterWorld, logDebugSize / 2 + new Vector2(textBoxMargin, textBoxMargin)); } m_lineMesh.PrepareDraw(); m_triangleMesh.PrepareDraw(); Engine.Renderer.Device.BlendState = BlendState.AlphaBlend; Engine.Renderer.Device.RasterizerState = RasterizerState.CullNone; Engine.Renderer.Device.DepthStencilState = DepthStencilState.None; if (m_triangleMesh.PrimitiveCount > 0) { Engine.Renderer.DrawMesh(m_triangleMesh, m_effect); } if (m_lineMesh.PrimitiveCount > 0) { Engine.Renderer.DrawMesh(m_lineMesh, m_effect); } foreach (var msg in m_texts) { Vector2 size = Engine.Renderer.SpriteFont.MeasureString(msg.Text); Vector2 screenPos = Engine.Renderer.CurrentCamera.WorldToScreen(msg.Position) - size / 2; Engine.Renderer.DrawStringUnbatched(screenPos, msg.Text, Color.White); } if (Engine.Log.DebugEnabled) { Engine.Renderer.DrawStringUnbatched(logDebugOriginScreen, logDebugString, Color.White); } }