Ejemplo n.º 1
0
        public void DrawMe(Graphics g)
        {
            PointF     boundingBoxTopLeft = new PointF((float)_parentPositionDB.AbsolutePosition.X * _camera.ZoomLevel, (float)_parentPositionDB.AbsolutePosition.Y * _camera.ZoomLevel);
            PointF     bodyPos            = new PointF((float)_bodyPositionDB.AbsolutePosition.X * _camera.ZoomLevel, (float)_bodyPositionDB.AbsolutePosition.Y * _camera.ZoomLevel);
            SizeF      elipseSize         = new SizeF(_orbitElipseWidth * _camera.ZoomLevel, _orbitElipseHeight * _camera.ZoomLevel);
            RectangleF elipseBoundingBox  = new RectangleF(boundingBoxTopLeft, elipseSize);

            g.SaveTransform();
            var rmatrix = Matrix.Create();
            //the distance between the center of the bounding rectangle, and one of the elipse's focal points
            float focalpoint = (float)_focalDistance * _camera.ZoomLevel;
            float halfWid    = _orbitElipseWidth * 0.5f * _camera.ZoomLevel;
            float halfHei    = _orbitElipseHeight * 0.5f * _camera.ZoomLevel;

            PointF focalOffset = new PointF(-halfWid - focalpoint, -halfHei);

            //get the offset from the camera, accounting for zoom, pan etc.
            IMatrix cameraOffset = _camera.GetViewProjectionMatrix(new PointF(0, 0));

            //apply the camera offset
            g.MultiplyTransform(cameraOffset);

            //debug line, draws from the parent body to the body.
            //if (myEntity.GetDataBlob<NameDB>().DefaultName == "Luna" || myEntity.GetDataBlob<NameDB>().DefaultName == "Earth")
            //    g.DrawLine(Colors.DeepPink, boundingBoxTopLeft, bodyPos);

            float startArcAngle = GetStartArcAngle();

            g.TranslateTransform(focalOffset);


            // this point is from the frame of reference of the elipse.
            PointF rotatePoint = new PointF(halfWid + focalpoint, halfHei) + boundingBoxTopLeft;

            rmatrix.RotateAt(_orbitAngle, rotatePoint);
            g.MultiplyTransform(rmatrix);

            //if (myEntity.GetDataBlob<NameDB>().DefaultName == "Mercury")
            //    g.DrawLine(Colors.DeepPink, (boundingBoxTopLeft + elipseSize) / 2, focalOffset - bodyPos );


            //debug rectangle, draws the bounding box for the rotated elipse
            //if (myEntity.GetDataBlob<NameDB>().DefaultName == "Mercury" || myEntity.GetDataBlob<NameDB>().DefaultName == "Earth")
            //    g.DrawRectangle(Colors.BlueViolet, elipseBoundingBox);



            //draw the elipse (as a number of arcs each with a different pen, this gives the fading alpha channel effect)
            int i = 0;

            foreach (var pen in _segmentPens)
            {
                g.DrawArc(pen, elipseBoundingBox, startArcAngle - (i * SweepAngle), -SweepAngle);
                i++;
            }
            g.RestoreTransform();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws the Name of the Item
        /// </summary>
        /// <param name="g"></param>
        public void DrawMe(Graphics g)
        {
            g.SaveTransform();
            IMatrix cameraOffset = _camera.GetViewProjectionMatrix(new PointF((float)worldPosition.X, (float)worldPosition.Y));

            g.MultiplyTransform(cameraOffset);
            g.TranslateTransform(ViewOffset);
            g.DrawText(font, color, (float)worldPosition.X, (float)worldPosition.Y, name);

            g.RestoreTransform();
        }