public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); // Traverse the contact results. Apply a force on shapes // that overlap the sensor. for (int i = 0; i < Count; ++i) { if (_touching[i] == false) { continue; } Body body = _bodies[i]; Body ground = _sensor.Body; CircleShape circle = (CircleShape)_sensor.Shape; Vector2 center = ground.GetWorldPoint(circle.Position); Vector2 position = body.Position; Vector2 d = center - position; if (d.LengthSquared < Alt.FarseerPhysics.Settings.Epsilon * Alt.FarseerPhysics.Settings.Epsilon) { continue; } d.Normalize(); Vector2 f = 100.0f * d; body.ApplyForce(f, position); } }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Note: The left side of the ship has a different density than the right side of the ship"); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Triangulation took " + _sw.ElapsedMilliseconds + " ms"); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Press (j) to toggle the rope joint."); DrawString(_useRopeJoint ? "Rope ON" : "Rope OFF"); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Keys: left = a, brake = s, right = d, toggle motor = m"); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); DrawString("Press: (,) to launch a bullet."); //if (StepCount == 300) //{ // if (_bullet != null) // { // World.Remove(_bullet); // _bullet = null; // } // { // CircleShape shape = new CircleShape(0.25f, 20); // _bullet = BodyFactory.CreateBody(World); // _bullet.BodyType = BodyType.Dynamic; // _bullet.Bullet = true; // _bullet.Position = new Vector2(-31.0f, 5.0f); // _bullet.LinearVelocity = new Vector2(400.0f, 0.0f); // Fixture fixture = _bullet.CreateFixture(shape); // fixture.Restitution = 0.05f; // } //} // }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); PolyShapesCallback callback = new PolyShapesCallback(); callback.Circle.Radius = 2.0f; callback.Circle.Position = new Vector2(0.0f, 1.1f); callback.Transform.SetIdentity(); callback.DebugDraw = DebugView; AABB aabb; callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0); World.QueryAABB(callback.ReportFixture, ref aabb); Color color = new ColorR(0.4f, 0.7f, 0.8f); DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color); DrawString("Press 1-5 to drop stuff"); DrawString("Press a to (de)activate some bodies"); DrawString("Press d to destroy a body"); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Rotation: " + _circleFixture.Body.Rotation); DrawString("Revolutions: " + _circleFixture.Body.Revolutions); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); double ratio = _joint1.Ratio; double l = _joint1.LengthA + ratio * _joint1.LengthB; DrawString(string.Format("L1 + {0:n} * L2 = {1:n}", ratio, l)); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); DrawString("Keys: (f) toggle friction, (m) toggle motor"); double torque = _joint1.GetMotorTorque(settings.Hz); DrawString("Motor Torque = " + torque); }
public override void Update(FarseerPhysicsGameSettings settings) { Body body = BodyFactory.CreateCircle(World, 0.4f, 1); body.Position = new Vector2(Rand.RandomFloat(-35, 35), 10); body.BodyType = BodyType.Dynamic; body.Restitution = 1f; base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); for (int i = 0; i < _removeBodies.Count; i++) { World.RemoveBody(_removeBodies[i]); } _removeBodies.Clear(); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); if (_count < Count) { Body box = BodyFactory.CreateRectangle(World, 0.125f * 2, 0.125f * 2, 1, new Vector2(0, 10)); box.BodyType = BodyType.Dynamic; ++_count; } }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); DrawString("This demonstrates a soft distance joint."); DrawString("Press: (b) to delete a body, (j) to delete a joint"); DrawString("Bodies removed: " + _removedBodies); DrawString("Joints removed: " + _removedJoints); }
public override void Update(FarseerPhysicsGameSettings settings) { Vector2 v = _character.LinearVelocity; v.X = -5.0f; _character.LinearVelocity = v; DrawString(_collision ? "OnCollision fired" : "OnSeparation fired"); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { _time += 0.01f; if (_time > 1f) { _time = 0; } PathManager.MoveBodyOnPath(_path, _movingBody, _time, 1f, 1f / 60f); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("SimpleWindForce | Mouse: Direction | Left-Click: Position | W/S: Variation"); DrawString("Wind Strength:" + _simpleWind.Strength); DrawString("Variation:" + _simpleWind.Variation); //DebugView.DrawSegment(SimpleWind.Position, SimpleWind.Direction-SimpleWind.Position, Color.Red); DrawPointForce(); base.Update(settings); }
protected void Initialize() { m_InfoFont = new Alt.Sketch.Font("Arial", 10.01, Alt.Sketch.FontStyle.Bold); settings = new FarseerPhysicsGameSettings(); FarseerPhysics_onRestart(); m_Timer = new Alt.GUI.Timer(10); m_Timer.Tick += Timer_Tick; m_Timer.Start(); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); double ratio = _joint4.Ratio; double value = _joint1.JointAngle + ratio * _joint2.JointAngle; DrawString(string.Format("theta1 + {0} * theta2 = {1}", ratio, value)); ratio = _joint5.Ratio; value = _joint2.JointAngle + ratio * _joint3.JointTranslation; DrawString(string.Format("theta2 + {0} * delta = {1}", ratio, value)); }
public override void Update(FarseerPhysicsGameSettings settings) { foreach (Vertices vertex in _polygons) { if (vertex != null) { Vector2[] array = vertex.ToArray(); Color col = Color.SteelBlue; if (!vertex.IsCounterClockWise()) { col = Color.Aquamarine; } if (vertex == _selected) { col = Color.LightBlue; } if (vertex == _subject) { col = Color.Green; if (vertex == _selected) { col = Color.LightGreen; } } if (vertex == _clip) { col = Color.DarkRed; if (vertex == _selected) { col = Color.IndianRed; } } DebugView.DrawPolygon(array, vertex.Count, col); for (int j = 0; j < vertex.Count; ++j) { DebugView.DrawPoint(vertex[j], .2f, Color.Red); } } } DrawString("A,S,D = Create Rectangle"); DrawString("Q,W,E = Create Circle"); DrawString("Click to Drag polygons"); DrawString("1 = Select Subject while dragging [green]"); DrawString("2 = Select Clip while dragging [red]"); DrawString("Space = Union"); DrawString("Backspace = Subtract"); DrawString("Shift = Intersect"); DrawString("Holes are colored light blue"); }
public override void Update(FarseerPhysicsGameSettings settings) { DebugView.DrawAABB(ref _terrainArea, Color.Red * 0.5f); DrawString("Left click and drag the mouse to destroy terrain!"); DrawString("Right click and drag the mouse to create terrain!"); DrawString("Middle click to create circles!"); DrawString("Press t or y to cycle between decomposers: " + _terrain.Decomposer); TextLine += 25; DrawString("Press g or h to decrease/increase circle radius: " + _circleRadius); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { ContactManager cm = World.ContactManager; DynamicTreeBroadPhase dt = (DynamicTreeBroadPhase)cm.BroadPhase; int height = dt.TreeHeight; int leafCount = dt.ProxyCount; double minimumNodeCount = 2 * leafCount - 1; double minimumHeight = (double)Math.Ceiling(Math.Log(minimumNodeCount) / Math.Log(2.0f)); DrawString(string.Format("dynamic tree Height = {0}, min = {1}", height, (int)minimumHeight)); DrawString(string.Format("create time = {0} ms, fixture count = {1}", _createTime, _fixtureCount)); base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Press A,S,W,D move endpoint"); DrawString("Press Enter to cut"); DrawString("Press TAB to change endpoint"); DebugView.DrawSegment(_start, _end, Color.Red); List <Fixture> fixtures = new List <Fixture>(); List <Vector2> entryPoints = new List <Vector2>(); List <Vector2> exitPoints = new List <Vector2>(); //Get the entry points World.RayCast((f, p, n, fr) => { fixtures.Add(f); entryPoints.Add(p); return(1); }, _start, _end); //Reverse the ray to get the exitpoints World.RayCast((f, p, n, fr) => { exitPoints.Add(p); return(1); }, _end, _start); DrawString("Fixtures: " + fixtures.Count); foreach (Vector2 entryPoint in entryPoints) { DebugView.DrawPoint(entryPoint, 0.5f, Color.Yellow); } foreach (Vector2 exitPoint in exitPoints) { DebugView.DrawPoint(exitPoint, 0.5f, Color.PowderBlue); } base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Loaded: " + _nextFileName + " - Press T for next"); Vector2 offset = new Vector2(-6, 12); for (int i = 0; i < _names.Length; i++) { string title = string.Format("{0}: {1} ms - {2} triangles", _names[i], _timings[i], _bodies[i].FixtureList.Count); Vector2 screenPosition = ConvertWorldToScreen(_bodies[i].Position + offset); DebugView.DrawString((int)screenPosition.X, (int)screenPosition.Y, title); } base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); DistanceInput input = new DistanceInput(); input.ProxyA.Set(_polygonA, 0); input.ProxyB.Set(_polygonB, 0); input.TransformA = _transformA; input.TransformB = _transformB; input.UseRadii = true; SimplexCache cache; cache.Count = 0; DistanceOutput output; Distance.ComputeDistance(out output, out cache, input); DrawString("Distance = " + output.Distance); DrawString("Iterations = " + output.Iterations); { Color color = new ColorR(0.9f, 0.9f, 0.9f); Vector2[] v = new Vector2[Alt.FarseerPhysics.Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.Vertices.Count; ++i) { v[i] = MathUtils.Mul(ref _transformA, _polygonA.Vertices[i]); } DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color); for (int i = 0; i < _polygonB.Vertices.Count; ++i) { v[i] = MathUtils.Mul(ref _transformB, _polygonB.Vertices[i]); } DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color); } Vector2 x1 = output.PointA; Vector2 x2 = output.PointB; DebugView.DrawPoint(x1, 0.5f, new ColorR(1.0f, 0.0f, 0.0f)); DebugView.DrawPoint(x2, 0.5f, new ColorR(1.0f, 0.0f, 0.0f)); DebugView.DrawSegment(x1, x2, new ColorR(1.0f, 1.0f, 0.0f)); }
public override void Update(FarseerPhysicsGameSettings settings) { DrawString("Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); DrawString(string.Format("frequency = {0} hz, damping ratio = {1}", _hz, _zeta)); DrawString(string.Format("actual speed = {0} rad/sec", _spring1.JointSpeed.ToString("F1"))); base.Update(settings); Vector2 carPosition = _car.Position; carPosition.X = -carPosition.X; ViewCenter = carPosition; }
public override void Update(FarseerPhysicsGameSettings settings) { bool advanceRay = settings.Pause == false || settings.SingleStep; base.Update(settings); DrawString("Press 1-5 to drop stuff"); const double l = 25.0f; Vector2 point1 = new Vector2(0.0f, 10.0f); Vector2 d = new Vector2(l * (double)Math.Cos(_angle), -l * Math.Abs((double)Math.Sin(_angle))); Vector2 point2 = point1 + d; _fixture = null; World.RayCast((fixture, point, normal, fraction) => { _fixture = fixture; _point = point; _normal = normal; return(fraction); }, point1, point2); if (_fixture != null) { DebugView.DrawPoint(_point, 0.5f, new ColorR(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, _point, new ColorR(0.8f, 0.8f, 0.8f)); Vector2 head = _point + 0.5f * _normal; DebugView.DrawSegment(_point, head, new ColorR(0.9f, 0.9f, 0.4f)); } else { DebugView.DrawSegment(point1, point2, new ColorR(0.8f, 0.8f, 0.8f)); } if (advanceRay) { _angle += 0.25f * Alt.FarseerPhysics.Settings.Pi / 180.0f; } }
public override void Update(FarseerPhysicsGameSettings settings) { if (_break) { Break(); _broke = true; _break = false; } // Cache velocities to improve movement on breakage. if (_broke == false) { _velocity = _body1.LinearVelocity; _angularVelocity = _body1.AngularVelocity; } base.Update(settings); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); if (!settings.Pause && settings.Hz > 0.0f) { _time += 1.0f / settings.Hz; } Vector2 linearOffset = new Vector2(); linearOffset.X = 6.0f * (double)Math.Sin(2.0f * _time); linearOffset.Y = 8.0f + 4.0f * (double)Math.Sin(1.0f * _time); double angularOffset = 4.0f * _time; _joint.LinearOffset = linearOffset; _joint.AngularOffset = angularOffset; }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); DrawString("Press: (,) to explode at mouse position."); DrawString("Press: (A) to decrease the explosion radius, (S) to increase it."); DrawString("Press: (D) to decrease the explosion power, (F) to increase it."); // Fighting against double decimals double powernumber = (double)((int)(_force * 10)) / 10; DrawString("Power: " + powernumber); Color color = new ColorR(0.4f, 0.7f, 0.8f); DebugView.DrawCircle(_mousePos, _radius, color); }