コード例 #1
0
        private void InitializeRoute(RenderContext11 renderContext)
        {
            triangleList               = new TriangleList();
            triangleList.Decay         = 1000;
            triangleList.Sky           = this.Astronomical;
            triangleList.TimeSeries    = true;
            triangleList.DepthBuffered = false;
            triangleList.AutoTime      = false;

            int steps = 500;

            Vector3d start = Coordinates.GeoTo3dDouble(latStart, lngStart);
            Vector3d end   = Coordinates.GeoTo3dDouble(latEnd, lngEnd);
            Vector3d dir   = end - start;

            dir.Normalize();

            Vector3d startNormal = start;

            startNormal.Normalize();

            Vector3d left  = Vector3d.Cross(startNormal, dir);
            Vector3d right = Vector3d.Cross(dir, startNormal);

            left.Normalize();
            right.Normalize();

            left.Multiply(.001 * width);
            right.Multiply(.001 * width);

            Vector3d lastLeft  = new Vector3d();
            Vector3d lastRight = new Vector3d();
            bool     firstTime = true;

            for (int i = 0; i <= steps; i++)
            {
                Vector3d v = Vector3d.Lerp(start, end, i / (float)steps);
                v.Normalize();
                Vector3d cl = v;
                Vector3d cr = v;

                cl.Add(left);
                cr.Add(right);

                if (!firstTime)
                {
                    triangleList.AddQuad(lastRight, lastLeft, cr, cl, Color, new Dates(i / (float)steps, 2));
                }
                else
                {
                    firstTime = false;
                }

                lastLeft  = cl;
                lastRight = cr;
            }
        }
コード例 #2
0
        private void AddLines(bool sky, KmlLineList geo, float lineWidth, Color polyColor, Color lineColor, bool extrude)
        {
            //todo can we save this work for later?
            List <Vector3d> vertexList       = new List <Vector3d>();
            List <Vector3d> vertexListGround = new List <Vector3d>();

            //todo list
            // We need to Wrap Around for complete polygone
            // we aldo need to do intereor
            //todo space? using RA/DEC



            for (int i = 0; i < (geo.PointList.Count); i++)
            {
                vertexList.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1 + (geo.PointList[i].Alt / geo.MeanRadius)));
                vertexListGround.Add(Coordinates.GeoTo3dDouble(geo.PointList[i].Lat, geo.PointList[i].Lng, 1));
            }


            for (int i = 0; i < (geo.PointList.Count - 1); i++)
            {
                if (sky)
                {
                    lines.AddLine(Coordinates.RADecTo3d(-(180.0 - geo.PointList[i].Lng) / 15 + 12, geo.PointList[i].Lat, 1), Coordinates.RADecTo3d(-(180.0 - geo.PointList[i + 1].Lng) / 15 + 12, geo.PointList[i + 1].Lat, 1), lineColor, new Dates());
                }
                else
                {
                    if (extrude)
                    {
                        triangles.AddQuad(vertexList[i], vertexList[i + 1], vertexListGround[i], vertexListGround[i + 1], polyColor, new Dates());
                    }

                    if (lineWidth > 0)
                    {
                        lines.AddLine
                            (vertexList[i], vertexList[i + 1], lineColor, new Dates());
                        if (extrude)
                        {
                            lines.AddLine(vertexListGround[i], vertexListGround[i + 1], lineColor, new Dates());
                            lines.AddLine(vertexList[i], vertexListGround[i], lineColor, new Dates());
                            lines.AddLine(vertexList[i + 1], vertexListGround[i + 1], lineColor, new Dates());
                        }
                    }
                }
            }

            List <int> indexes = Glu.TesselateSimplePoly(vertexList);

            for (int i = 0; i < indexes.Count; i += 3)
            {
                triangles.AddTriangle(vertexList[indexes[i]], vertexList[indexes[i + 1]], vertexList[indexes[i + 2]], polyColor, new Dates());
            }
        }
コード例 #3
0
        private void InitializeRoute(RenderContext11 renderContext)
        {
            triangleList = new TriangleList();
            triangleList.Decay = 1000;
            triangleList.Sky = this.Astronomical;
            triangleList.TimeSeries = true;
            triangleList.DepthBuffered = false;
            triangleList.AutoTime = false;

            int steps = 500;

            Vector3d start = Coordinates.GeoTo3dDouble(latStart, lngStart);
            Vector3d end = Coordinates.GeoTo3dDouble(latEnd, lngEnd);
            Vector3d dir = end - start;
            dir.Normalize();

            Vector3d startNormal = start;
            startNormal.Normalize();

            Vector3d left = Vector3d.Cross(startNormal, dir);
            Vector3d right = Vector3d.Cross(dir, startNormal);
            left.Normalize();
            right.Normalize();

            left.Multiply(.001*width);
            right.Multiply(.001 * width);

            Vector3d lastLeft = new Vector3d();
            Vector3d lastRight = new Vector3d();
            bool firstTime = true;
            for (int i = 0; i <= steps; i++)
            {
                Vector3d v = Vector3d.Lerp(start, end, i / (float)steps);
                v.Normalize();
                Vector3d cl = v;
                Vector3d cr = v;

                cl.Add(left);
                cr.Add(right);

                if (!firstTime)
                {
                    triangleList.AddQuad(lastRight, lastLeft, cr, cl, Color, new Dates(i / (float)steps, 2));
                }
                else
                {
                   firstTime = false;
                }

                lastLeft = cl;
                lastRight = cr;

            }
        }
コード例 #4
0
        static void MakeCube(TriangleList tl, Vector3d center, double size, System.Drawing.Color color)
        {
            System.Drawing.Color dark = System.Drawing.Color.FromArgb((int)(color.R * .6), (color.G), (int)(color.B * .6));
            System.Drawing.Color med = System.Drawing.Color.FromArgb((int)(color.R * .8), (int)(color.G * .8), (int)(color.B * .8));

            tl.AddQuad(
                new Vector3d(center.X + size, center.Y + size, center.Z + size),
                new Vector3d(center.X + size, center.Y + size, center.Z - size),
                new Vector3d(center.X - size, center.Y + size, center.Z + size),
                new Vector3d(center.X - size, center.Y + size, center.Z - size),
                color, new Dates());

            tl.AddQuad(
                new Vector3d(center.X + size, center.Y - size, center.Z + size),
                new Vector3d(center.X - size, center.Y - size, center.Z + size),
                new Vector3d(center.X + size, center.Y - size, center.Z - size),
                new Vector3d(center.X - size, center.Y - size, center.Z - size),
                color, new Dates());

            tl.AddQuad(
               new Vector3d(center.X - size, center.Y + size, center.Z + size),
               new Vector3d(center.X - size, center.Y + size, center.Z - size),
               new Vector3d(center.X - size, center.Y - size, center.Z + size),
               new Vector3d(center.X - size, center.Y - size, center.Z - size),
               dark, new Dates());

            tl.AddQuad(
                new Vector3d(center.X + size, center.Y + size, center.Z + size),
                new Vector3d(center.X + size, center.Y - size, center.Z + size),
                new Vector3d(center.X + size, center.Y + size, center.Z - size),
                new Vector3d(center.X + size, center.Y - size, center.Z - size),
                dark, new Dates());

            tl.AddQuad(
              new Vector3d(center.X + size, center.Y + size, center.Z + size),
              new Vector3d(center.X - size, center.Y + size, center.Z + size),
              new Vector3d(center.X + size, center.Y - size, center.Z + size),
              new Vector3d(center.X - size, center.Y - size, center.Z + size),
              med, new Dates());

            tl.AddQuad(
              new Vector3d(center.X + size, center.Y + size, center.Z - size),
              new Vector3d(center.X + size, center.Y - size, center.Z - size),
              new Vector3d(center.X - size, center.Y + size, center.Z - size),
              new Vector3d(center.X - size, center.Y - size, center.Z - size),
              med, new Dates());
        }
コード例 #5
0
        static void InitRotateUI()
        {
            RotateUi = new TriangleList();
            RotateUi.DepthBuffered = false;
            RotateUi.TimeSeries = false;
            RotateUi.WriteZbuffer = false;

            double twoPi = Math.PI * 2;
            double step = twoPi / 40;
            double rad = .05;
            int index = 0;

            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(rad * (start ? 0 : (end ? 1.5 : 1)), Math.Cos(a), Math.Sin(a));
                Vector3d pnt2 = new Vector3d(-rad * (start ? 0 : (end ? 1.5 : 1)), Math.Cos(a), Math.Sin(a));
                Vector3d pnt3 = new Vector3d(rad * (start ? 1.5 : (end ? 0 : 1)), Math.Cos(a + step), Math.Sin(a + step));
                Vector3d pnt4 = new Vector3d(-rad * (start ? 1.5 : (end ? 0 : 1)), Math.Cos(a + step), Math.Sin(a + step));
                RotateUi.AddQuad(pnt1, pnt3, pnt2, pnt4, System.Drawing.Color.FromArgb(192, System.Drawing.Color.DarkRed), new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(192, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }

            index = 0;
            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(Math.Cos(a), Math.Sin(a), rad * (start ? 0 : (end ? 1.5 : 1)));
                Vector3d pnt2 = new Vector3d(Math.Cos(a), Math.Sin(a), -rad * (start ? 0 : (end ? 1.5 : 1)));
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step), Math.Sin(a + step), rad * (start ? 1.5 : (end ? 0 : 1)));
                Vector3d pnt4 = new Vector3d(Math.Cos(a + step), Math.Sin(a + step), -rad * (start ? 1.5 : (end ? 0 : 1)));
                RotateUi.AddQuad(pnt1, pnt3, pnt2, pnt4, System.Drawing.Color.FromArgb(192, System.Drawing.Color.DarkBlue), new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(192, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }

            index = 0;
            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(Math.Cos(a), rad * (start ? 0 : (end ? 1.5 : 1)), Math.Sin(a));
                Vector3d pnt2 = new Vector3d(Math.Cos(a), -rad * (start ? 0 : (end ? 1.5 : 1)), Math.Sin(a));
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step), rad * (start ? 1.5 : (end ? 0 : 1)), Math.Sin(a + step));
                Vector3d pnt4 = new Vector3d(Math.Cos(a + step), -rad * (start ? 1.5 : (end ? 0 : 1)), Math.Sin(a + step));
                RotateUi.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(192, System.Drawing.Color.DarkGreen), new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(192, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }

            // X
            index = 0;
            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(-rad * (start ? 0 : (end ? 1.5 : 1)), Math.Cos(a), Math.Sin(a));
                Vector3d pnt2 = new Vector3d(rad * (start ? 0 : (end ? 1.5 : 1)), Math.Cos(a), Math.Sin(a));
                Vector3d pnt3 = new Vector3d(-rad * (start ? 1.5 : (end ? 0 : 1)), Math.Cos(a + step), Math.Sin(a + step));
                Vector3d pnt4 = new Vector3d(rad * (start ? 1.5 : (end ? 0 : 1)), Math.Cos(a + step), Math.Sin(a + step));
                RotateUi.AddQuad(pnt1, pnt3, pnt2, pnt4, System.Drawing.Color.Red, new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(255, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }

            //Y
            index = 0;
            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(Math.Cos(a), Math.Sin(a), -rad * (start ? 0 : (end ? 1.5 : 1)));
                Vector3d pnt2 = new Vector3d(Math.Cos(a), Math.Sin(a), rad * (start ? 0 : (end ? 1.5 : 1)));
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step), Math.Sin(a + step), -rad * (start ? 1.5 : (end ? 0 : 1)));
                Vector3d pnt4 = new Vector3d(Math.Cos(a + step), Math.Sin(a + step), rad * (start ? 1.5 : (end ? 0 : 1)));
                RotateUi.AddQuad(pnt1, pnt3, pnt2, pnt4, System.Drawing.Color.Blue, new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(255, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }

            //Z
            index = 0;
            for (double a = 0; a < twoPi; a += step)
            {
                bool start = (index % 10) == 0;
                bool end = ((index + 1) % 10) == 0;
                Vector3d pnt1 = new Vector3d(Math.Cos(a), -rad * (start ? 0 : (end ? 1.5 : 1)), Math.Sin(a));
                Vector3d pnt2 = new Vector3d(Math.Cos(a), rad * (start ? 0 : (end ? 1.5 : 1)), Math.Sin(a));
                Vector3d pnt3 = new Vector3d(Math.Cos(a + step), -rad * (start ? 1.5 : (end ? 0 : 1)), Math.Sin(a + step));
                Vector3d pnt4 = new Vector3d(Math.Cos(a + step), rad * (start ? 1.5 : (end ? 0 : 1)), Math.Sin(a + step));
                RotateUi.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.Green, new Dates());
                //TranslateUI.AddQuad(pnt1, pnt2, pnt3, pnt4, System.Drawing.Color.FromArgb(255, Math.Max(0, (int)(Math.Sin(a) * 128)), Math.Max(0, (int)(Math.Sin(a) * 128))), new Dates());
                index++;
            }
        }