public override void Update(GameSettings settings, GameTime gameTime) { ContactManager cm = World.ContactManager; DynamicTreeBroadPhase dt = cm.BroadPhase as DynamicTreeBroadPhase; if (dt != null) { int height = dt.ComputeHeight(); int leafCount = dt.ProxyCount; int minimumNodeCount = 2 * leafCount - 1; float minimumHeight = (float)Math.Ceiling(Math.Log(minimumNodeCount) / Math.Log(2.0f)); DebugView.DrawString(50, TextLine, "Test of dynamic tree performance in worse case scenario.", height, minimumHeight); TextLine += 15; DebugView.DrawString(50, TextLine, "I know this is slow. I hope to address this in a future update.", height, minimumHeight); TextLine += 15; DebugView.DrawString(50, TextLine, "Dynamic tree height = {0}, min = {1}", height, minimumHeight); TextLine += 15; } base.Update(settings, gameTime); }
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:n}, Ave GJK iters = {1:n}, Max GJK iters = {2:n}", Distance.GJKCalls, Distance.GJKIters / (float)Distance.GJKCalls, Distance.GJKMaxIters); TextLine += 15; } if (TimeOfImpact.TOICalls > 0) { DebugView.DrawString(50, TextLine, "TOI calls = {0:n}, Ave TOI iters = {1:n}, Max TOI iters = {2:n}", TimeOfImpact.TOICalls, TimeOfImpact.TOIIters / (float)TimeOfImpact.TOICalls, TimeOfImpact.TOIMaxRootIters); TextLine += 15; DebugView.DrawString(50, TextLine, "Ave TOI root iters = {0:n}, Max TOI root iters = {1:n}", 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); 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(); var ts = tempshape.ToList().Cast <CCVector2>(); DebugView.DrawPolygon(ts.ToArray(), _clipCircle.Count, color); DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Keys: left = a, brake = s, right = d, toggle motor = m"); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); PolygonShape shape = new PolygonShape(new Vertices(_points), 0f); DrawString("Press g to generate a new random convex hull"); 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 (_auto) { Generate(); } }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "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; // } //} //TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); PolyShapesCallback callback = new PolyShapesCallback(); callback.Circle.Radius = 2.0f; callback.Circle.Position = new Vector2(0.0f, 2.1f); callback.Transform.SetIdentity(); callback.DebugDraw = DebugView; AABB aabb; callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); World.QueryAABB(callback.ReportFixture, ref aabb); Color color = new Color(0.4f, 0.7f, 0.8f); DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color); DebugView.EndCustomDraw(); DebugView.DrawString(50, TextLine, "Press 1-5 to drop stuff"); TextLine += 15; DebugView.DrawString(50, TextLine, "Press a to (de)activate some bodies"); TextLine += 15; DebugView.DrawString(50, TextLine, "Press d to destroy a body"); TextLine += 15; }
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) { DebugView.DrawString(50, TextLine, "Rotation: " + _circleFixture.Body.Rotation); TextLine += 15; DebugView.DrawString(50, TextLine, "Revolutions: " + _circleFixture.Body.Revolutions); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(50, TextLine, "Note: The left side of the ship has a different density than the right side of the ship"); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawString(30, TextLine, "Press + to increase and - to decrease max length"); DebugView.DrawString(30, TextLine += TextLine, "Max length: " + _joint.MaxLength); DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { DebugView.DrawString(4, 60, "Collision1 fired: " + _collision1Fired); DebugView.DrawString(4, 60 + TextLine, "Collision2 fired:" + _collision2Fired); DebugView.DrawString(4, 60 + TextLine * 2, "Separation1 fired: " + _separation1Fired); DebugView.DrawString(4, 60 + TextLine * 3, "Separation2 fired: " + _separation2Fired); DebugView.DrawString(4, 60 + TextLine * 4, "Contact disabled: " + _contactDisabled); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Keys: (f) toggle friction, (m) toggle motor"); TextLine += 15; float torque = _joint1.MotorTorque; DebugView.DrawString(50, TextLine, "Motor Torque = {0:n}", torque); 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) { 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) { DebugView.DrawString(50, TextLine, "Recursion Level: " + _level); TextLine += 15; DebugView.DrawString(50, TextLine, "Grid Size: " + _gridSize); TextLine += 15; DebugView.DrawString(50, TextLine, "Time: " + _time + " ms"); TextLine += 15; base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "This demonstrates a soft distance joint."); TextLine += 15; DebugView.DrawString(50, TextLine, "Press: (b) to delete a body, (j) to delete a joint"); TextLine += 15; DebugView.DrawString(50, TextLine, "Bodies removed: " + _removedBodies); TextLine += 15; DebugView.DrawString(50, TextLine, "Joints removed: " + _removedJoints); }
public override void Update(GameSettings settings, GameTime gameTime) { //If the message times out, remove it from the list. for (int i = _messages.Count - 1; i >= 0; i--) { _messages[i].ElapsedTime += settings.Hz; if (_messages[i].ElapsedTime > 5) { _messages.Remove(_messages[i]); } } if (_left != null) { Vector2[] array = _left.ToArray(); DebugView.DrawPolygon(ref array, _left.Count, Color.Red); } if (_right != null) { Vector2[] array = _right.ToArray(); DebugView.DrawPolygon(ref array, _right.Count, Color.Red); } DebugView.DrawString(50, TextLine, "A,S,D = Create Rectangle"); TextLine += 15; DebugView.DrawString(50, TextLine, "Q,W,E = Create Circle"); TextLine += 15; DebugView.DrawString(50, TextLine, "Click to Drag polygons"); TextLine += 15; DebugView.DrawString(50, TextLine, "Space = Union"); TextLine += 15; DebugView.DrawString(50, TextLine, "Backspace = Subtract"); TextLine += 15; DebugView.DrawString(50, TextLine, "Space = Union"); TextLine += 15; DebugView.DrawString(50, TextLine, "Enter = Add to Simulation"); TextLine += 15; for (int i = _messages.Count - 1; i >= 0; i--) { DebugView.DrawString(50, TextLine, _messages[i].Text); TextLine += 15; } base.Update(settings, gameTime); }
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) { 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(ref GameInstance.Projection, ref GameInstance.View); { 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.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 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, "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) { 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, "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(ref GameInstance.Projection, ref GameInstance.View); //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) { 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(ref GameInstance.Projection, ref GameInstance.View); 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(ref GameInstance.Projection, ref GameInstance.View); 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) { 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 = GameInstance.ConvertWorldToScreen(_bodies[i].Position + offset); DebugView.DrawString((int)screenPosition.X, (int)screenPosition.Y, title); } 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); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); 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)); } DebugView.EndCustomDraw(); if (advanceRay) { _angle += 0.25f * Settings.Pi / 180.0f; } }
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) { 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) { foreach (Body b in World.BodyList) { if (b.BodyType != BodyType.Dynamic) { continue; } if (b.Awake) { } } if (StepCount == 180) { StepCount += 0; } //if (sleeping) //{ // CreateCircle(); //} base.Update(settings, gameTime); foreach (Body b in World.BodyList) { if (b.BodyType != BodyType.Dynamic) { continue; } Vector2 p = b.Position; if (p.X <= -10.0f || 10.0f <= p.X || p.Y <= 0.0f || 20.0f <= p.Y) { p.X += 0.0f; } } DebugView.DrawString(50, TextLine, "Press 'c' to create a circle."); TextLine += 15; }
public override void Update(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DebugView.DrawString(50, TextLine, "Press: (,) to explode at mouse position."); TextLine += 15; DebugView.DrawString(50, TextLine, "Press: (A) to decrease the explosion radius, (S) to increase it."); TextLine += 15; DebugView.DrawString(50, TextLine, "Press: (D) to decrease the explosion power, (F) to increase it."); TextLine += 15; // Fighting against float decimals float powernumber = (float)((int)(_power * 10)) / 10; DebugView.DrawString(50, TextLine, "Power: " + powernumber); Color color = new Color(0.4f, 0.7f, 0.8f); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawCircle(_mousePos, _radius, color); DebugView.EndCustomDraw(); }