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 AddLine(Vector2 start, Vector2 end, ref DebugBrush debugRenderParams) { if (debugRenderParams.DrawWireframe) { var vertex = new VertexPositionColor(); vertex.Position = new Vector3(start, 0); vertex.Color = debugRenderParams.LineColor; int idx1 = m_lineMesh.Vertex(vertex); vertex.Position = new Vector3(end, 0); vertex.Color = debugRenderParams.LineColor; int idx2 = m_lineMesh.Vertex(vertex); m_lineMesh.Index(idx1); m_lineMesh.Index(idx2); } }
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 AddTriangle(Vector2 v1, Vector2 v2, Vector2 v3, ref DebugBrush debugRenderParams) { if (debugRenderParams.DrawSurface) { var vertex = new VertexPositionColor(); vertex.Position = new Vector3(v1, 0); vertex.Color = debugRenderParams.SurfaceColor; int idx1 = m_triangleMesh.Vertex(vertex); vertex.Position = new Vector3(v2, 0); vertex.Color = debugRenderParams.SurfaceColor; int idx2 = m_triangleMesh.Vertex(vertex); vertex.Position = new Vector3(v3, 0); vertex.Color = debugRenderParams.SurfaceColor; int idx3 = m_triangleMesh.Vertex(vertex); m_triangleMesh.Index(idx1); m_triangleMesh.Index(idx2); m_triangleMesh.Index(idx3); } }
public override void Update() { if (!(m_chargeTimerMS.Active || m_maxChargeTimerMS.Active)) { return; } base.Update(); // Update angle float chargeCompletion = LBE.MathHelper.LinearStep(0, m_chargeTimerMS.TargetTime, m_chargeTimerMS.TimeMS); if (m_chargedMax) { chargeCompletion = 1; } m_angle = (float)Math.PI * chargeCompletion; // Create gfx feedback m_lineMesh.Reset(); m_triangleMesh.Reset(); int nbrSide = 32; float radius = 30 * m_scale; for (int i = 0; i < nbrSide; i++) { float angleStep = m_angle / nbrSide; Vector2 circlePoint1 = new Vector2((float)Math.Cos(angleStep * i), (float)Math.Sin(angleStep * i)); circlePoint1 = circlePoint1.Rotate(GetWorldTransform().Orientation - 0.5f * m_angle); Vector2 p1 = Owner.Position + radius * circlePoint1; Vector2 circlePoint2 = new Vector2((float)Math.Cos(angleStep * (i + 1)), (float)Math.Sin(angleStep * (i + 1))); circlePoint2 = circlePoint2.Rotate(GetWorldTransform().Orientation - 0.5f * m_angle); Vector2 p2 = Owner.Position + radius * circlePoint2; // Circle var vertex = new VertexPositionColor(); vertex.Color = m_team.ColorScheme.Color1; vertex.Position = new Vector3(p1, 0); int idx1 = m_lineMesh.Vertex(vertex); vertex.Position = new Vector3(p2, 0); int idx2 = m_lineMesh.Vertex(vertex); m_lineMesh.Index(idx1); m_lineMesh.Index(idx2); // Disk var vertexT = new VertexPositionColor(); vertexT.Color = new Color(m_team.ColorScheme.Color1, 0.2f); vertexT.Position = new Vector3(Owner.Position, 0); int idxT1 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p1, 0); int idxT2 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p2, 0); int idxT3 = m_triangleMesh.Vertex(vertexT); m_triangleMesh.Index(idxT1); m_triangleMesh.Index(idxT2); m_triangleMesh.Index(idxT3); } // UpdateScan(); if (m_playerToAim != null) { PassBallToTeam(); StopCharge(); } }
public override void Update() { if (!m_active) { return; } m_pastPositions.Add(Position); m_mesh.Reset(); float width = 3; int nbrPoint = 24; int iStart = m_pastPositions.Count > nbrPoint ? m_pastPositions.Count - nbrPoint : 0; for (int i = iStart; i < m_pastPositions.Count - 1; i++) { float alphaCoef = (m_fadeOutTimer.TargetTime - m_fadeOutTimer.TimeMS) / m_fadeOutTimer.TargetTime; float alpha = 1.0f / (float)nbrPoint * (i - iStart) * alphaCoef; Color colCenter = new Color(m_color, alpha); Color colSide = new Color(m_color, alpha * 0.25f); Vector2 dir = m_pastPositions[i + 1] - m_pastPositions[i]; dir.Normalize(); Vector2 orthoDir = dir.Rotate((float)Math.PI * 0.5f); orthoDir.Normalize(); int i1 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] + orthoDir * width * 2, 0), colSide)); int i2 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] + orthoDir * width, 0), colCenter)); int i3 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] - orthoDir * width, 0), colCenter)); int i4 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i] - orthoDir * width * 2, 0), colSide)); int i5 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] + orthoDir * width * 2, 0), colSide)); int i6 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] + orthoDir * width, 0), colCenter)); int i7 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] - orthoDir * width, 0), colCenter)); int i8 = m_mesh.Vertex(new VertexPositionColor(new Vector3(m_pastPositions[i + 1] - orthoDir * width * 2, 0), colSide)); m_mesh.Index(i1); m_mesh.Index(i2); m_mesh.Index(i5); m_mesh.Index(i2); m_mesh.Index(i5); m_mesh.Index(i6); m_mesh.Index(i2); m_mesh.Index(i3); m_mesh.Index(i6); m_mesh.Index(i3); m_mesh.Index(i6); m_mesh.Index(i7); m_mesh.Index(i3); m_mesh.Index(i4); m_mesh.Index(i7); m_mesh.Index(i4); m_mesh.Index(i7); m_mesh.Index(i8); } }
public override void Update() { base.Update(); m_lineMesh.Reset(); m_triangleMesh.Reset(); int nbrSide = 32; int radius = 50; float chargeCompletion = LBE.MathHelper.LinearStep(0, m_chargeTimerMS.TargetTime, m_chargeTimerMS.TimeMS); if (m_chargedMax) { chargeCompletion = 1; } m_angle = 2 * (float)Math.PI * Math.Max(chargeCompletion, 0.05f * (float)Math.PI); for (int i = 0; i < nbrSide; i++) { float angleStep = m_angle / nbrSide; Vector2 circlePoint1 = new Vector2((float)Math.Cos(angleStep * i), (float)Math.Sin(angleStep * i)); circlePoint1 = circlePoint1.Rotate(m_player.BallAngle - 0.5f * m_angle); Vector2 p1 = Owner.Position + radius * circlePoint1; Vector2 circlePoint2 = new Vector2((float)Math.Cos(angleStep * (i + 1)), (float)Math.Sin(angleStep * (i + 1))); circlePoint2 = circlePoint2.Rotate(m_player.BallAngle - 0.5f * m_angle); Vector2 p2 = Owner.Position + radius * circlePoint2; // Circle var vertex = new VertexPositionColor(); vertex.Color = m_player.Team.ColorScheme.Color1; vertex.Position = new Vector3(p1, 0); int idx1 = m_lineMesh.Vertex(vertex); vertex.Position = new Vector3(p2, 0); int idx2 = m_lineMesh.Vertex(vertex); m_lineMesh.Index(idx1); m_lineMesh.Index(idx2); // Disk var vertexT = new VertexPositionColor(); vertexT.Color = new Color(m_player.Team.ColorScheme.Color1, 0.2f); vertexT.Position = new Vector3(Owner.Position, 0); int idxT1 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p1, 0); int idxT2 = m_triangleMesh.Vertex(vertexT); vertexT.Position = new Vector3(p2, 0); int idxT3 = m_triangleMesh.Vertex(vertexT); m_triangleMesh.Index(idxT1); m_triangleMesh.Index(idxT2); m_triangleMesh.Index(idxT3); } }