void drawPerformanceGraph() { _graphValues.Add(world.updateTime / TimeSpan.TicksPerMillisecond); if (_graphValues.Count > valuesToGraph + 1) { _graphValues.RemoveAt(0); } float x = performancePanelBounds.X; float deltaX = performancePanelBounds.Width / (float)valuesToGraph; float yScale = performancePanelBounds.Bottom - (float)performancePanelBounds.Top; // we must have at least 2 values to start rendering if (_graphValues.Count > 2) { _max = _graphValues.Max(); _avg = _graphValues.Average(); _min = _graphValues.Min(); if (adaptiveLimits) { maximumValue = _max; minimumValue = 0; } // start at last value (newest value added) // continue until no values are left for (int i = _graphValues.Count - 1; i > 0; i--) { float y1 = performancePanelBounds.Bottom - ((_graphValues[i] / (maximumValue - minimumValue)) * yScale); float y2 = performancePanelBounds.Bottom - ((_graphValues[i - 1] / (maximumValue - minimumValue)) * yScale); var x1 = new Vector2(MathHelper.Clamp(x, performancePanelBounds.Left, performancePanelBounds.Right), MathHelper.Clamp(y1, performancePanelBounds.Top, performancePanelBounds.Bottom)); var x2 = new Vector2(MathHelper.Clamp(x + deltaX, performancePanelBounds.Left, performancePanelBounds.Right), MathHelper.Clamp(y2, performancePanelBounds.Top, performancePanelBounds.Bottom)); drawSegment(FSConvert.toSimUnits(x1), FSConvert.toSimUnits(x2), Color.LightGreen); x += deltaX; } } drawString(performancePanelBounds.Right + 10, performancePanelBounds.Top, string.Format("Max: {0} ms", _max)); drawString(performancePanelBounds.Right + 10, performancePanelBounds.Center.Y - 7, string.Format("Avg: {0} ms", _avg)); drawString(performancePanelBounds.Right + 10, performancePanelBounds.Bottom - 15, string.Format("Min: {0} ms", _min)); //Draw background. _background[0] = new Vector2(performancePanelBounds.X, performancePanelBounds.Y); _background[1] = new Vector2(performancePanelBounds.X, performancePanelBounds.Y + performancePanelBounds.Height); _background[2] = new Vector2(performancePanelBounds.X + performancePanelBounds.Width, performancePanelBounds.Y + performancePanelBounds.Height); _background[3] = new Vector2(performancePanelBounds.X + performancePanelBounds.Width, performancePanelBounds.Y); _background[0] = FSConvert.toSimUnits(_background[0]); _background[1] = FSConvert.toSimUnits(_background[1]); _background[2] = FSConvert.toSimUnits(_background[2]); _background[3] = FSConvert.toSimUnits(_background[3]); drawSolidPolygon(_background, 4, Color.DarkGray, true); }
public static Fixture attachLoopShape(this Body body, List <Vector2> vertices) { for (var i = 0; i < vertices.Count; i++) { vertices[i] = FSConvert.toSimUnits(vertices[i]); } return(FixtureFactory.attachLoopShape(new Vertices(vertices), body, null)); }
/// <summary> /// Creates a chain. /// </summary> /// <param name="world">The world.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <param name="linkWidth">The width.</param> /// <param name="linkHeight">The height.</param> /// <param name="numberOfLinks">The number of links.</param> /// <param name="linkDensity">The link density.</param> /// <param name="attachRopeJoint">Creates a rope joint between start and end. This enforces the length of the rope. Said in another way: it makes the rope less bouncy.</param> /// <returns></returns> public static List <Body> createChain(World world, Vector2 start, Vector2 end, float linkWidth, float linkHeight, int numberOfLinks, float linkDensity, bool attachRopeJoint, bool fixStart = false, bool fixEnd = false) { return(FarseerPhysics.Factories.LinkFactory.createChain(world, FSConvert.displayToSim * start, FSConvert.toSimUnits(end), FSConvert.displayToSim * linkWidth, FSConvert.displayToSim * linkHeight, numberOfLinks, linkDensity, attachRopeJoint, fixStart, fixEnd)); }
public static Body createCapsule(World world, float height, float endRadius, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createCapsule(world, FSConvert.toSimUnits(height), FSConvert.toSimUnits(endRadius), density, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static Body createGear(World world, float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createGear(world, FSConvert.toSimUnits(radius), numberOfTeeth, tipPercentage, FSConvert.toSimUnits(toothHeight), density, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static Body createCompoundPolygon(World world, List <Vertices> list, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createCompoundPolygon(world, list, density, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static Body createPolygon(World world, Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { for (var i = 0; i < vertices.Count; i++) { vertices[i] *= FSConvert.displayToSim; } return(FarseerPhysics.Factories.BodyFactory.createPolygon(world, vertices, density, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static Body createEllipse(World world, float xRadius, float yRadius, int edges, float density, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createEllipse(world, FSConvert.toSimUnits(xRadius), FSConvert.toSimUnits(yRadius), edges, density, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static Body createCircle(World world, float radius, float density, Vector2 position = new Vector2(), BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createCircle(world, FSConvert.toSimUnits(radius), density, FSConvert.toSimUnits(position), bodyType, userData)); }
public static Body createLoopShape(World world, Vertices vertices, Vector2 position = new Vector2(), object userData = null) { for (var i = 0; i < vertices.Count; i++) { vertices[i] *= FSConvert.displayToSim; } return(FarseerPhysics.Factories.BodyFactory.createLoopShape(world, vertices, FSConvert.toSimUnits(position), userData)); }
public static Body createEdge(World world, Vector2 start, Vector2 end, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createEdge(world, FSConvert.toSimUnits(start), FSConvert.toSimUnits(end), userData)); }
public static Body createBody(World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(new Body(world, FSConvert.toSimUnits(position), rotation, bodyType, userData)); }
public static BreakableBody createBreakableBody(World world, IEnumerable <Shape> shapes, Vector2 position = new Vector2(), float rotation = 0) { return(FarseerPhysics.Factories.BodyFactory.createBreakableBody(world, shapes, FSConvert.toSimUnits(position), rotation)); }
public static BreakableBody createBreakableBody(World world, Vertices vertices, float density, Vector2 position = new Vector2(), float rotation = 0) { for (var i = 0; i < vertices.Count; i++) { vertices[i] *= FSConvert.displayToSim; } return(FarseerPhysics.Factories.BodyFactory.createBreakableBody(world, vertices, density, FSConvert.toSimUnits(position), rotation)); }
public static Body createSolidArc(World world, float density, float radians, int sides, float radius, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.createSolidArc(world, density, radians, sides, FSConvert.toSimUnits(radius), FSConvert.toSimUnits(position), rotation, bodyType)); }
public static Body createLineArc(World world, float radians, int sides, float radius, bool closed = false, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { var body = FarseerPhysics.Factories.BodyFactory.createLineArc(world, radians, sides, FSConvert.toSimUnits(radius), closed, FSConvert.toSimUnits(position), rotation, bodyType); body.userData = userData; return(body); }