private void DrawSprings(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < _physicsSimulator.SpringList.Count; i++)
            {
                if (!(_physicsSimulator.SpringList[i] is FixedLinearSpring))
                {
                    continue;
                }

                FixedLinearSpring fixedLinearSpring = (FixedLinearSpring)_physicsSimulator.SpringList[i];
                _worldAttachPoint = fixedLinearSpring.WorldAttachPoint;
                _body1AttachPointInWorldCoordinates =
                    fixedLinearSpring.Body.GetWorldPosition(fixedLinearSpring.BodyAttachPoint);
                _springCircleBrush.Draw(spriteBatch, _body1AttachPointInWorldCoordinates);
                _springCircleBrush.Draw(spriteBatch, _worldAttachPoint);

                Vector2.Lerp(ref _worldAttachPoint, ref _body1AttachPointInWorldCoordinates, .25f, out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                Vector2.Lerp(ref _worldAttachPoint, ref _body1AttachPointInWorldCoordinates, .50f, out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                Vector2.Lerp(ref _worldAttachPoint, ref _body1AttachPointInWorldCoordinates, .75f, out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                _springLineBrush.Draw(spriteBatch, _body1AttachPointInWorldCoordinates,
                                      fixedLinearSpring.WorldAttachPoint);
            }

            for (int i = 0; i < _physicsSimulator.SpringList.Count; i++)
            {
                if (!(_physicsSimulator.SpringList[i] is LinearSpring))
                {
                    continue;
                }

                LinearSpring linearSpring = (LinearSpring)_physicsSimulator.SpringList[i];
                _attachPoint1 = linearSpring.AttachPoint1;
                _attachPoint2 = linearSpring.AttachPoint2;
                linearSpring.Body1.GetWorldPosition(ref _attachPoint1, out _body1AttachPointInWorldCoordinates);
                linearSpring.Body2.GetWorldPosition(ref _attachPoint2, out _body2AttachPointInWorldCoordinates);
                _springCircleBrush.Draw(spriteBatch, _body1AttachPointInWorldCoordinates);
                _springCircleBrush.Draw(spriteBatch, _body2AttachPointInWorldCoordinates);

                Vector2.Lerp(ref _body1AttachPointInWorldCoordinates, ref _body2AttachPointInWorldCoordinates, .25f,
                             out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                Vector2.Lerp(ref _body1AttachPointInWorldCoordinates, ref _body2AttachPointInWorldCoordinates, .50f,
                             out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                Vector2.Lerp(ref _body1AttachPointInWorldCoordinates, ref _body2AttachPointInWorldCoordinates, .75f,
                             out _vectorTemp1);
                _springCircleBrush.Draw(spriteBatch, _vectorTemp1);

                _springLineBrush.Draw(spriteBatch, _body1AttachPointInWorldCoordinates,
                                      _body2AttachPointInWorldCoordinates);
            }
        }
示例#2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     for (int i = 0; i < _count; i++)
     {
         _circleBrush.Draw(spriteBatch, _circleGeom[i].Position);
     }
 }
 private void DrawVerticesAndEdges(SpriteBatch spriteBatch)
 {
     //draw vertice texture
     for (int i = 0; i < _physicsSimulator.GeomList.Count; i++)
     {
         int verticeCount = _physicsSimulator.GeomList[i].LocalVertices.Count;
         for (int j = 0; j < verticeCount; j++)
         {
             if (_enableEdgeView)
             {
                 if (j < verticeCount - 1)
                 {
                     _edgeLineBrush.Draw(spriteBatch, _physicsSimulator.GeomList[i].WorldVertices[j],
                                         _physicsSimulator.GeomList[i].WorldVertices[j + 1]);
                 }
                 else
                 {
                     _edgeLineBrush.Draw(spriteBatch, _physicsSimulator.GeomList[i].WorldVertices[j],
                                         _physicsSimulator.GeomList[i].WorldVertices[0]);
                 }
             }
             if (_enableVerticeView)
             {
                 _verticeCircleBrush.Draw(spriteBatch, _physicsSimulator.GeomList[i].WorldVertices[j]);
             }
         }
     }
 }
 private void DrawContacts(SpriteBatch spriteBatch)
 {
     //draw contact textures
     for (int i = 0; i < _physicsSimulator.ArbiterList.Count; i++)
     {
         for (int j = 0; j < _physicsSimulator.ArbiterList[i].ContactList.Count; j++)
         {
             _contactCircleBrush.Draw(spriteBatch, _physicsSimulator.ArbiterList[i].ContactList[j].Position);
         }
     }
 }
示例#5
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            _circleBrush.Draw(ScreenManager.SpriteBatch, _circleBody.Position);
            _rectangleBrush.Draw(ScreenManager.SpriteBatch, _rectangleBody.Position, _rectangleBody.Rotation);

            ScreenManager.SpriteBatch.End();

            base.Draw(gameTime);
        }
示例#6
0
    /// <inheritdoc />
    public override void Draw()
    {
        var size        = Size;
        var enabled     = EnabledInHierarchy;
        var circleColor = _isPressed ? ColorPressed : Color;

        if (!enabled)
        {
            circleColor *= 0.5f;
        }
        var pressedScale = 0.3f;
        var normalSize   = 0.5f;
        var circleBounds = _isPressed ? new Rectangle(Vector2.Clamp(_inputLocation, size * (pressedScale / 2), size * (1 - pressedScale / 2)) - size * (pressedScale / 2), size * pressedScale) : new Rectangle(size * (0.5f - normalSize * 0.5f), size * normalSize);

        CircleBrush?.Draw(circleBounds, circleColor);
    }
 private void DrawGrid(SpriteBatch spriteBatch)
 {
     //draw grid
     for (int i = 0; i < _physicsSimulator.GeomList.Count; i++)
     {
         if (_physicsSimulator.GeomList[i].Grid == null)
         {
             continue;
         }
         int count = _physicsSimulator.GeomList[i].Grid.Points.Length;
         for (int j = 0; j < count; j++)
         {
             Vector2 point =
                 _physicsSimulator.GeomList[i].GetWorldPosition(_physicsSimulator.GeomList[i].Grid.Points[j]);
             _gridCircleBrush.Draw(spriteBatch, point);
         }
     }
 }
示例#8
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);

            _circleBrush.Draw(ScreenManager.SpriteBatch, _circleBody.Position);
            _rectangleBrush.Draw(ScreenManager.SpriteBatch, _rectangleBody.Position, _rectangleBody.Rotation);
            _lineBrush.Draw(ScreenManager.SpriteBatch, _p1, _p2);

            foreach (Vector2 point in _intersectingPoints)
            {
                _marker.Draw(ScreenManager.SpriteBatch, point);
            }

            ScreenManager.SpriteBatch.DrawString(ScreenManager.SpriteFonts.DetailsFont, string.Format("Colliding with {0} geometries", _intersectingGeoms.Count), new Vector2(50, ScreenManager.ScreenHeight - 70), Color.White);

            ScreenManager.SpriteBatch.End();

            base.Draw(gameTime);
        }