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 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 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); }
/// <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> /// <param name="fixStart"></param> /// <param name="fixEnd"></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)); }
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 Body CreateEllipse(World world, float xRadius, float yRadius, int edges, float density, System.Numerics.Vector2 position = new System.Numerics.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 CreateGear(World world, float radius, int numberOfTeeth, float tipPercentage, float toothHeight, float density, System.Numerics.Vector2 position = new System.Numerics.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 CreateCircle(World world, float radius, float density, System.Numerics.Vector2 position = new System.Numerics.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 CreateRectangle(World world, float width, float height, float density, System.Numerics.Vector2 position = new System.Numerics.Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.CreateRectangle(world, FSConvert.ToSimUnits(width), FSConvert.ToSimUnits(height), density, FSConvert.ToSimUnits(position), rotation, bodyType, userData)); }
public static Body CreateEdge(World world, System.Numerics.Vector2 start, System.Numerics.Vector2 end, object userData = null) { return(FarseerPhysics.Factories.BodyFactory.CreateEdge(world, FSConvert.ToSimUnits(start), FSConvert.ToSimUnits(end), userData)); }
public static BreakableBody CreateBreakableBody(World world, IEnumerable <Shape> shapes, System.Numerics.Vector2 position = new System.Numerics.Vector2(), float rotation = 0) { return(FarseerPhysics.Factories.BodyFactory.CreateBreakableBody(world, shapes, FSConvert.ToSimUnits(position), rotation)); }
public static Body CreateBody(World world, System.Numerics.Vector2 position = new System.Numerics.Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userData = null) { return(new Body(world, FSConvert.ToSimUnits(position), rotation, bodyType, userData)); }