Exemplo n.º 1
0
        public override void Draw(IntPtr rendererPtr, Camera camera)
        {
            //now we draw a line between each of the points in the translatedPoints[] array.
            float alpha = MaxAlpha;

            for (int i = 0; i < _numberOfDrawSegments - 1; i++)
            {
                SDL.SDL_SetRenderDrawColor(rendererPtr, Red, Grn, Blu, (byte)alpha);//we cast the alpha here to stop rounding errors creaping up.
                SDL.SDL_RenderDrawLine(rendererPtr, _drawPoints[i].x, _drawPoints[i].y, _drawPoints[i + 1].x, _drawPoints[i + 1].y);
                alpha -= _alphaChangeAmount;
            }

            SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 50, 100, 100);
            //DrawPrimitive.DrawFilledCircle(rendererPtr ,ViewScreenPos.x , ViewScreenPos.y, (int)_soiViewRadius);
            DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _soiViewRadius, _soiViewRadius);

            /*
             * var soipnts = CreatePrimitiveShapes.BresenhamCircle(ViewScreenPos.x, ViewScreenPos.y, (int)_soiViewRadius);
             * for (int i = 0; i < soipnts.Count -1; i+=2)
             * {
             *  SDL.SDL_RenderDrawLine(rendererPtr, soipnts[i].x, soipnts[i].y, soipnts[i + 1].x, soipnts[i + 1].y);
             *  //SDL.SDL_RenderDrawPoint(rendererPtr, soipnts[i].x, soipnts[i].y);
             *  //var err = SDL.SDL_GetError();
             * }
             */

            SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 255);
            DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _targetViewRadius, _targetViewRadius);
            var plntPts = CreatePrimitiveShapes.BresenhamCircle(ViewScreenPos.x, ViewScreenPos.y, (int)_targetViewRadius);

            for (int i = 0; i < plntPts.Count - 1; i++)
            {
                SDL.SDL_RenderDrawLine(rendererPtr, plntPts[i].x, plntPts[i].y, plntPts[i + 1].x, plntPts[i + 1].y);
            }

            /*
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 100, 0, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 63, 63, 0, _loAN); //draw LoAN angle
             *
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 50, 0, 100, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 64, 64, _loAN, _aoP); //draw AoP angle
             *
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 66, 66, OrbitAngleRadians,  _trueAnomaly);
             */
        }
Exemplo n.º 2
0
        public override void Draw(IntPtr rendererPtr, Camera camera)
        {
            //Orbit line
            //now we draw a line between each of the points in the translatedPoints[] array.
            float alpha = MaxAlpha;

            for (int i = 0; i < _numberOfDrawSegments - 1; i++)
            {
                var au = 1;//GameConstants.Units.MetersPerAu;
                int x1 = (int)(_drawPoints[i].x * au);
                int y1 = (int)(_drawPoints[i].y * au);
                int x2 = (int)(_drawPoints[i + 1].x * au);
                int y2 = (int)(_drawPoints[i + 1].y * au);

                //SDL.SDL_RenderDrawLine(rendererPtr, x1, y1, x2, y2);

                SDL.SDL_SetRenderDrawColor(rendererPtr, Red, Grn, Blu, (byte)alpha);//we cast the alpha here to stop rounding errors creaping up.

                SDL.SDL_RenderDrawLine(rendererPtr, x1, y1, x2, y2);
                //SDL.SDL_RenderDrawLine(rendererPtr, _drawPoints[i].x, _drawPoints[i].y, _drawPoints[i + 1].x, _drawPoints[i + 1].y);
                alpha -= _alphaChangeAmount;
            }



            //SOI filled circle area.
            SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 50, 100, 100);
            //DrawPrimitive.DrawFilledCircle(rendererPtr ,ViewScreenPos.x , ViewScreenPos.y, (int)_soiViewRadius);
            //DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _soiViewRadius, _soiViewRadius);


            var soipnts = CreatePrimitiveShapes.BresenhamCircle(0, 0, (int)_soiViewRadius);

            //SDL.SDL_RenderDrawPoints(rendererPtr, soipnts.ToArray(), soipnts.Count);
            var lasty = 0;

            for (int i = 0; i < soipnts.Count; i += 2)
            {
                var x = soipnts[i].x;
                var y = soipnts[i].y;
                if (y != lasty)
                {
                    SDL.SDL_RenderDrawLine(rendererPtr, ViewScreenPos.x - x, ViewScreenPos.y - y, ViewScreenPos.x + x, ViewScreenPos.y - y);
                }
                lasty = y;
            }


/*
 *          for (int i = 0; i < soipnts.Count -1; i++)
 *          {
 *              //var err = SDL.SDL_GetError();
 *              //SDL.SDL_RenderDrawLine(rendererPtr, soipnts[i].x, soipnts[i].y, soipnts[i + 1].x, soipnts[i + 1].y);
 *              if (SDL.SDL_RenderDrawPoint(rendererPtr, soipnts[i].x, soipnts[i].y) < 0)
 *              {
 *                  var err = SDL.SDL_GetError();
 *              }
 *
 *              //SDL.SDL_RenderDrawLine(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, soipnts[i].x, soipnts[i].y);
 *              //var err2 = SDL.SDL_GetError();
 *          }
 */
            //Planet Filled Circle
            SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 255);
            DrawPrimitive.DrawEllipse(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, _targetViewRadius, _targetViewRadius);
            var plntPts = CreatePrimitiveShapes.BresenhamCircle(ViewScreenPos.x, ViewScreenPos.y, (int)_targetViewRadius);

            for (int i = 0; i < plntPts.Count - 1; i++)
            {
                SDL.SDL_RenderDrawLine(rendererPtr, plntPts[i].x, plntPts[i].y, plntPts[i + 1].x, plntPts[i + 1].y);
            }

            /*
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 0, 100, 0, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 63, 63, 0, _loAN); //draw LoAN angle
             *
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 50, 0, 100, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 64, 64, _loAN, _aoP); //draw AoP angle
             *
             * SDL.SDL_SetRenderDrawColor(rendererPtr, 100, 0, 0, 160);
             * DrawPrimitive.DrawArc(rendererPtr, ViewScreenPos.x, ViewScreenPos.y, 66, 66, OrbitAngleRadians,  _trueAnomaly);
             */
        }