public void Draw(SpriteBatch sb, SpriteFont font) { var projection = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Height), 0f, 0f, 1f); _debugView.RenderDebugData(projection, camera.getScaledViewMatrix()); var projection2 = Matrix.CreateOrthographicOffCenter(0f, sb.GraphicsDevice.Viewport.Width, sb.GraphicsDevice.Viewport.Height, 0f, 0f, 1f); _debugView.BeginCustomDraw(projection2, camera.getViewMatrix()); foreach (var ray in player.controller.castList) { _debugView.DrawSegment(ray.from, ray.to, Color.Blue); } foreach (var p in platformList) { foreach (var ray in p.controller.castList) { _debugView.DrawSegment(ray.from, ray.to, Color.White); } } var areaPoints = new Vector2[] { ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.top)), ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.top)), ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.bottom)), ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.bottom)) }; _debugView.DrawSolidPolygon(areaPoints, 4, Color.Red); _debugView.DrawPoint(ConvertUnits.ToDisplayUnits(camera.focusPosition), 3, Color.White); _debugView.DrawPoint(camera.Position, 3, Color.Pink); var cameraBounds = new Vector2[] { new Vector2(camera.Bounds.Left, camera.Bounds.Top), new Vector2(camera.Bounds.Right, camera.Bounds.Top), new Vector2(camera.Bounds.Right, camera.Bounds.Bottom), new Vector2(camera.Bounds.Left, camera.Bounds.Bottom) }; _debugView.DrawPolygon(cameraBounds, 4, Color.Green); _debugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { Manifold manifold = new Manifold(); CollidePolygon.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB); WorldManifold.Initialize(ref manifold, ref _transformA, _polygonA.Radius, ref _transformB, _polygonB.Radius, out _, out FixedArray2 <Vector2> points, out _); DrawString("Point count = " + manifold.PointCount); 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); } for (int i = 0; i < manifold.PointCount; ++i) { DebugView.DrawPoint(points[i], 0.1f, new Color(0.9f, 0.3f, 0.3f)); DrawString(points[i].ToString()); } DebugView.EndCustomDraw(); }
public override void Update(GameSettings settings, GameTime gameTime) { DrawString("Use the mouse to create a polygon."); DrawString("Simple: " + _vertices.IsSimple()); DrawString("Convex: " + _vertices.IsConvex()); DrawString("CCW: " + _vertices.IsCounterClockWise()); DrawString("Area: " + _vertices.GetArea()); PolygonError returnCode = _vertices.CheckPolygon(); if (returnCode == PolygonError.NoError) DrawString("Polygon is supported in Velcro Physics"); else DrawString("Polygon is NOT supported in Velcro Physics. Reason: " + returnCode); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); for (int i = 0; i < _vertices.Count; i++) { Vector2 currentVertex = _vertices[i]; Vector2 nextVertex = _vertices.NextVertex(i); DebugView.DrawPoint(currentVertex, 0.1f, Color.Yellow); DebugView.DrawSegment(currentVertex, nextVertex, Color.Red); } DebugView.DrawPoint(_vertices.GetCentroid(), 0.1f, Color.Green); AABB aabb = _vertices.GetAABB(); DebugView.DrawAABB(ref aabb, Color.HotPink); DebugView.EndCustomDraw(); 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) { if (_go && settings.Hz > 0.0f) { _time += 1.0f / settings.Hz; } Vector2 linearOffset = new Vector2(); linearOffset.X = 6.0f * MathUtils.Sinf(2.0f * _time); linearOffset.Y = 8.0f + 4.0f * MathUtils.Sinf(1.0f * _time); float angularOffset = 4.0f * _time; _joint.LinearOffset = linearOffset; _joint.AngularOffset = angularOffset; DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawPoint(linearOffset, 4.0f, new Color(0.9f, 0.9f, 0.9f)); DebugView.EndCustomDraw(); DrawString("Keys: (s) pause"); base.Update(settings, gameTime); }
public override void Update(GameSettings settings, GameTime gameTime) { 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.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawPolygon(array, vertex.Count, col); for (int j = 0; j < vertex.Count; ++j) { DebugView.DrawPoint(vertex[j], .2f, Color.Red); } DebugView.EndCustomDraw(); } } 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(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); DistanceInput input = new DistanceInput(); input.ProxyA = new DistanceProxy(_polygonA, 0); input.ProxyB = new DistanceProxy(_polygonB, 0); input.TransformA = _transformA; input.TransformB = _transformB; input.UseRadii = true; SimplexCache cache = new SimplexCache(); cache.Count = 0; DistanceOutput output; DistanceGJK.ComputeDistance(ref input, out output, out cache); DrawString($"distance = {output.Distance}"); DrawString($"iterations = {output.Iterations}"); 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; Color c1 = new Color(1.0f, 0.0f, 0.0f); DebugView.DrawPoint(x1, 4.0f, c1); Color c2 = new Color(1.0f, 1.0f, 0.0f); DebugView.DrawPoint(x2, 4.0f, c2); DebugView.EndCustomDraw(); }
private void DrawVertices(Vertices vertices) { if (vertices.Count >= 1) { DebugView.DrawPolygon(vertices.ToArray(), vertices.Count, Color.Red); foreach (Vector2 vector2 in vertices) { DebugView.DrawPoint(vector2, 0.1f, Color.Yellow); } } }
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 void RenderDebug(DebugView debugView, Matrix view, Matrix projection) { foreach (Car car in cars) { foreach (CastedRay ray in car.Rays) { debugView.BeginCustomDraw(projection, view); if (ray.Hit) { debugView.DrawPoint(ray.P1, .25f, new Color(0.9f, 0.4f, 0.4f)); debugView.DrawSegment(ray.P2, ray.P1, new Color(0.8f, 0.4f, 0.4f)); } else { debugView.DrawPoint(ray.P1, .25f, new Color(0.4f, 0.9f, 0.4f)); debugView.DrawSegment(ray.P2, ray.P1, new Color(0.8f, 0.8f, 0.8f)); } debugView.EndCustomDraw(); } car.Rays.Clear(); } }
public override void Update(GameSettings settings, GameTime gameTime) { DrawString("Press A,S,W,D move endpoint"); DrawString("Press Enter to cut"); DrawString("Press TAB to change endpoint"); 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); DrawString("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, float elapsedSeconds) { base.Update(settings, elapsedSeconds); DistanceInput input; input.ProxyA = new DistanceProxy(_polygonA, 0); input.ProxyB = new DistanceProxy(_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); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); { Color color = ColorHelper.FromPercentages(0.9f, 0.9f, 0.9f); Vector2[] v = new Vector2[Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.Vertices.Count; ++i) { v[i] = Transform.Multiply(_polygonA.Vertices[i], ref _transformA); } DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color); for (int i = 0; i < _polygonB.Vertices.Count; ++i) { v[i] = Transform.Multiply(_polygonB.Vertices[i], ref _transformB); } DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color); } Vector2 x1 = output.PointA; Vector2 x2 = output.PointB; DebugView.DrawPoint(x1, 0.5f, ColorHelper.FromPercentages(1.0f, 0.0f, 0.0f)); DebugView.DrawPoint(x2, 0.5f, ColorHelper.FromPercentages(1.0f, 0.0f, 0.0f)); DebugView.DrawSegment(x1, x2, ColorHelper.FromPercentages(1.0f, 1.0f, 0.0f)); DebugView.EndCustomDraw(); }
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) { 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(GameSettings settings, GameTime gameTime) { bool advanceRay = settings.Pause == false || settings.SingleStep; base.Update(settings, gameTime); DrawString("Press 1-5 to drop stuff"); 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 * MathHelper.Pi / 180.0f; } }
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(FarseerPhysicsGameSettings settings) { DrawString("Melkman: Red"); DrawString("Giftwrap: Green"); DrawString("ChainHull: Blue"); for (int i = 0; i < PointCount; 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); base.Update(settings); }
public override void Update(GameSettings settings, GameTime gameTime) { DrawString("Melkman: Red"); DrawString("Giftwrap: Green"); DrawString("ChainHull: Blue"); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); for (int i = 0; i < PointCount; 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(FarseerPhysicsGameSettings settings) { DrawString("Use the mouse to create a polygon."); DrawString("Simple: " + _vertices.IsSimple()); DrawString("Convex: " + _vertices.IsConvex()); DrawString("CCW: " + _vertices.IsCounterClockWise()); DrawString("Area: " + _vertices.GetArea()); PolygonError returnCode = _vertices.CheckPolygon(); if (returnCode == PolygonError.NoError) { DrawString("Polygon is supported in Farseer Physics Engine"); } else { DrawString("Polygon is NOT supported in Farseer Physics Engine. Reason: " + returnCode); } for (int i = 0; i < _vertices.Count; i++) { Vector2 currentVertex = _vertices[i]; Vector2 nextVertex = _vertices.NextVertex(i); DebugView.DrawPoint(currentVertex, 0.1f, Color.Yellow); DebugView.DrawSegment(currentVertex, nextVertex, Color.Red); } DebugView.DrawPoint(_vertices.GetCentroid(), 0.1f, Color.Green); AABB aabb = _vertices.GetAABB(); DebugView.DrawAABB(ref aabb, Color.HotPink); base.Update(settings); }
public override void Update(GameSettings settings, GameTime gameTime) { bool advanceRay = !settings.Pause || settings.SingleStep; base.Update(settings, gameTime); DrawString("Press 1-5 to drop stuff"); float L = 25.0f; Vector2 point1 = new Vector2(0.0f, 10.0f); Vector2 d = new Vector2(L * MathUtils.Cosf(_angle), -L * MathUtils.Abs(MathUtils.Sinf(_angle))); Vector2 point2 = point1 + d; EdgeShapesCallback callback = new EdgeShapesCallback(); World.RayCast(callback.ReportFixture, point1, point2); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); if (callback._fixture != null) { DebugView.DrawPoint(callback._point, 5f, new Color(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, callback._point, new Color(0.8f, 0.8f, 0.8f)); Vector2 head = callback._point + 0.5f * callback._normal; DebugView.DrawSegment(callback._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 * MathConstants.Pi / 180.0f; } }
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, float elapsedSeconds) { Manifold manifold = new Manifold(); Collision.Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB); Vector2 normal; FixedArray2 <Vector2> points; ContactSolver.WorldManifold.Initialize(ref manifold, ref _transformA, _polygonA.Radius, ref _transformB, _polygonB.Radius, out normal, out points); DrawString("Point count = " + manifold.PointCount); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); { Color color = ColorHelper.FromPercentages(0.9f, 0.9f, 0.9f); Vector2[] v = new Vector2[Settings.MaxPolygonVertices]; for (int i = 0; i < _polygonA.Vertices.Count; ++i) { v[i] = Transform.Multiply(_polygonA.Vertices[i], ref _transformA); } DebugView.DrawPolygon(v, _polygonA.Vertices.Count, color); for (int i = 0; i < _polygonB.Vertices.Count; ++i) { v[i] = Transform.Multiply(_polygonB.Vertices[i], ref _transformB); } DebugView.DrawPolygon(v, _polygonB.Vertices.Count, color); } for (int i = 0; i < manifold.PointCount; ++i) { DebugView.DrawPoint(points[i], 0.1f, ColorHelper.FromPercentages(0.9f, 0.3f, 0.3f)); DrawString(points[i].ToString()); } DebugView.EndCustomDraw(); }
public override void Update(FarseerPhysicsGameSettings settings) { base.Update(settings); PolygonShape shape = new PolygonShape(new Vertices(_points), 0f); DrawString("Press g to generate a new random convex hull"); DebugView.DrawPolygon(shape.Vertices.ToArray(), shape.Vertices.Count, new ColorR(0.9, 0.9, 0.9)); for (int i = 0; i < _count; ++i) { DebugView.DrawPoint(_points[i], 0.1f, new ColorR(0.9, 0.5, 0.5)); Vector2 position = ConvertWorldToScreen(_points[i]); DebugView.DrawString((int)position.X, (int)position.Y, i.ToString()); } if (_auto) { Generate(); } }
public override void Update(FarseerPhysicsGameSettings settings) { Manifold manifold = new Manifold(); Alt.FarseerPhysics.Collision.Collision.CollidePolygons(ref manifold, _polygonA, ref _transformA, _polygonB, ref _transformB); Vector2 normal; FixedArray2 <Vector2> points; ContactSolver.WorldManifold.Initialize(ref manifold, ref _transformA, _polygonA.Radius, ref _transformB, _polygonB.Radius, out normal, out points); DrawString("Point count = " + manifold.PointCount); { Color color = new ColorR(0.9, 0.9, 0.9); 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); } for (int i = 0; i < manifold.PointCount; ++i) { DebugView.DrawPoint(points[i], 0.1f, new ColorR(0.9f, 0.3f, 0.3f)); DrawString(points[i].ToString()); } }
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); } 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) { _rayActor = null; for (int i = 0; i < ActorCount; ++i) { _actors[i].Fraction = 1.0f; _actors[i].Overlap = false; } if (_automated) { int actionCount = Math.Max(1, ActorCount >> 2); for (int i = 0; i < actionCount; ++i) { Action(); } } Query(); RayCast(); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); for (int i = 0; i < ActorCount; ++i) { Actor actor = _actors[i]; if (actor.ProxyId == -1) { continue; } Color ca = new Color(0.9f, 0.9f, 0.9f); if (actor == _rayActor && actor.Overlap) { ca = new Color(0.9f, 0.6f, 0.6f); } else if (actor == _rayActor) { ca = new Color(0.6f, 0.9f, 0.6f); } else if (actor.Overlap) { ca = new Color(0.6f, 0.6f, 0.9f); } DebugView.DrawAABB(ref actor.AABB, ca); } Color c = new Color(0.7f, 0.7f, 0.7f); DebugView.DrawAABB(ref _queryAABB, c); DebugView.DrawSegment(_rayCastInput.Point1, _rayCastInput.Point2, c); Color c1 = new Color(0.2f, 0.9f, 0.2f); Color c2 = new Color(0.9f, 0.2f, 0.2f); DebugView.DrawPoint(_rayCastInput.Point1, 0.1f, c1); DebugView.DrawPoint(_rayCastInput.Point2, 0.1f, c2); if (_rayActor != null) { Color cr = new Color(0.2f, 0.2f, 0.9f); Vector2 p = _rayCastInput.Point1 + _rayActor.Fraction * (_rayCastInput.Point2 - _rayCastInput.Point1); DebugView.DrawPoint(p, 0.1f, cr); } DebugView.EndCustomDraw(); int height = _tree.Height; DrawString("Dynamic tree height = " + height); }
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, m to change the mode"); TextLine += 15; DebugView.DrawString(50, TextLine, string.Format("Mode = {0}", _mode)); TextLine += 15; const float l = 11.0f; Vector2 point1 = new Vector2(0.0f, 10.0f); Vector2 d = new Vector2(l * (float)Math.Cos(_angle), l * (float)Math.Sin(_angle)); Vector2 point2 = point1 + d; Vector2 point = Vector2.Zero, normal = Vector2.Zero; switch (_mode) { case RayCastMode.Closest: bool hitClosest = false; World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.UserData != null) { int index = (int)body.UserData; if (index == 0) { // filter return(-1.0f); } } hitClosest = true; point = p; normal = n; return(fr); }, point1, point2); if (hitClosest) { DebugView.BeginCustomDraw(); DebugView.DrawPoint(point, .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)); DebugView.EndCustomDraw(); } else { DebugView.BeginCustomDraw(); DebugView.DrawSegment(point1, point2, new Color(0.8f, 0.8f, 0.8f)); DebugView.EndCustomDraw(); } break; case RayCastMode.Any: bool hitAny = false; World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.UserData != null) { int index = (int)body.UserData; if (index == 0) { // filter return(-1.0f); } } hitAny = true; point = p; normal = n; return(0); }, point1, point2); if (hitAny) { DebugView.BeginCustomDraw(); DebugView.DrawPoint(point, .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)); DebugView.EndCustomDraw(); } else { DebugView.BeginCustomDraw(); DebugView.DrawSegment(point1, point2, new Color(0.8f, 0.8f, 0.8f)); DebugView.EndCustomDraw(); } break; case RayCastMode.Multiple: List <Vector2> points = new List <Vector2>(); List <Vector2> normals = new List <Vector2>(); World.RayCast((f, p, n, fr) => { Body body = f.Body; if (body.UserData != null) { int index = (int)body.UserData; if (index == 0) { // filter return(-1.0f); } } points.Add(p); normals.Add(n); return(1.0f); }, point1, point2); DebugView.BeginCustomDraw(); DebugView.DrawSegment(point1, point2, new Color(0.8f, 0.8f, 0.8f)); for (int i = 0; i < points.Count; i++) { DebugView.DrawPoint(points[i], .5f, new Color(0.4f, 0.9f, 0.4f)); DebugView.DrawSegment(point1, points[i], new Color(0.8f, 0.8f, 0.8f)); Vector2 head = points[i] + 0.5f * normals[i]; DebugView.DrawSegment(points[i], head, new Color(0.9f, 0.9f, 0.4f)); } DebugView.EndCustomDraw(); break; default: break; } if (advanceRay) { _angle += 0.25f * Settings.Pi / 180.0f; } }
public override void Update(GameSettings settings, GameTime gameTime) { for (int i = 0; i < _polygons.Count; ++i) { if (_polygons[i] != null) { CCVector2[] array = new CCVector2[_polygons.Count]; for (int p = 0; p < _polygons[i].Count; p++) { array[p] = (CCVector2)_polygons[i][p]; } 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 void DrawNoneForce() { DebugView.DrawPoint(_simpleWind.Position, 2, Color.Red); }
public void DrawPointForce() { DebugView.DrawPoint(_simpleWind.Position, 2, Color.Red); DebugView.DrawCircle(_simpleWind.Position, _simpleWind.DecayStart, Color.Green); DebugView.DrawCircle(_simpleWind.Position, _simpleWind.DecayEnd, Color.Red); }