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, float elapsedSeconds) { base.Update(settings, elapsedSeconds); PolyShapesCallback callback = new PolyShapesCallback(); callback.Circle.Radius = 2.0f; callback.Circle.Position = new Vector2(0.0f, 1.1f); callback.Transform = Transform.Identity; callback.DebugDraw = DebugView; AABB aabb; callback.Circle.ComputeAABB(out aabb, ref callback.Transform, 0); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); World.FindFixtures(callback.ReportFixture, ref aabb); Color color = ColorHelper.FromPercentages(0.4f, 0.7f, 0.8f); DebugView.DrawCircle(callback.Circle.Position, callback.Circle.Radius, color); DebugView.EndCustomDraw(); 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(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) { 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) { 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); PolygonShapesCallback callback = new PolygonShapesCallback(); callback._circle.Radius = 2.0f; callback._circle.Position = new Vector2(0.0f, 1.1f); callback._transform.SetIdentity(); callback._debugView = DebugView; callback._projection = GameInstance.Projection; callback._view = GameInstance.View; AABB aabb; callback._circle.ComputeAABB(ref callback._transform, 0, out aabb); World.QueryAABB(callback.ReportFixture, ref aabb); Color color = new Color(0.4f, 0.7f, 0.8f); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawCircle(callback._circle.Position, callback._circle.Radius, color); DebugView.EndCustomDraw(); DrawString($"Press 1-5 to drop stuff, maximum of {PolygonShapesCallback.MaxCount} overlaps detected"); DrawString("Press 'a' to enable/disable some bodies"); DrawString("Press 'd' to destroy a body"); }
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 Mouse(MouseState state, MouseState oldState) { var pos = CCDrawManager.ScreenToWorld(state.X, state.Y); Vector2 position = new Vector2(pos.X, pos.Y); if (state.RightButton == ButtonState.Pressed) { DrawCircleOnMap(position, -1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f); DebugView.EndCustomDraw(); } if (state.LeftButton == ButtonState.Pressed) { DrawCircleOnMap(position, 1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f); DebugView.EndCustomDraw(); } if (state.MiddleButton == ButtonState.Pressed) { Body circle = BodyFactory.CreateCircle(World, 1, 1); circle.BodyType = BodyType.Dynamic; circle.Position = position; } }
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, 1.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(); 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 Mouse(MouseState state, MouseState oldState) { Vector2 position = GameInstance.ConvertScreenToWorld(state.X, state.Y); if (state.RightButton == ButtonState.Pressed) { DrawCircleOnMap(position, -1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f); DebugView.EndCustomDraw(); } else if (state.LeftButton == ButtonState.Pressed) { DrawCircleOnMap(position, 1); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f); DebugView.EndCustomDraw(); } else if (state.MiddleButton == ButtonState.Pressed) { Body circle = World.CreateCircle(1, 1); circle.BodyType = BodyType.Dynamic; circle.Position = position; } }
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 Draw(GameTime gameTime) { DebugView.BeginCustomDraw(Camera.Projection, Camera.View); foreach (Polygon p in _farseerPoly.Values) { DebugView.DrawPolygon(p.Vertices.ToArray(), p.Vertices.Count, Color.Black, p.Closed); } DebugView.EndCustomDraw(); base.Draw(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(); }
public override void Update(GameSettings settings, float elapsedSeconds) { DrawString("SimpleWindForce | Mouse: Direction | Left-Click: Position | W/S: Variation"); DrawString("Wind Strength:" + _simpleWind.Strength); DrawString("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, elapsedSeconds); }
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) { //Draw the details of the QuadTree QuadTreeBroadPhase quadTreeBroadPhase = World.ContactManager.BroadPhase as QuadTreeBroadPhase; if (quadTreeBroadPhase != null) { DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DrawTree(quadTreeBroadPhase.QuadTree); DebugView.EndCustomDraw(); } base.Update(settings, gameTime); }
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) { 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.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawAABB(ref _terrainArea, Color.Red * 0.5f); DebugView.EndCustomDraw(); 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, gameTime); }
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(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(GameSettings settings, GameTime gameTime) { base.Update(settings, gameTime); 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 float decimals float powernumber = (float)((int)(_force * 10)) / 10; DrawString("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(); }
public override void Mouse(MouseManager mouse) { Vector2 position = GameInstance.ConvertScreenToWorld(mouse.NewPosition); if (mouse.IsButtonDown(MouseButton.Left)) { DrawCircleOnMap(position, (sbyte)(_create ? -1 : 1)); _terrain.RegenerateTerrain(); DebugView.BeginCustomDraw(ref GameInstance.Projection, ref GameInstance.View); DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f); DebugView.EndCustomDraw(); } else if (mouse.IsButtonDown(MouseButton.Middle)) { Body circle = BodyFactory.CreateCircle(World, 1, 1); circle.BodyType = BodyType.Dynamic; circle.Position = position; } }
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(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(); }