Esempio n. 1
0
        private void RenderVehicle(MovingEntity objVehicle, Graphics objGraphics, Pen objPen)
        {
            PointF pntLeft,pntFront,pntRight;

            if (UseSmoothing)
            {
                Vector2D SmoothedPerp = objVehicle.SmoothedHeading().Perp();

                pntLeft = (PointF)(objVehicle.Pos + (SmoothedPerp * objVehicle.BRadius));
                pntFront = (PointF)(objVehicle.Pos + (objVehicle.SmoothedHeading() * (objVehicle.BRadius * 2)));
                pntRight = (PointF)(objVehicle.Pos - (SmoothedPerp * objVehicle.BRadius));
            }
            else
            {
                 pntLeft = (PointF)(objVehicle.Pos + (objVehicle.Side() * objVehicle.BRadius));
                 pntFront = (PointF)(objVehicle.Pos + (objVehicle.Heading() * (objVehicle.BRadius * 2)));
                 pntRight = (PointF)(objVehicle.Pos - (objVehicle.Side() * objVehicle.BRadius));
            }

            PointF[] points = new PointF[4];

            points[0] = pntLeft;
            points[1] = pntFront;
            points[2] = pntRight;
            points[3] = pntLeft;

            objGraphics.DrawPolygon(objPen, points);
        }
Esempio n. 2
0
        private void renderDetectionBox(MovingEntity objVehicle, Graphics objGraphics, Pen objPen)
        {
            List<Vector2D> points = new List<Vector2D>();

            points.Add(new Vector2D(0, objVehicle.BRadius));
            points.Add(new Vector2D(objVehicle.Steering().DBoxLength(), objVehicle.BRadius));
            points.Add(new Vector2D(objVehicle.Steering().DBoxLength(), -objVehicle.BRadius));
            points.Add(new Vector2D(0, -objVehicle.BRadius));

            if (UseSmoothing)
            {
                points = Utils.WorldTransform(points, objVehicle.Pos, objVehicle.SmoothedHeading(), objVehicle.SmoothedHeading().Perp());
            }
            else
            {
                points = Utils.WorldTransform(points, objVehicle.Pos, objVehicle.Heading(), objVehicle.Side());                
            }

            objGraphics.DrawLine(objPen, (PointF)points[0], (PointF)points[1]);
            objGraphics.DrawLine(objPen, (PointF)points[1], (PointF)points[2]);
            objGraphics.DrawLine(objPen, (PointF)points[2], (PointF)points[3]);
        }