public void LoadToPhysicsSimulator(PhysicsSimulator physicsSimulator) { physicsSimulator.Add(LeftBorder); physicsSimulator.Add(RightBorder); physicsSimulator.Add(TopBorder); physicsSimulator.Add(BottomBorder); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { phsX = new PhysicsSimulator(); //Create physX //phsX.Iterations = 5; //phsX.Gravity = new Vector2(0, (float)9.8); // TODO: Add your initialization logic here Random r = new Random(); for (int x = 48; x < 230; x += 64) { for (int y = 48; y < 200; y += 48) { Body rectangleBody; rectangleBody = BodyFactory.Instance.CreateRectangleBody(phsX, 32, 32, 1); rectangleBody.Position = new Vector2(x, y); phsX.Add(GeomFactory.Instance.CreateRectangleGeom(phsX, rectangleBody, 32, 32)); } } //Body leftCorner; leftCorner = BodyFactory.Instance.CreateRectangleBody(phsX, 10, 480, 100000); leftCorner.Position = new Vector2(5, 240); //Body rightCorner; rightCorner = BodyFactory.Instance.CreateRectangleBody(phsX, 10, 480, 100000); rightCorner.Position = new Vector2(267, 240); //Body topCorner; topCorner = BodyFactory.Instance.CreateRectangleBody(phsX, 272, 10, 100000); topCorner.Position = new Vector2(136, 5); //Body bottomCorner; bottomCorner = BodyFactory.Instance.CreateRectangleBody(phsX, 272, 10, 100000); bottomCorner.Position = new Vector2(136, 475); Geom gl = GeomFactory.Instance.CreateRectangleGeom(leftCorner, 10, 480); Geom gr = GeomFactory.Instance.CreateRectangleGeom(rightCorner, 10, 480); Geom gu = GeomFactory.Instance.CreateRectangleGeom(topCorner, 272, 10); Geom gb = GeomFactory.Instance.CreateRectangleGeom(bottomCorner, 272, 10); gl.Body.IsStatic = true; gr.Body.IsStatic = true; gu.Body.IsStatic = true; gb.Body.IsStatic = true; phsX.Add(gl); phsX.Add(gr); phsX.Add(gu); phsX.Add(gb); base.Initialize(); }
public void Load(PhysicsSimulator physicsSimulator, GraphicsDevice device) { Random rand = new Random(); physicsSimulator.Add(_topBody); physicsSimulator.Add(_rightLegBody); physicsSimulator.Add(_leftLegBody); physicsSimulator.Add(_topGeom); physicsSimulator.Add(_rightLegGeom); physicsSimulator.Add(_leftLegGeom); _leftWeldJoint = new WeldJoint(_leftLegBody, _topBody, _leftLegBody.Position - new Vector2(-5, _height / 2)); _leftWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f; _leftWeldJoint.Broke += _leftWeldJoint_Broke; physicsSimulator.Add(_leftWeldJoint); _rightWeldJoint = new WeldJoint(_rightLegBody, _topBody, _rightLegBody.Position - new Vector2(5, _height / 2)); _rightWeldJoint.Breakpoint = (float)rand.NextDouble() * 3f + 1f; _rightWeldJoint.Broke += _rightWeldJoint_Broke; physicsSimulator.Add(_rightWeldJoint); _topBrush = new PolygonBrush(_topGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f); _leftBrush = new PolygonBrush(_leftLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f); _rightBrush = new PolygonBrush(_rightLegGeom.LocalVertices, Color.BurlyWood, Color.Black, 1.0f, 0.5f); _topBrush.Load(device); _leftBrush.Load(device); _rightBrush.Load(device); }
/// <summary> /// Creates a gravity controller and adds it to the physics simulator. /// </summary> /// <param name="simulator">the physicsSimulator used by this controller.</param> /// <param name="bodies">The bodies you want to generate gravity.</param> /// <param name="strength">the maximum strength of gravity (the gravity strength when two bodies are on the same spot)</param> /// <param name="radius">the maximum distance that can be between 2 bodies before it will stop trying to apply gravity between them.</param> /// <returns></returns> public GravityController CreateGravityController(PhysicsSimulator simulator, List <Body> bodies, float strength, float radius) { GravityController gravityController = new GravityController(simulator, bodies, strength, radius); simulator.Add(gravityController); return(gravityController); }
public FixedRevoluteJoint CreateFixedRevoluteJoint(PhysicsSimulator physicsSimulator, Body body, Vector2 anchor) { FixedRevoluteJoint revoluteJoint = CreateFixedRevoluteJoint(body, anchor); physicsSimulator.Add(revoluteJoint); return(revoluteJoint); }
/// <summary> /// Creates a polygon geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="vertices">The vertices.</param> /// <param name="positionOffset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT /// Put in 0 or less to make the engine calculate a grid cell size.</param> /// <returns></returns> public Geom CreatePolygonGeom(PhysicsSimulator physicsSimulator, Body body, Vertices vertices, Vector2 positionOffset, float rotationOffset, float collisionGridSize) { Geom geometry = CreatePolygonGeom(body, vertices, positionOffset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return(geometry); }
/// <summary> /// Creates a clone of a geometry. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="geometry">The geometry to clone.</param> /// <returns></returns> public Geom CreateGeom(PhysicsSimulator physicsSimulator, Body body, Geom geometry) { Geom geometryClone = CreateGeom(body, geometry); physicsSimulator.Add(geometryClone); return(geometryClone); }
public AngleJoint CreateAngleJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2) { AngleJoint angleJoint = CreateAngleJoint(body1, body2); physicsSimulator.Add(angleJoint); return(angleJoint); }
public RevoluteJoint CreateRevoluteJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, Vector2 initialAnchorPosition) { RevoluteJoint revoluteJoint = CreateRevoluteJoint(body1, body2, initialAnchorPosition); physicsSimulator.Add(revoluteJoint); return revoluteJoint; }
//rectangles public Body CreateRectangleBody(PhysicsSimulator physicsSimulator, float width, float height, float mass) { Body body = CreateRectangleBody(width, height, mass); physicsSimulator.Add(body); return(body); }
//ellipses /// <summary> /// Creates a ellipse body. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="xRadius">The width.</param> /// <param name="yRadius">The height.</param> /// <param name="mass">The mass.</param> /// <returns></returns> public Body CreateEllipseBody(PhysicsSimulator physicsSimulator, float xRadius, float yRadius, float mass) { Body body = CreateEllipseBody(xRadius, yRadius, mass); physicsSimulator.Add(body); return(body); }
public Body CreateBody(PhysicsSimulator physicsSimulator, Body body) { Body bodyClone = CreateBody(body); physicsSimulator.Add(bodyClone); return(bodyClone); }
//misc public Body CreateBody(PhysicsSimulator physicsSimulator, float mass, float momentOfInertia) { Body body = CreateBody(mass, momentOfInertia); physicsSimulator.Add(body); return(body); }
public override void LoadContent() { _agent = new Agent(new Vector2(500, 500)); _agent.Load(ScreenManager.GraphicsDevice, PhysicsSimulator); //LoadObstacles(); _weldedBody = new List <Body>(); _weldedGeom = new List <Geom>(); for (int i = 0; i < 128; i++) { _weldedBody.Add(BodyFactory.Instance.CreateRectangleBody(25, 25, 10.0f)); _weldedGeom.Add(GeomFactory.Instance.CreateRectangleGeom(_weldedBody[i], 25, 25)); _weldedGeom[i].RestitutionCoefficient = 0.0001f; _weldedGeom[i].FrictionCoefficient = 0.999f; PhysicsSimulator.Add(_weldedBody[i]); PhysicsSimulator.Add(_weldedGeom[i]); } for (int x = 0; x < 8; x++) { for (int y = 0; y < 16; y++) { // Width*y + x _weldedBody[8 * y + x].Position = new Vector2((x * 30) + 80, (y * 30) + 80); } } _weld = new Weld(PhysicsSimulator, _weldedGeom); base.LoadContent(); }
public void Initialize(PhysicsSimulator physicsSimulator) { //The wave controller controls how the waves move.. how big, how fast, etc.. //The wave controller is represented as set of points equally //spaced horizontally along the width of the wave. WaveController = new WaveController(); WaveController.Position = ConvertUnits.ToSimUnits(0, 300); WaveController.Width = ConvertUnits.ToSimUnits(700); WaveController.Height = ConvertUnits.ToSimUnits(200); WaveController.NodeCount = 20; //how many vertices make up the surface of the wave WaveController.DampingCoefficient = .95f; //determines how quickly the wave will disipate WaveController.Frequency = .16f; //determines how fast the wave algorithm runs (seconds) //The wave generator parameters simply move an end-point of the wave up and down. //Think of a string attached to a wall on one end and held by a person on the other. //If the person moves the string up and down to make "waves" then the arm is acting //similar to the wave generator. The WaveGeneratorStep property controls how fast the "arm" //moves. WaveController.WaveGeneratorMax = WaveGeneratorMax; WaveController.WaveGeneratorMin = WaveGeneratorMin; WaveController.WaveGeneratorStep = WaveGeneratorStep; WaveController.Initialize(); //fluid drag controller controls how things move once IN the water. FluidDragController = new FluidDragController(); FluidDragController.Initialize(WaveController, 5f, 4f, 2f, physicsSimulator.Gravity); //init with default values. physicsSimulator.Add(FluidDragController); }
/// <summary> /// Creates a gravity controller and adds it to the physics simulator. /// </summary> /// <param name="simulator">the physicsSimulator used by this controller.</param> /// <param name="points">The points you want to generate gravity.</param> /// <param name="strength">the maximum strength of gravity (the gravity strength when two bodies are on the same spot)</param> /// <param name="radius">the maximum distance that can be between 2 bodies before it will stop trying to apply gravity between them.</param> /// <returns></returns> public GravityController CreateGravityController(PhysicsSimulator simulator, List <Vector2> points, float strength, float radius) { GravityController gravityController = new GravityController(simulator, points, strength, radius); simulator.Add(gravityController); return(gravityController); }
//circles public Body CreateCircleBody(PhysicsSimulator physicsSimulator, float radius, float mass) { Body body = CreateCircleBody(radius, mass); physicsSimulator.Add(body); return(body); }
/// <summary> /// Creates a Body. The moment of inertia of the body is calculated from the /// set of vertices passed in to this method. The vertices should represent a polygon /// </summary> /// <param name="physicsSimulator"><see cref="PhysicsSimulator"/> to add this body to.</param> /// <param name="vertices">Vertices representing some polygon</param> /// <param name="mass">Mass of the Body</param> /// <returns></returns> public Body CreatePolygonBody(PhysicsSimulator physicsSimulator, Vertices vertices, float mass) { Body body = CreatePolygonBody(vertices, mass); physicsSimulator.Add(body); return(body); }
public PinJoint CreatePinJoint(PhysicsSimulator physicsSimulator, Body body1, Vector2 anchor1, Body body2, Vector2 anchor2) { PinJoint pinJoint = CreatePinJoint(body1, anchor1, body2, anchor2); physicsSimulator.Add(pinJoint); return pinJoint; }
public AngleSpring CreateAngleSpring(PhysicsSimulator physicsSimulator, Body body1, Body body2, float springConstant, float dampingConstant) { AngleSpring angleSpring = CreateAngleSpring(body1, body2, springConstant, dampingConstant); physicsSimulator.Add(angleSpring); return angleSpring; }
public AngleJoint CreateAngleJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float softness, float biasFactor) { AngleJoint angleJoint = CreateAngleJoint(body1, body2, softness, biasFactor); physicsSimulator.Add(angleJoint); return angleJoint; }
/// <summary> /// Creates the rectangle geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="positionOffset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT</param> /// <returns></returns> public Geom CreateRectangleGeom(PhysicsSimulator physicsSimulator, Body body, float width, float height, Vector2 positionOffset, float rotationOffset, float collisionGridSize) { Geom geometry = CreateRectangleGeom(body, width, height, positionOffset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return(geometry); }
public FixedAngleSpring CreateFixedAngleSpring(PhysicsSimulator physicsSimulator, Body body, float springConstant, float dampningConstant) { FixedAngleSpring fixedAngleSpring = CreateFixedAngleSpring(body, springConstant, dampningConstant); physicsSimulator.Add(fixedAngleSpring); return fixedAngleSpring; }
public FixedAngleJoint CreateFixedAngleJoint(PhysicsSimulator physicsSimulator, Body body) { FixedAngleJoint fixedAngleJoint = CreateFixedAngleJoint(body); physicsSimulator.Add(fixedAngleJoint); return(fixedAngleJoint); }
public RevoluteJoint CreateRevoluteJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, Vector2 initialAnchorPosition) { RevoluteJoint revoluteJoint = CreateRevoluteJoint(body1, body2, initialAnchorPosition); physicsSimulator.Add(revoluteJoint); return(revoluteJoint); }
public FixedAngleLimitJoint CreateFixedAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body, float min, float max) { FixedAngleLimitJoint fixedAngleLimitJoint = CreateFixedAngleLimitJoint(body, min, max); physicsSimulator.Add(fixedAngleLimitJoint); return(fixedAngleLimitJoint); }
public AngleLimitJoint CreateAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float min, float max) { AngleLimitJoint angleLimitJoint = CreateAngleLimitJoint(body1, body2, min, max); physicsSimulator.Add(angleLimitJoint); return(angleLimitJoint); }
public AngleJoint CreateAngleJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float softness, float biasFactor) { AngleJoint angleJoint = CreateAngleJoint(body1, body2, softness, biasFactor); physicsSimulator.Add(angleJoint); return(angleJoint); }
public PinJoint CreatePinJoint(PhysicsSimulator physicsSimulator, Body body1, Vector2 anchor1, Body body2, Vector2 anchor2) { PinJoint pinJoint = CreatePinJoint(body1, anchor1, body2, anchor2); physicsSimulator.Add(pinJoint); return(pinJoint); }
public SliderJoint CreateSliderJoint(PhysicsSimulator physicsSimulator, Body body1, Vector2 anchor1, Body body2, Vector2 anchor2, float min, float max) { SliderJoint sliderJoint = CreateSliderJoint(body1, anchor1, body2, anchor2, min, max); physicsSimulator.Add(sliderJoint); return(sliderJoint); }
//fixed angle limit joint public FixedAngleLimitJoint CreateFixedAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body, float lowerLimit, float upperLimit) { FixedAngleLimitJoint fixedAngleLimitJoint = CreateFixedAngleLimitJoint(body, lowerLimit, upperLimit); physicsSimulator.Add(fixedAngleLimitJoint); return(fixedAngleLimitJoint); }
public FixedAngleSpring CreateFixedAngleSpring(PhysicsSimulator physicsSimulator, Body body, float springConstant, float dampningConstant) { FixedAngleSpring fixedAngleSpring = CreateFixedAngleSpring(body, springConstant, dampningConstant); physicsSimulator.Add(fixedAngleSpring); return(fixedAngleSpring); }
/// <summary> /// Creates a circle geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="radius">The radius.</param> /// <param name="numberOfEdges">The number of edges.</param> /// <param name="offset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT</param> /// <returns></returns> public Geom CreateCircleGeom(PhysicsSimulator physicsSimulator, Body body, float radius, int numberOfEdges, Vector2 offset, float rotationOffset, float collisionGridSize) { Geom geometry = CreateCircleGeom(body, radius, numberOfEdges, offset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return(geometry); }
public AngleSpring CreateAngleSpring(PhysicsSimulator physicsSimulator, Body body1, Body body2, float springConstant, float dampningConstant) { AngleSpring angleSpring = CreateAngleSpring(body1, body2, springConstant, dampningConstant); physicsSimulator.Add(angleSpring); return(angleSpring); }
/// <summary> /// Creates a clone of a geometry. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="geometry">The geometry to clone.</param> /// <param name="offset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <returns></returns> public Geom CreateGeom(PhysicsSimulator physicsSimulator, Body body, Geom geometry, Vector2 offset, float rotationOffset) { Geom geometryClone = CreateGeom(body, geometry, offset, rotationOffset); physicsSimulator.Add(geometryClone); return(geometryClone); }
public FixedLinearSpring CreateFixedLinearSpring(PhysicsSimulator physicsSimulator, Body body, Vector2 bodyAttachPoint, Vector2 worldAttachPoint, float springConstant, float dampingConstant) { FixedLinearSpring fixedSpring = CreateFixedLinearSpring(body, bodyAttachPoint, worldAttachPoint, springConstant, dampingConstant); physicsSimulator.Add(fixedSpring); return fixedSpring; }
public LinearSpring CreateLinearSpring(PhysicsSimulator physicsSimulator, Body body1, Vector2 attachPoint1, Body body2, Vector2 attachPoint2, float springConstant, float dampingConstant) { LinearSpring linearSpring = CreateLinearSpring(body1, attachPoint1, body2, attachPoint2, springConstant, dampingConstant); physicsSimulator.Add(linearSpring); return linearSpring; }
/// <summary> /// Creates a circle geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="radius">The radius.</param> /// <param name="numberOfEdges">The number of edges.</param> /// <param name="offset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT</param> /// <returns></returns> public Geom CreateCircleGeom(PhysicsSimulator physicsSimulator, Body body, float radius, int numberOfEdges, Vector2 offset, float rotationOffset, float collisionGridSize) { Geom geometry = CreateCircleGeom(body, radius, numberOfEdges, offset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return geometry; }
/// <summary> /// Creates a polygon geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="vertices">The vertices.</param> /// <param name="positionOffset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT /// Put in 0 or less to make the engine calculate a grid cell size.</param> /// <returns></returns> public Geom CreatePolygonGeom(PhysicsSimulator physicsSimulator, Body body, Vertices vertices, Vector2 positionOffset, float rotationOffset, float collisionGridSize) { Geom geometry = CreatePolygonGeom(body, vertices, positionOffset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return geometry; }
public AngleJoint CreateAngleJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2) { AngleJoint angleJoint = CreateAngleJoint(body1, body2); physicsSimulator.Add(angleJoint); return angleJoint; }
public Body CreateBody(PhysicsSimulator physicsSimulator, Body body) { Body bodyClone = CreateBody(body); physicsSimulator.Add(bodyClone); return bodyClone; }
public AngleLimitJoint CreateAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body1, Body body2, float min, float max) { AngleLimitJoint angleLimitJoint = CreateAngleLimitJoint(body1, body2, min, max); physicsSimulator.Add(angleLimitJoint); return angleLimitJoint; }
/// <summary> /// Creates a gravity controller and adds it to the physics simulator. /// </summary> /// <param name="simulator">the physicsSimulator used by this controller.</param> /// <param name="bodies">The bodies you want to generate gravity.</param> /// <param name="strength">the maximum strength of gravity (the gravity strength when two bodies are on the same spot)</param> /// <param name="radius">the maximum distance that can be between 2 bodies before it will stop trying to apply gravity between them.</param> /// <returns></returns> public GravityController CreateGravityController(PhysicsSimulator simulator, List<Body> bodies, float strength, float radius) { GravityController gravityController = new GravityController(simulator, bodies, strength, radius); simulator.Add(gravityController); return gravityController; }
public SliderJoint CreateSliderJoint(PhysicsSimulator physicsSimulator, Body body1, Vector2 anchor1, Body body2, Vector2 anchor2, float min, float max) { SliderJoint sliderJoint = CreateSliderJoint(body1, anchor1, body2, anchor2, min, max); physicsSimulator.Add(sliderJoint); return sliderJoint; }
/// <summary> /// Adds to physics simulator. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> public void AddToPhysicsSimulator(PhysicsSimulator physicsSimulator) { foreach (Body body in _bodies) physicsSimulator.Add(body); foreach (Geom geom in _geoms) physicsSimulator.Add(geom); foreach (Joint joint in _joints) physicsSimulator.Add(joint); foreach (Spring spring in _springs) physicsSimulator.Add(spring); }
public FixedRevoluteJoint CreateFixedRevoluteJoint(PhysicsSimulator physicsSimulator, Body body, Vector2 anchor) { FixedRevoluteJoint revoluteJoint = CreateFixedRevoluteJoint(body, anchor); physicsSimulator.Add(revoluteJoint); return revoluteJoint; }
/// <summary> /// Creates rectangular geoms that match the size of the bodies. /// Then adds the geometries to the given physics simulator. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="collisionGroup">The collision group.</param> public void CreateGeoms(PhysicsSimulator physicsSimulator, int collisionGroup) { CreateGeoms(collisionGroup); foreach (Geom geom in _geoms) { physicsSimulator.Add(geom); } }
public FixedAngleLimitJoint CreateFixedAngleLimitJoint(PhysicsSimulator physicsSimulator, Body body, float min, float max) { FixedAngleLimitJoint fixedAngleLimitJoint = CreateFixedAngleLimitJoint(body, min, max); physicsSimulator.Add(fixedAngleLimitJoint); return fixedAngleLimitJoint; }
/// <summary> /// Creates a gravity controller and adds it to the physics simulator. /// </summary> /// <param name="simulator">the physicsSimulator used by this controller.</param> /// <param name="points">The points you want to generate gravity.</param> /// <param name="strength">the maximum strength of gravity (the gravity strength when two bodies are on the same spot)</param> /// <param name="radius">the maximum distance that can be between 2 bodies before it will stop trying to apply gravity between them.</param> /// <returns></returns> public GravityController CreateGravityController(PhysicsSimulator simulator, List<Vector2> points, float strength, float radius) { GravityController gravityController = new GravityController(simulator, points, strength, radius); simulator.Add(gravityController); return gravityController; }
/// <summary> /// Creates a ellipse body. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="xRadius">The width.</param> /// <param name="yRadius">The height.</param> /// <param name="mass">The mass.</param> /// <returns></returns> public Body CreateEllipseBody(PhysicsSimulator physicsSimulator, float xRadius, float yRadius, float mass) { Body body = CreateEllipseBody(xRadius, yRadius, mass); physicsSimulator.Add(body); return body; }
/// <summary> /// Creates the rectangle geom. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="positionOffset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <param name="collisionGridSize">Size of the collision grid. - not used with SAT</param> /// <returns></returns> public Geom CreateRectangleGeom(PhysicsSimulator physicsSimulator, Body body, float width, float height, Vector2 positionOffset, float rotationOffset, float collisionGridSize) { Geom geometry = CreateRectangleGeom(body, width, height, positionOffset, rotationOffset, collisionGridSize); physicsSimulator.Add(geometry); return geometry; }
/// <summary> /// Creates a rectangle body. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="mass">The mass.</param> /// <returns></returns> public Body CreateRectangleBody(PhysicsSimulator physicsSimulator, float width, float height, float mass) { Body body = CreateRectangleBody(width, height, mass); physicsSimulator.Add(body); return body; }
/// <summary> /// Creates a clone of a geometry. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="geometry">The geometry to clone.</param> /// <param name="offset">The offset.</param> /// <param name="rotationOffset">The rotation offset.</param> /// <returns></returns> public Geom CreateGeom(PhysicsSimulator physicsSimulator, Body body, Geom geometry, Vector2 offset, float rotationOffset) { Geom geometryClone = CreateGeom(body, geometry, offset, rotationOffset); physicsSimulator.Add(geometryClone); return geometryClone; }
public FixedAngleJoint CreateFixedAngleJoint(PhysicsSimulator physicsSimulator, Body body) { FixedAngleJoint fixedAngleJoint = CreateFixedAngleJoint(body); physicsSimulator.Add(fixedAngleJoint); return fixedAngleJoint; }
/// <summary> /// Creates a Body. The moment of inertia of the body is calculated from the /// set of vertices passed in to this method. The vertices should represent a polygon. /// </summary> /// <param name="physicsSimulator"><see cref="PhysicsSimulator"/> to add this body to.</param> /// <param name="vertices">Vertices representing some polygon</param> /// <param name="mass">Mass of the Body</param> /// <returns></returns> public Body CreatePolygonBody(PhysicsSimulator physicsSimulator, Vertices vertices, float mass) { Body body = CreatePolygonBody(vertices, mass); physicsSimulator.Add(body); return body; }
/// <summary> /// Creates a clone of a geometry. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="geometry">The geometry to clone.</param> /// <returns></returns> public Geom CreateGeom(PhysicsSimulator physicsSimulator, Body body, Geom geometry) { Geom geometryClone = CreateGeom(body, geometry); physicsSimulator.Add(geometryClone); return geometryClone; }
public Body CreateBody(PhysicsSimulator physicsSimulator, float mass, float momentOfInertia) { Body body = CreateBody(mass, momentOfInertia); physicsSimulator.Add(body); return body; }
/// <summary> /// Creates a polygon geometry. /// Use this if you use the SAT narrow phase collider. It will automatically decompose concave geometries using auto-divide. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="body">The body.</param> /// <param name="vertices">The vertices.</param> /// <param name="maxGeoms">The number of geometries to split the geometry into. It is needed to make SAT support concave polygons. The engine will try to reach the desired number of geometries.</param> /// <returns></returns> public List<Geom> CreateSATPolygonGeom(PhysicsSimulator physicsSimulator, Body body, Vertices vertices, int maxGeoms) { List<Geom> geometries = CreateSATPolygonGeom(body, vertices, maxGeoms); foreach (Geom geom in geometries) { physicsSimulator.Add(geom); } return geometries; }
/// <summary> /// Creates a circle body. /// </summary> /// <param name="physicsSimulator">The physics simulator.</param> /// <param name="radius">The radius.</param> /// <param name="mass">The mass.</param> /// <returns></returns> public Body CreateCircleBody(PhysicsSimulator physicsSimulator, float radius, float mass) { Body body = CreateCircleBody(radius, mass); physicsSimulator.Add(body); return body; }
/// <summary> /// Creates rectangular geoms that match the size of the bodies. /// Then adds the geometries to the given physics simulator. /// </summary> /// <param name="collisionCategory">The collision category of the geometries.</param> /// <param name="collidesWith">The collisioncategory the geometries should collide with..</param> /// <param name="physicsSimulator">The physics simulator.</param> public void CreateGeoms(CollisionCategory collisionCategory, CollisionCategory collidesWith, PhysicsSimulator physicsSimulator) { CreateGeoms(collisionCategory, collidesWith); foreach (Geom geom in _geoms) { physicsSimulator.Add(geom); } }