示例#1
0
 public SimpleCircle(ECSLib.IPosition positionDB, double radius, SDL.SDL_Color colour)
 {
     _positionDB  = positionDB;
     positionByDB = true;
     _shape       = new Shape()
     {
         Points = CreatePrimitiveShapes.Circle(0, 0, radius, 128),
         Color  = colour,
     };
 }
示例#2
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);
             */
        }
示例#3
0
        void Front(int width, int height, int offsetX, int offsetY) //crew
        {
            var  points = CreatePrimitiveShapes.CreateArc(offsetX, offsetY, width * 0.5, height * 0.5, CreatePrimitiveShapes.QuarterCircle, CreatePrimitiveShapes.HalfCircle, 16);
            byte r      = 0;
            byte g      = 100;
            byte b      = 100;
            byte a      = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };
            Shapes.Add(new Shape()
            {
                Points = points, Color = colour
            });
        }
示例#4
0
        void Reactors(int width, int height, int offsetX, int offsetY)
        {
            byte r = 100;
            byte g = 0;
            byte b = 0;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };

            var shape = new Shape()
            {
                Color = colour, Points = CreatePrimitiveShapes.CreateArc(offsetX, offsetY, (int)(width * 0.5), (int)(height * 0.5), 0, CreatePrimitiveShapes.PI2, 12)
            };

            Shapes.Add(shape);
        }
示例#5
0
        void Engines(int width, int height, int offsetX, int offsetY)
        {
            byte r1 = 200;
            byte g1 = 200;
            byte b1 = 200;
            byte a1 = 255;

            SDL.SDL_Color colourbox = new SDL.SDL_Color()
            {
                r = r1, g = g1, b = b1, a = a1
            };

            byte r2 = 100;
            byte g2 = 150;
            byte b2 = 0;
            byte a2 = 255;

            SDL.SDL_Color colourCone = new SDL.SDL_Color()
            {
                r = r2, g = g2, b = b2, a = a2
            };

            int thrusterCount = 3;
            int twidth        = width / thrusterCount;
            int toffset       = (int)(offsetX - width * 0.5f + twidth * 0.5);

            for (int i = 0; i < thrusterCount; i++)
            {
                int boxHeight  = height / 3;
                int boxWidth   = twidth;
                int coneHeight = height - boxHeight;
                Shapes.Add(new Shape()
                {
                    Color = colourbox, Points = CreatePrimitiveShapes.Rectangle(toffset, (int)(offsetY + boxHeight * 0.5), boxWidth, boxHeight, CreatePrimitiveShapes.PosFrom.Center)
                });
                Shapes.Add(new Shape()
                {
                    Color = colourCone, Points = CreatePrimitiveShapes.CreateArc(toffset, offsetY + boxHeight + coneHeight, (int)(boxWidth * 0.5), coneHeight, CreatePrimitiveShapes.QuarterCircle, CreatePrimitiveShapes.HalfCircle, 8)
                });
                toffset += twidth;
            }
        }
示例#6
0
        void Unknown()
        {
            short segments = 24;
            var   points   = CreatePrimitiveShapes.Circle(0, 0, 100, segments);
            //colors picked out of my ass .
            //TODO: use minerals for this? but migth not have that info. going to have to work in with sensor stuff.
            byte r = 100;
            byte g = 100;
            byte b = 100;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };
            Shapes.Add(new Shape()
            {
                Color = colour, Points = points
            });
        }
示例#7
0
        void Cargo(int width, int height, int offsetX, int offsetY)//and fuel
        {
            byte r = 0;
            byte g = 0;
            byte b = 200;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };

            //TODO: change numbers depending on number of cargo containing components.
            int numberofPodsX = 4;
            int numberofPodsY = 2;

            int podWidth = width / numberofPodsX;
            int offsetx1 = (int)(offsetX - width * 0.5f + podWidth * 0.5);

            int podHeight = height / numberofPodsY;
            int offsety1  = (int)(offsetY + podHeight * 0.5);

            for (int podset = 0; podset < numberofPodsY; podset++)
            {
                offsety1 += podset * podHeight;

                int offsetx2 = offsetx1 - podWidth;

                for (int i = 0; i < numberofPodsX; i++)
                {
                    offsetx2 += podWidth;
                    Shape shape = new Shape()
                    {
                        Color = colour, Points = CreatePrimitiveShapes.RoundedCylinder(podWidth, height / numberofPodsY, offsetx2, offsety1)
                    };
                    Shapes.Add(shape);
                }
            }
        }
示例#8
0
        void Terestrial()
        {
            _iconMinSize = 8;
            short segments = 32;
            var   points   = CreatePrimitiveShapes.Circle(0, 0, 100, segments);


            //colors picked out of my ass for a blue/green look.
            //TODO: use minerals for this? but migth not have that info. going to have to work in with sensor stuff.
            byte r = 0;
            byte g = 100;
            byte b = 100;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };
            Shapes.Add(new Shape()
            {
                Color = colour, Points = points
            });
        }
示例#9
0
        void Asteroid()
        {
            _iconMinSize = 8;
            double vertDiameter = _rng.Next(50, 100);
            double horDiameter  = _rng.Next(50, 100);
            int    segments     = _rng.Next(8, 32);
            int    jagMax       = _rng.Next(5, 8);
            int    jagMin       = _rng.Next(4, jagMax);

            var points = CreatePrimitiveShapes.CreateArc(0, 0, horDiameter, vertDiameter, 0, Math.PI * 2, segments);

            for (int i = 0; i < segments; i = i + 2)
            {
                //this is not right, need to pull the points in towards the center, not just pull them left.
                double x = points[i].X - _rng.Next(jagMin, jagMax);
                double y = points[i].Y - _rng.Next(jagMin, jagMax);
                points[i] = new PointD()
                {
                    X = x, Y = y
                };
            }
            //colors picked out of my ass for a brown look.
            //TODO: use minerals for this? but migth not have that info. going to have to work in with sensor stuff.
            byte r = 150;
            byte g = 100;
            byte b = 50;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };
            Shapes.Add(new Shape()
            {
                Color = colour, Points = points
            });
        }
        void CreateProgradeArrow()
        {
            PointD[] arrowPoints = CreatePrimitiveShapes.CreateArrow(24);

            /*
             * List<PointD> arrowPoints = new List<PointD>(pnts.Length);
             * foreach (var point in pnts)
             * {
             *  double x = point.X * Math.Cos(ProgradeAngle) - point.Y * Math.Sin(ProgradeAngle);
             *  double y = point.X * Math.Sin(ProgradeAngle) + point.Y * Math.Cos(ProgradeAngle);
             *  arrowPoints.Add(new PointD() { X = x, Y = y });
             * }
             */
            var rotate270 = Matrix.New270DegreeMatrix();

            _arrow = new PointD[arrowPoints.Length];
            for (int i = 0; i < _arrow.Length; i++)
            {
                _arrow[i] = rotate270.TransformD(arrowPoints[i]);
            }

            _progradeArrow = new Shape()
            {
                Points = _arrow,
                Color  = VectorColour
            };

            if (Shapes.Count < 1)
            {
                Shapes.Add(_progradeArrow);
            }
            else
            {
                Shapes[0] = _progradeArrow;
            }
        }
        void Setup()
        {
            Shapes = new List <Shape>(5);
            CreateProgradeArrow();

            Shape dot = new Shape()
            {
                Points = CreatePrimitiveShapes.Circle(0, 0, 3, 6),
                Color  = PrimaryColour
            };
            Shape circle = new Shape()
            {
                Points = CreatePrimitiveShapes.Circle(0, 0, 8, 12),
                Color  = PrimaryColour
            };

            //Shapes[0] = vectorArrow;
            //Shapes[1] = dot;
            //Shapes[2] = circle;
            //Shapes[3] = chevron;
            //Shapes[4] = chevron2;
            Shapes.Add(dot);
            Shapes.Add(circle);
        }
示例#12
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);
             */
        }
示例#13
0
        private static void Setup(List <Icon> icons)
        {
            List <Shape> shapes = new List <Shape>();

            PointD[] lpoints1 = new PointD[] {
                new PointD {
                    X = 0, Y = -160
                },
                new PointD {
                    X = 0, Y = 160
                },
            };
            PointD[] lpoints2 = new PointD[] {
                new PointD {
                    X = -25, Y = 0
                },
                new PointD {
                    X = 25, Y = 0
                }
            };
            SDL.SDL_Color lcolor = new SDL.SDL_Color()
            {
                r = 0, g = 255, b = 0, a = 255
            };
            shapes.Add(new Shape()
            {
                Points = lpoints1, Color = lcolor
            });
            shapes.Add(new Shape()
            {
                Points = lpoints2, Color = lcolor
            });
            PositionDB lpos = new PositionDB(new Vector3(0, 0, 0), new Guid());

            icons.Add(new Icon(lpos)
            {
                Shapes = shapes
            });

            for (int i = 0; i < 4; i++)
            {
                PointD[]      points = CreatePrimitiveShapes.CreateArc(50 + 50 * i, 400, 100, 100, 0, 4.71, 160);
                SDL.SDL_Color color  = new SDL.SDL_Color()
                {
                    r = (byte)(i * 60), g = 100, b = 100, a = 255
                };
                Shape shape = new Shape()
                {
                    Points = points, Color = color
                };
                PositionDB pos1 = new PositionDB(new Vector3(0, 0, 0), new Guid());

                icons.Add(new Icon(pos1)
                {
                    Shapes = new List <Shape> {
                        shape
                    }
                });
            }

            /*
             * PositionDB pos2 = new PositionDB(new Vector4(0, -0, 0, 0), new Guid());
             * var shape2 = new Shape() { Color = new SDL.SDL_Color() { r = 255, g = 0, b = 0, a = 255 }, Points = CreatePrimitiveShapes.RoundedCylinder(50, 100, 0, 0) };
             * var shapes2 = new List<Shape>() { shape2 };
             *
             * icons.Add(new Icon(pos2) { Shapes = shapes2 });
             */

            PositionDB pos3 = new PositionDB(new Vector3(100, 0, 0), new Guid());

            icons.Add(new ShipIcon(pos3));
        }