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 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); } }
private void DrawAABB(SpriteBatch spriteBatch) { //draw aabb for (int i = 0; i < _physicsSimulator.GeomList.Count; i++) { Vector2 min = _physicsSimulator.GeomList[i].AABB.Min; Vector2 max = _physicsSimulator.GeomList[i].AABB.Max; Vector2 topRight = new Vector2(max.X, min.Y); Vector2 bottomLeft = new Vector2(min.X, max.Y); _aabbLineBrush.Draw(spriteBatch, min, topRight); _aabbLineBrush.Draw(spriteBatch, topRight, max); _aabbLineBrush.Draw(spriteBatch, max, bottomLeft); _aabbLineBrush.Draw(spriteBatch, bottomLeft, min); } }
public override void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); _border.Draw(ScreenManager.SpriteBatch); _agent.Draw(ScreenManager.SpriteBatch); _redCircles1.Draw(ScreenManager.SpriteBatch); _redCircles2.Draw(ScreenManager.SpriteBatch); _redCircles3.Draw(ScreenManager.SpriteBatch); _greenCircles1.Draw(ScreenManager.SpriteBatch); _greenCircles2.Draw(ScreenManager.SpriteBatch); _greenCircles3.Draw(ScreenManager.SpriteBatch); _blueCircles1.Draw(ScreenManager.SpriteBatch); _blueCircles2.Draw(ScreenManager.SpriteBatch); _blueCircles3.Draw(ScreenManager.SpriteBatch); _blackCircles1.Draw(ScreenManager.SpriteBatch); _blackCircles2.Draw(ScreenManager.SpriteBatch); _blackCircles3.Draw(ScreenManager.SpriteBatch); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); _agent.Draw(ScreenManager.SpriteBatch); _springRectangleRope1.Draw(ScreenManager.SpriteBatch); _springRectangleRope2.Draw(ScreenManager.SpriteBatch); _platform1.Draw(ScreenManager.SpriteBatch); _platform2.Draw(ScreenManager.SpriteBatch); _platform3.Draw(ScreenManager.SpriteBatch); _floor.Draw(ScreenManager.SpriteBatch); _angularSpringLever1.Draw(ScreenManager.SpriteBatch); _angularSpringLever2.Draw(ScreenManager.SpriteBatch); _angularSpringLever3.Draw(ScreenManager.SpriteBatch); _angularSpringLever4.Draw(ScreenManager.SpriteBatch); ScreenManager.SpriteBatch.Draw(_hangingTexture, _hangingGeom.Position, null, Color.White, _hangingGeom.Rotation, new Vector2(_hangingTexture.Width / 2f, _hangingTexture.Height / 2f), 1, SpriteEffects.None, 0); _border.Draw(ScreenManager.SpriteBatch); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
private void DrawCoordinateAxis(SpriteBatch spriteBatch) { for (int i = 0; i < _physicsSimulator.BodyList.Count; i++) { Vector2 startX = _physicsSimulator.BodyList[i].GetWorldPosition(new Vector2(-_coordinateAxisLineLength / 2f, 0)); Vector2 endX = _physicsSimulator.BodyList[i].GetWorldPosition(new Vector2(_coordinateAxisLineLength / 2f, 0)); Vector2 startY = _physicsSimulator.BodyList[i].GetWorldPosition(new Vector2(0, -_coordinateAxisLineLength / 2f)); Vector2 endY = _physicsSimulator.BodyList[i].GetWorldPosition(new Vector2(0, _coordinateAxisLineLength / 2f)); _coordinateAxisLineBrush.Draw(spriteBatch, startX, endX); _coordinateAxisLineBrush.Draw(spriteBatch, startY, endY); } }
private void DrawRevoluteJoints(SpriteBatch spriteBatch) { for (int i = 0; i < _physicsSimulator.JointList.Count; i++) { if (_physicsSimulator.JointList[i] is FixedRevoluteJoint) { FixedRevoluteJoint fixedRevoluteJoint = (FixedRevoluteJoint)_physicsSimulator.JointList[i]; _revoluteJointRectangleBrush.Draw(spriteBatch, fixedRevoluteJoint.Anchor); } if (_physicsSimulator.JointList[i] is RevoluteJoint) { RevoluteJoint revoluteJoint = (RevoluteJoint)_physicsSimulator.JointList[i]; _revoluteJointRectangleBrush.Draw(spriteBatch, revoluteJoint.CurrentAnchor); _revoluteJointLineBrush.Draw(spriteBatch, revoluteJoint.CurrentAnchor, revoluteJoint.Body1.Position); _revoluteJointLineBrush.Draw(spriteBatch, revoluteJoint.CurrentAnchor, revoluteJoint.Body2.Position); } } }
private void DrawSliderJoints(SpriteBatch spriteBatch) { for (int i = 0; i < _physicsSimulator.JointList.Count; i++) { if (_physicsSimulator.JointList[i] is SliderJoint) { SliderJoint sliderJoint = (SliderJoint)_physicsSimulator.JointList[i]; _sliderJointRectangleBrush.Draw(spriteBatch, sliderJoint.WorldAnchor1); _sliderJointRectangleBrush.Draw(spriteBatch, sliderJoint.WorldAnchor2); _sliderJointLineBrush.Draw(spriteBatch, sliderJoint.WorldAnchor1, sliderJoint.WorldAnchor2); } } }
private void DrawPinJoints(SpriteBatch spriteBatch) { for (int i = 0; i < _physicsSimulator.JointList.Count; i++) { if (_physicsSimulator.JointList[i] is PinJoint) { PinJoint pinJoint = (PinJoint)_physicsSimulator.JointList[i]; _pinJointRectangleBrush.Draw(spriteBatch, pinJoint.WorldAnchor1); _pinJointRectangleBrush.Draw(spriteBatch, pinJoint.WorldAnchor2); _pinJointLineBrush.Draw(spriteBatch, pinJoint.WorldAnchor1, pinJoint.WorldAnchor2); } } }
public override void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); ScreenManager.SpriteBatch.Draw(_circleTexture, _circleGeom.Position, null, Color.White, _circleGeom.Rotation, _circleOrigin, 1, SpriteEffects.None, 0); ScreenManager.SpriteBatch.Draw(_rectangleTexture, _rectangleGeom.Position, null, Color.White, _rectangleGeom.Rotation, _rectangleOrigin, 1, SpriteEffects.None, 0); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
public override void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); ScreenManager.SpriteBatch.Draw(_floorTexture, _floorBody.Position, null, Color.White, _floorBody.Rotation, _floorOrigin, 1, SpriteEffects.None, 0f); DrawObstacles(); DrawAgent(); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } ScreenManager.SpriteBatch.End(); base.Draw(gameTime); }
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); }
/// <summary> /// This is called when the screen should draw itself. /// </summary> public virtual void Draw(GameTime gameTime) { ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend); if (_mousePickSpring != null) { _lineBrush.Draw(ScreenManager.SpriteBatch, _mousePickSpring.Body.GetWorldPosition(_mousePickSpring.BodyAttachPoint), _mousePickSpring.WorldAttachPoint); } if (_debugViewEnabled) { _physicsSimulatorView.Draw(ScreenManager.SpriteBatch); } _border.Draw(ScreenManager.SpriteBatch); ScreenManager.SpriteBatch.End(); }
static void DrawPrimitives(IEnumerable <Drawable> primitives, Cairo.Context grw) { foreach (var p in primitives) { var l = p as LineElement; if (l != null) { LineBrush.Draw(grw, l); } var a = p as ArcElement; if (a != null) { ArcBrush.Draw(grw, a); } var a3 = p as Arc3PointsElement; if (a3 != null) { Arc3PointsBrush.Draw(grw, a3); } var t = p as TextElement; if (t != null) { TextBrush.Draw(grw, t); } var r = p as RectangleElement; if (r != null) { RectangleBrush.Draw(grw, r); } } }
private void drawGraph(SpriteBatch spriteBatch) { spriteBatch.Draw(ScreenManager.BlankTexture, new Rectangle(0, 0, XnaDartsGame.Viewport.Width, XnaDartsGame.Viewport.Height), Color.Black); var padding = 60; var graphWidth = (int)(XnaDartsGame.Viewport.Width * 0.8f) - padding * 2; var graphHeight = (int)(XnaDartsGame.Viewport.Height * 0.6f) - padding * 2; var graphX = (int)(XnaDartsGame.Viewport.Width * 0.1f) + padding; var graphY = (int)(XnaDartsGame.Viewport.Width * 0.1f) + padding; var spacing = graphWidth / Math.Max((_recordManager.Records.Count - 1), 1); var minValue = _recordManager.Records.Min(x => x.Score); var maxValue = _recordManager.Records.Max(x => x.Score); var dv = maxValue - minValue; if (dv == 0) { dv = 1; } var lastX = graphX; var lastY = graphY + graphHeight; spriteBatch.Draw(ScreenManager.BlankTexture, new Rectangle(graphX - padding, graphY - padding, graphWidth + padding * 2, graphHeight + padding * 2), Color.White); _lineBrush.Color = Color.Black; _lineBrush.Draw(spriteBatch, new Vector2(graphX, graphY), new Vector2(graphX + graphWidth, graphY)); _lineBrush.Draw(spriteBatch, new Vector2(graphX + graphWidth, graphY), new Vector2(graphX + graphWidth, graphY + graphHeight)); _lineBrush.Draw(spriteBatch, new Vector2(graphX + graphWidth, graphY + graphHeight), new Vector2(graphX, graphY + graphHeight)); _lineBrush.Draw(spriteBatch, new Vector2(graphX, graphY + graphHeight), new Vector2(graphX, graphY)); _lineBrush.Color = new Color(69, 142, 229); for (var i = 0; i < _recordManager.Records.Count; i++) { var x = graphX + spacing * i; var y = graphY + graphHeight - graphHeight * (_recordManager.Records[i].Score - minValue) / dv; if (i > 0) { _lineBrush.Draw(spriteBatch, new Vector2(lastX, lastY), new Vector2(x, y)); } spriteBatch.DrawString(ScreenManager.Arial12, _recordManager.Records[i].Score.ToString(), new Vector2(x, y), Color.Black); var textSize = ScreenManager.Arial12.MeasureString(_recordManager.Records[i].Date.ToShortDateString()); var offset = textSize * 0.5f; offset.X = (int)offset.X; offset.Y = (int)offset.Y; var temp = textSize.X / spacing; var n = (int)Math.Round(temp); if (Math.Round(temp) < temp) { n += 1; } if (n == 0) { n = 1; } if (i % n == 0) { spriteBatch.DrawString(ScreenManager.Arial12, _recordManager.Records[i].Date.ToShortDateString(), new Vector2(x, graphY + graphHeight + padding / 2) - offset, Color.Black); } lastX = x; lastY = y; } }
public void Draw(SpriteBatch sb, LineBrush lb, Color color) { lb.Draw(sb, StartPos, EndPos, color); }
public void Draw(SpriteBatch sb, LineBrush lb, Vector2 offset, Color color) { lb.Draw(sb, StartPos + offset, EndPos + offset, color); }
public void DrawSkeleton(SpriteBatch spriteBatch, LineBrush lb, Vector2 position, Vector2 size, Color color, int skeletonId = 0) { if (Skeletons.Length <= skeletonId || Skeletons[skeletonId] == null) { //Skeleton not found. Draw an X lb.Draw(spriteBatch, position, position + size, color); lb.Draw(spriteBatch, new LineSegment(position.X + size.X, position.Y, position.X, position.Y + size.Y), color); return; } //Right Hand lb.Draw(spriteBatch, ToVector2(JointType.HandRight, size, skeletonId), ToVector2(JointType.WristRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.WristRight, size, skeletonId), ToVector2(JointType.ElbowRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ElbowRight, size, skeletonId), ToVector2(JointType.ShoulderRight, size, skeletonId), color, position); //Head & Shoulders lb.Draw(spriteBatch, ToVector2(JointType.ShoulderRight, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Head, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ShoulderCenter, size, skeletonId), ToVector2(JointType.ShoulderLeft, size, skeletonId), color, position); //Left Hand lb.Draw(spriteBatch, ToVector2(JointType.HandLeft, size, skeletonId), ToVector2(JointType.WristLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.WristLeft, size, skeletonId), ToVector2(JointType.ElbowLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.ElbowLeft, size, skeletonId), ToVector2(JointType.ShoulderLeft, size, skeletonId), color, position); //Hips & Spine lb.Draw(spriteBatch, ToVector2(JointType.HipLeft, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.HipRight, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Spine, size, skeletonId), ToVector2(JointType.HipCenter, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.Spine, size, skeletonId), ToVector2(JointType.ShoulderCenter, size, skeletonId), color, position); //Left foot lb.Draw(spriteBatch, ToVector2(JointType.HipLeft, size, skeletonId), ToVector2(JointType.KneeLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.KneeLeft, size, skeletonId), ToVector2(JointType.AnkleLeft, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.AnkleLeft, size, skeletonId), ToVector2(JointType.FootLeft, size, skeletonId), color, position); //Right foot lb.Draw(spriteBatch, ToVector2(JointType.HipRight, size, skeletonId), ToVector2(JointType.KneeRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.KneeRight, size, skeletonId), ToVector2(JointType.AnkleRight, size, skeletonId), color, position); lb.Draw(spriteBatch, ToVector2(JointType.AnkleRight, size, skeletonId), ToVector2(JointType.FootRight, size, skeletonId), color, position); }