public override void Update(GameSettings settings, GameTime gameTime) { if (StepCount == 12) { StepCount += 0; } base.Update(settings, gameTime); if (Distance.GJKCalls > 0) { DebugView.DrawString(50, TextLine, "GJK calls = {0}, Ave GJK iters = {1}, Max GJK iters = {2}", Distance.GJKCalls, Distance.GJKIters / (float)Distance.GJKCalls, Distance.GJKMaxIters); TextLine += 15; } if (TimeOfImpact.TOICalls > 0) { DebugView.DrawString(50, TextLine, "TOI calls = {0}, Ave TOI iters = {1}, Max TOI iters = {2}", TimeOfImpact.TOICalls, TimeOfImpact.TOIIters / (float)TimeOfImpact.TOICalls, TimeOfImpact.TOIMaxRootIters); TextLine += 15; DebugView.DrawString(50, TextLine, "Ave TOI root iters = {0}, Max TOI root iters = {1}", TimeOfImpact.TOIRootIters / (float)TimeOfImpact.TOICalls, TimeOfImpact.TOIMaxRootIters); TextLine += 15; } if (StepCount % 60 == 0) { //Launch(); } }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); PolygonShape shape = new PolygonShape(new Vertices(_points), 0f); DebugView.DrawString(5, TextLine, "Press g to generate a new random convex hull"); TextLine += 15; DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawPolygon(shape.Vertices.ToArray(), shape.Vertices.Count, new Color(0.9f, 0.9f, 0.9f)); for (int i = 0; i < _count; ++i) { DebugView.DrawPoint(_points[i], 0.1f, new Color(0.9f, 0.5f, 0.5f)); Vector2 position = GameInstance.ConvertWorldToScreen(_points[i]); DebugView.DrawString((int)position.X, (int)position.Y, i.ToString()); } DebugView.EndCustomDraw(); if (shape.Vertices.IsConvex() == false) { TextLine += 0; } if (_auto) { Generate(); } }
public override void Update(GameSettings settings, GameTime gameTime) { Manifold manifold = new Manifold(); Collision.Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB); Vector2 normal; FixedArray2<Vector2> points; Collision.Collision.GetWorldManifold(ref manifold, ref _transformA, _polygonA.Radius, ref _transformB, _polygonB.Radius, out normal, out points); DebugView.DrawString(50, TextLine, "Point count = {0:n0}", manifold.PointCount); TextLine += 15; DebugView.BeginCustomDraw(); { Color color = new Color(0.9f, 0.9f, 0.9f); Vector2[] v = new Vector2[Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.Vertices.Count; ++i) { v[i] = MathUtils.Multiply(ref _transformA, _polygonA.Vertices[i]); } DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color); for (int i = 0; i < _polygonB.Vertices.Count; ++i) { v[i] = MathUtils.Multiply(ref _transformB, _polygonB.Vertices[i]); } DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color); } for (int i = 0; i < manifold.PointCount; ++i) { DebugView.DrawPoint(points[i], 0.1f, new Color(0.9f, 0.3f, 0.3f)); } DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Segments: " + _segments + "\nPress: 'A' to increase segments, 'S' decrease segments\n'D' to create rectangle. 'F' to create capsule."); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { 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, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); float ratio = _joint1.Ratio; float l = _joint1.LengthA + ratio * _joint1.LengthB; DebugView.DrawString(50, TextLine, "L1 + {0:n} * L2 = {1:n}", ratio, l); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { _time += 0.01f; if (_time > 1f) _time = 0; PathManager.MoveBodyOnPath(_path, _movingBody, _time, 1f, 1f / 60f); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); 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(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "SimpleWindForce | Mouse: Direction | Left-Click: Position | W/S: Variation"); TextLine += 15; DebugView.DrawString(50, TextLine, "Wind Strength:" + _simpleWind.Strength); TextLine += 15; DebugView.DrawString(50, TextLine, "Variation:" + _simpleWind.Variation); DebugView.BeginCustomDraw(); //DebugView.DrawSegment(SimpleWind.Position, SimpleWind.Direction-SimpleWind.Position, Color.Red); DrawPointForce(); DebugView.EndCustomDraw(); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); 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); DebugView.DrawString(50, TextLine, "Distance = {0:n7}", output.Distance); TextLine += 15; DebugView.DrawString(50, TextLine, "Iterations = {0:n0}", output.Iterations); TextLine += 15; DebugView.BeginCustomDraw(); { Color color = new Color(0.9f, 0.9f, 0.9f); CCVector2[] v = new CCVector2[Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.Vertices.Count; ++i) { v[i] = (CCVector2)MathUtils.Multiply(ref _transformA, _polygonA.Vertices[i]); } DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color); for (int i = 0; i < _polygonB.Vertices.Count; ++i) { v[i] = (CCVector2)MathUtils.Multiply(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 Color(1.0f, 0.0f, 0.0f)); DebugView.DrawPoint(x2, 0.5f, new Color(1.0f, 0.0f, 0.0f)); DebugView.DrawSegment(x1, x2, new Color(1.0f, 1.0f, 0.0f)); DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Press A,S,W,D move endpoint"); TextLine += 15; DebugView.DrawString(50, TextLine, "Press Enter to cut"); TextLine += 15; DebugView.DrawString(50, TextLine, "Press TAB to change endpoint"); TextLine += 15; DebugView.BeginCustomDraw(); DebugView.DrawSegment(_start, _end, Color.Red); DebugView.EndCustomDraw(); 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); DebugView.DrawString(50, TextLine, "Fixtures: " + fixtures.Count); DebugView.BeginCustomDraw(); foreach (Vector2 entryPoint in entryPoints) { DebugView.DrawPoint(entryPoint, 0.5f, Color.Yellow); } foreach (Vector2 exitPoint in exitPoints) { DebugView.DrawPoint(exitPoint, 0.5f, Color.PowderBlue); } DebugView.EndCustomDraw(); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); if (m_Count < Count) { var body = BodyFactory.CreateBody(World, new Vector2(0.0f, 10.0f)); body.BodyType = BodyType.Dynamic; PolygonShape shape = new PolygonShape(5); shape.SetAsBox(0.125f, 0.125f); body.CreateFixture(shape); m_Count++; } }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); if (!settings.Pause && settings.Hz > 0.0f) _time += 1.0f / settings.Hz; Vector2 linearOffset = new Vector2(); linearOffset.X = 6.0f * (float)Math.Sin(2.0f * _time); linearOffset.Y = 8.0f + 4.0f * (float)Math.Sin(1.0f * _time); float angularOffset = 4.0f * _time; _joint.LinearOffset = linearOffset; _joint.AngularOffset = angularOffset; }
public override void Update(GameSettings settings, GameTime gameTime) { time += gameTime.ElapsedGameTime.Milliseconds; if (time > 100) { time = 0; if (save) { WorldSerializer.Serialize(World, "out.xml"); } else { WorldSerializer.Deserialize(World, "out.xml"); } save = !save; } base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { _count++; if (_count < 50) { const float x = 0; const float y = 15; Body body = BodyFactory.CreateBody(World); body.Position = new Vector2(x, y); body.BodyType = BodyType.Dynamic; Fixture fixture = body.CreateFixture(_polyShape); fixture.Friction = 0.3f; } base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Press: left mouse button to remove at mouse position."); TextLine += 15; DebugView.DrawString(50, TextLine, "Press: (A) to decrease the removal radius, (S) to increase it."); TextLine += 15; // Fighting against float decimals float radiusnumber = (float)((int)(Radius * 10)) / 10; DebugView.DrawString(50, TextLine, "Radius: " + radiusnumber); Color color = new Color(0.4f, 0.7f, 0.8f); //Transform shape to mouseposition and then draw Vertices tempshape = new Vertices(_clipCircle); tempshape.Translate(ref _mousePos); DebugView.BeginCustomDraw(); DebugView.DrawPolygon(tempshape.ToArray(), _clipCircle.Count, color); DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { Vector2 min = -new Vector2(10); Vector2 max = new Vector2(10); AABB affected = new AABB(ref min, ref max); Fixture fix = null; World.QueryAABB(fixture => { fix = fixture; return true; }, ref affected); //DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); //if (fix != null) // DebugView.DrawPoint(fix.Body.Position, 1, Color.Red); //DebugView.DrawAABB(ref affected, Color.AliceBlue); //DebugView.EndCustomDraw(); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Melkman: Red"); TextLine += 15; DebugView.DrawString(50, TextLine, "Giftwrap: Green"); TextLine += 15; DebugView.DrawString(50, TextLine, "ChainHull: Blue"); TextLine += 15; DebugView.BeginCustomDraw(); for (int i = 0; i < 32; i++) { DebugView.DrawPoint(_pointCloud1[i], 0.1f, Color.Yellow); DebugView.DrawPoint(_pointCloud2[i], 0.1f, Color.Yellow); DebugView.DrawPoint(_pointCloud3[i], 0.1f, Color.Yellow); } var vector2List = new List<CCVector2>(); foreach (var v in _melkman) vector2List.Add((CCVector2)v); DebugView.DrawPolygon(vector2List.ToArray(), _melkman.Count, Color.Red); vector2List.Clear(); foreach (var v in _giftWrap) vector2List.Add((CCVector2)v); DebugView.DrawPolygon(vector2List.ToArray(), _giftWrap.Count, Color.Green); vector2List.Clear(); foreach (var v in _chainHull) vector2List.Add((CCVector2)v); DebugView.DrawPolygon(vector2List.ToArray(), _chainHull.Count, Color.Blue); DebugView.EndCustomDraw(); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Melkman: Red"); TextLine += 15; DebugView.DrawString(50, TextLine, "Giftwrap: Green"); TextLine += 15; DebugView.DrawString(50, TextLine, "ChainHull: Blue"); TextLine += 15; DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); for (int i = 0; i < 32; i++) { DebugView.DrawPoint(_pointCloud1[i], 0.1f, Color.Yellow); DebugView.DrawPoint(_pointCloud2[i], 0.1f, Color.Yellow); DebugView.DrawPoint(_pointCloud3[i], 0.1f, Color.Yellow); } DebugView.DrawPolygon(_melkman.ToArray(), _melkman.Count, Color.Red); DebugView.DrawPolygon(_giftWrap.ToArray(), _giftWrap.Count, Color.Green); DebugView.DrawPolygon(_chainHull.ToArray(), _chainHull.Count, Color.Blue); DebugView.EndCustomDraw(); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); float ratio = _joint4.Ratio; float value = _joint1.JointAngle + ratio * _joint2.JointAngle; DebugView.DrawString(50, TextLine, "theta1 + {0} * theta2 = {1}", ratio, value); TextLine += 15; ratio = _joint5.Ratio; value = _joint2.JointAngle + ratio * _joint3.JointTranslation; DebugView.DrawString(50, TextLine, "theta2 + {0} * delta = {1}", ratio, value); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Press (j) to toggle the rope joint."); TextLine += 15; DebugView.DrawString(50, TextLine, _useRopeJoint ? "Rope ON" : "Rope OFF"); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { for (int i = 0; i < _polygons.Count; ++i) { if (_polygons[i] != null) { Vector2[] array = _polygons[i].ToArray(); Color col = Color.SteelBlue; if (!_polygons[i].IsCounterClockWise()) { col = Color.Aquamarine; } if (_polygons[i] == _selected) { col = Color.LightBlue; } if (_polygons[i] == _subject) { col = Color.Green; if (_polygons[i] == _selected) { col = Color.LightGreen; } } if (_polygons[i] == _clip) { col = Color.DarkRed; if (_polygons[i] == _selected) { col = Color.IndianRed; } } DebugView.BeginCustomDraw(); DebugView.DrawPolygon(array, _polygons[i].Count, col); for (int j = 0; j < _polygons[i].Count; ++j) { DebugView.DrawPoint(_polygons[i][j], .2f, Color.Red); } DebugView.EndCustomDraw(); } } DebugView.DrawString(500, TextLine, "A,S,D = Create Rectangle"); TextLine += 15; DebugView.DrawString(500, TextLine, "Q,W,E = Create Circle"); TextLine += 15; DebugView.DrawString(500, TextLine, "Click to Drag polygons"); TextLine += 15; DebugView.DrawString(500, TextLine, "1 = Select Subject while dragging [green]"); TextLine += 15; DebugView.DrawString(500, TextLine, "2 = Select Clip while dragging [red]"); TextLine += 15; DebugView.DrawString(500, TextLine, "Space = Union"); TextLine += 15; DebugView.DrawString(500, TextLine, "Backspace = Subtract"); TextLine += 15; DebugView.DrawString(500, TextLine, "Shift = Intersect"); TextLine += 15; DebugView.DrawString(500, TextLine, "Holes are colored light blue"); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { // Drive the kinematic body. if (_platform.BodyType == BodyType.Kinematic) { Transform tf; _platform.GetTransform(out tf); Vector2 p = tf.p; Vector2 v = _platform.LinearVelocity; if ((p.X < -10.0f && v.X < 0.0f) || (p.X > 10.0f && v.X > 0.0f)) { v.X = -v.X; _platform.LinearVelocity = v; } } base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Keys: (d) dynamic, (s) static, (k) kinematic"); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Keys: left = a, brake = s, right = d, hz down = q, hz up = e"); TextLine += 15; DebugView.DrawString(50, TextLine, "frequency = {0} hz, damping ratio = {1}", _hz, _zeta); TextLine += 15; DebugView.DrawString(50, TextLine, "actual speed = {0} rad/sec", _spring1.JointSpeed); TextLine += 15; GameInstance.ViewCenter = _car.Position; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Left click and drag the mouse to destroy terrain!"); TextLine += 15; DebugView.DrawString(50, TextLine, "Right click and drag the mouse to create terrain!"); TextLine += 15; DebugView.DrawString(50, TextLine, "Middle click to create circles!"); TextLine += 15; DebugView.DrawString(50, TextLine, "Press t or y to cycle between decomposers: " + _terrain.Decomposer); TextLine += 25; DebugView.DrawString(50, TextLine, "Press g or h to decrease/increase circle radius: " + _circleRadius); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { bool advanceRay = settings.Pause == false || settings.SingleStep; base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Press 1-5 to drop stuff"); TextLine += 15; const float l = 25.0f; Vector2 point1 = new Vector2(0.0f, 10.0f); Vector2 d = new Vector2(l*(float) Math.Cos(_angle), -l*Math.Abs((float) 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 Color(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, _point, new Color(0.8f, 0.8f, 0.8f)); Vector2 head = _point + 0.5f*_normal; DebugView.DrawSegment(_point, head, new Color(0.9f, 0.9f, 0.4f)); } else { DebugView.DrawSegment(point1, point2, new Color(0.8f, 0.8f, 0.8f)); } if (advanceRay) { _angle += 0.25f*Settings.Pi/180.0f; } }
public override void Update(GameSettings settings, GameTime gameTime) { //GEN GameInstance.ViewCenter = Vector2.Zero; base.Update(settings, gameTime); }
public virtual void Update(GameSettings settings, GameTime gameTime) { float timeStep = Math.Min((float)gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f, (1f / 30f)); if (settings.Pause) { if (settings.SingleStep) settings.SingleStep = false; else timeStep = 0.0f; DebugView.DrawString(50, TextLine, "****PAUSED****"); TextLine += 15; } World.Step(timeStep); if (timeStep > 0.0f) ++StepCount; }
public override void Update(GameSettings settings, GameTime gameTime) { ContactManager cm = World.ContactManager; DynamicTreeBroadPhase dt = (DynamicTreeBroadPhase)cm.BroadPhase; int height = dt.TreeHeight; int leafCount = dt.ProxyCount; float minimumNodeCount = 2 * leafCount - 1; float minimumHeight = (float)Math.Ceiling(Math.Log(minimumNodeCount) / Math.Log(2.0f)); DebugView.DrawString(5, TextLine, "dynamic tree height = {0}, min = {1}", height, (int)minimumHeight); TextLine += 15; DebugView.DrawString(5, TextLine, "create time = {0} ms, fixture count = {1}", _createTime, _fixtureCount); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); Sweep sweepA = new Sweep(); sweepA.C0 = new Vector2(24.0f, -60.0f); sweepA.A0 = 2.95f; sweepA.C = sweepA.C0; sweepA.A = sweepA.A0; sweepA.LocalCenter = Vector2.Zero; Sweep sweepB = new Sweep(); sweepB.C0 = new Vector2(53.474274f, -50.252514f); sweepB.A0 = 513.36676f; // - 162.0f * b2_pi; sweepB.C = new Vector2(54.595478f, -51.083473f); sweepB.A = 513.62781f; // - 162.0f * b2_pi; sweepB.LocalCenter = Vector2.Zero; //sweepB.a0 -= 300.0f * b2_pi; //sweepB.a -= 300.0f * b2_pi; TOIInput input = new TOIInput(); input.ProxyA.Set(_shapeA, 0); input.ProxyB.Set(_shapeB, 0); input.SweepA = sweepA; input.SweepB = sweepB; input.TMax = 1.0f; TOIOutput output; TimeOfImpact.CalculateTimeOfImpact(out output, input); DebugView.DrawString(50, TextLine, "TOI = {0:n}", output.T); TextLine += 15; DebugView.DrawString(50, TextLine, "Max TOI iters = {0:n}, Max root iters = {1:n}", TimeOfImpact.TOIMaxIters, TimeOfImpact.TOIMaxRootIters); TextLine += 15; CCVector2[] vertices = new CCVector2[Settings.MaxPolygonVertices]; DebugView.BeginCustomDraw(); Transform transformA; sweepA.GetTransform(out transformA, 0.0f); for (int i = 0; i < _shapeA.Vertices.Count; ++i) { vertices[i] = (CCVector2)MathUtils.Multiply(ref transformA, _shapeA.Vertices[i]); } DebugView.DrawPolygon(vertices, _shapeA.Vertices.Count, new Color(0.9f, 0.9f, 0.9f)); Transform transformB; sweepB.GetTransform(out transformB, 0.0f); for (int i = 0; i < _shapeB.Vertices.Count; ++i) { vertices[i] = (CCVector2)MathUtils.Multiply(ref transformB, _shapeB.Vertices[i]); } DebugView.DrawPolygon(vertices, _shapeB.Vertices.Count, new Color(0.5f, 0.9f, 0.5f)); sweepB.GetTransform(out transformB, output.T); for (int i = 0; i < _shapeB.Vertices.Count; ++i) { vertices[i] = (CCVector2)MathUtils.Multiply(ref transformB, _shapeB.Vertices[i]); } DebugView.DrawPolygon(vertices, _shapeB.Vertices.Count, new Color(0.5f, 0.7f, 0.9f)); sweepB.GetTransform(out transformB, 1.0f); for (int i = 0; i < _shapeB.Vertices.Count; ++i) { vertices[i] = (CCVector2)MathUtils.Multiply(ref transformB, _shapeB.Vertices[i]); } DebugView.DrawPolygon(vertices, _shapeB.Vertices.Count, new Color(0.9f, 0.5f, 0.5f)); DebugView.EndCustomDraw(); }