//////////////////////////////////////////////////////////// /// <summary> /// Construct the shape from another shape /// </summary> /// <param name="copy">Shape to copy</param> //////////////////////////////////////////////////////////// public ConvexShape(ConvexShape copy) : base(copy) { SetPointCount(copy.GetPointCount()); for (uint i = 0; i < copy.GetPointCount(); ++i) SetPoint(i, copy.GetPoint(i)); }
public void DrawQuad(int x, int y, int width, int height, Color color, Color color2, int thickness) { var zoom = GetZoom(); int real_x = (int)(x * zoom); int real_y = (int)(y * zoom); int real_width = (int)(width * zoom); int real_height = (int)(height * zoom); SFML.System.Vector2f position = new SFML.System.Vector2f(real_x, real_y); SFML.System.Vector2f size = new SFML.System.Vector2f(real_width, real_height); float offset_x = 0; float offset_y = 0; SFML.Graphics.ConvexShape rect = new SFML.Graphics.ConvexShape(4); rect.OutlineThickness = thickness; rect.OutlineColor = new SFML.Graphics.Color(color2.R, color2.G, color2.B, color2.A); rect.FillColor = new SFML.Graphics.Color(color.R, color.G, color.B, color.A); rect.Position = position; rect.SetPoint(0, new SFML.System.Vector2f(offset_x, offset_y)); rect.SetPoint(1, new SFML.System.Vector2f(offset_x + size.X, offset_y)); rect.SetPoint(2, new SFML.System.Vector2f(offset_x + size.X - size.Y, offset_y + size.Y)); rect.SetPoint(3, new SFML.System.Vector2f(offset_x - size.Y, offset_y + size.Y)); RenderWindow.Draw(rect); }
public AimAssistance(Game Game, Cannon SourceObject) : base(Game) { this.SourceObject = SourceObject; if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL) { Colour = new Color(0, 0, 0, 192); Thickness = 3; FillColour = new Color(255, 255, 255, 25); } else if (Game.GraphicsMode == Game.GRAPHICSMODE_BLUEPRINT) { Colour = new Color(255, 255, 255, 255); Thickness = 1; FillColour = new Color(255, 255, 255, 15); } // Reticle Reticle = new DisplayObject(); Reticle.Visible = false; AddChild(Reticle); UpdateReticle(); // Aiming Lines LineCenter = new RectangleShape(new Vector2f(Utils.Distance(new Vector2f(0, 48), new Vector2f(0, Game.Size.X - 48)), Thickness)); LineCenter.FillColor = Colour; LineCenter.Origin = new Vector2f(0, Thickness / 2); LineCenter.Position = new Vector2f(0, 48); LineCenter.Rotation = 90; AddChild(LineCenter); LineLeft = new RectangleShape(new Vector2f(10, Thickness)); LineLeft.FillColor = Colour; LineLeft.Origin = new Vector2f(0, Thickness / 2); LineLeft.Position = new Vector2f(11, 43); AddChild(LineLeft); LineRight = new RectangleShape(new Vector2f(10, Thickness)); LineRight.FillColor = Colour; LineRight.Origin = new Vector2f(0, Thickness / 2); LineRight.Position = new Vector2f(-11, 43); AddChild(LineRight); Fill = new ConvexShape(4); Fill.FillColor = FillColour; AddChild(Fill); }
public Triangle(float width, float height) : base(0.5f * width * height) { float halfWidth = width / 2f; float halfHeight = height / 2f; triangle = new ConvexShape(3); triangle.SetPoint(0, new Vector2f(halfWidth, 0)); triangle.SetPoint(1, new Vector2f(width, height)); triangle.SetPoint(2, new Vector2f(0, height)); triangle.FillColor = Color.Yellow; Origin = new Vector2f(halfWidth, halfHeight); this.width = width; this.height = height; }
public DebugView() { _staticColor = new Color(100, 150, 100, 128); _dynamicColor = new Color(100, 100, 150, 128); _staticOutlineColor = new Color(_staticColor.R, _staticColor.G, _staticColor.B, 255); _dynamicOutlineColor = new Color(_dynamicColor.R, _dynamicColor.G, _dynamicColor.B, 255); _circles = new CircleShape[MAX_SHAPES]; _polygons = new ConvexShape[MAX_SHAPES]; _lines = new RectangleShape[MAX_SHAPES]; for (int i = 0; i < MAX_SHAPES; i++) { _circles[i] = new CircleShape(); _circles[i].OutlineThickness = -0.05f; _polygons[i] = new ConvexShape(); _polygons[i].OutlineThickness = -0.05f; _lines[i] = new RectangleShape(); } }
// Create color primitive render component from a body private static ColorPrimitiveRenderComponent createColorPrimitiveRenderComponent(int entityId, Body body, Color color) { ColorPrimitiveRenderComponent component = new ColorPrimitiveRenderComponent(entityId, color); List<BodyRenderData> allRenderData = new List<BodyRenderData>(); BodyRenderData renderData = new BodyRenderData(); List<ConvexShape> shapes = new List<ConvexShape>(); foreach (Fixture fixture in body.FixtureList) { if (fixture.Shape.ShapeType == ShapeType.Polygon) { PolygonShape polygonShape = fixture.Shape as PolygonShape; ConvexShape sfmlShape = new ConvexShape((uint)polygonShape.Vertices.Count); for (int i = 0; i < polygonShape.Vertices.Count; i++) { Vector2 vertex = polygonShape.Vertices[i]; sfmlShape.SetPoint((uint)i, new Vector2f(vertex.X, vertex.Y)); } sfmlShape.FillColor = color; shapes.Add(sfmlShape); } } renderData.body = body; renderData.shapes = shapes; allRenderData.Add(renderData); component.renderData = allRenderData; return component; }
/// <summary> Draws a user-defined convex object. </summary> public void Draw(ConvexShape shape, RenderStates?state = null) { var shapeObj = new ConvexShape(shape); DrawShape(shapeObj, state ?? RenderStates.Default); }