Esempio n. 1
0
        internal void ShowSphereOnce(Vector3 center, float radius, Color color)
        {
            for (int j = 0; j < Sides; j++)
            {
                float   angle = j / (float)Sides * MathHelper.TwoPi;
                Vector3 x     = new Vector3((float)Math.Cos(angle), 0, (float)Math.Sin(angle)) * radius;
                Vector3 y     = Vector3.UnitY * radius;

                // Draw the vertical circles.
                for (int i = 0; i < CircleSteps; i++)
                {
                    float angle1 = i / (float)CircleSteps * MathHelper.TwoPi;
                    float angle2 = (i + 1) / (float)CircleSteps * MathHelper.TwoPi;
                    float sin1   = (float)Math.Sin(angle1);
                    float cos1   = (float)Math.Cos(angle1);
                    float sin2   = (float)Math.Sin(angle2);
                    float cos2   = (float)Math.Cos(angle2);
                    lines.ShowLineOnce(center + y * sin1 + x * cos1, center + y * sin2 + x * cos2, color);
                }
            }

            Vector3 x2 = Vector3.UnitX * radius;
            Vector3 z2 = Vector3.UnitZ * radius;

            // Draw the equator.
            for (int i = 0; i < CircleSteps; i++)
            {
                float sin1 = (float)Math.Sin(i / (float)CircleSteps * MathHelper.TwoPi);
                float cos1 = (float)Math.Cos(i / (float)CircleSteps * MathHelper.TwoPi);
                float sin2 = (float)Math.Sin((i + 1) / (float)CircleSteps * MathHelper.TwoPi);
                float cos2 = (float)Math.Cos((i + 1) / (float)CircleSteps * MathHelper.TwoPi);
                lines.ShowLineOnce(center + x2 * sin1 + z2 * cos1, center + x2 * sin2 + z2 * cos2, color);
            }
        }
Esempio n. 2
0
        internal void ShowVector3Once(Vector3 location, Vector3 vector, Color color)
        {
            Vector3 v1 = location;
            Vector3 v2 = location + vector;
            // Difference vector
            Vector3 diff     = v1 - v2;
            float   distance = Vector3.Distance(v1, v2);

            if (distance == 0)
            {
                return;
            }
            diff *= 1 / distance;
            // Craft a vector that is normal to diff
            Vector3 normal1 = Vector3.Cross(diff, new Vector3(diff.Y, diff.X, diff.Z));

            if (normal1 == Vector3.Zero)
            {
                normal1 = Vector3.Cross(diff, diff + Vector3.UnitY);
            }
            // Craft a vector that is normal to both diff and normal1
            Vector3 normal2 = Vector3.Cross(diff, normal1);

            normal1 *= distance * 0.02f;
            normal2 *= distance * 0.02f;
            diff    *= distance * 0.04f;
            lines.ShowLineOnce(v1, v2, color);
            lines.ShowLineOnce(v2 + normal1 + diff, v2, color);
            lines.ShowLineOnce(v2 - normal1 + diff, v2, color);
            lines.ShowLineOnce(v2 + normal2 + diff, v2, color);
            lines.ShowLineOnce(v2 - normal2 + diff, v2, color);
        }
Esempio n. 3
0
        internal void ShowVector2Once(Vector2 location, Vector2 vector, Color color)
        {
            var v1 = location;
            var v2 = vector;
            // Difference vector
            var diff     = v1 - v2;
            var distance = Vector2.Distance(location, v2);

            if (distance == 0)
            {
                return;
            }
            diff *= 1 / distance;
            // Craft a vector that is normal to diff
            var normal1 = new Vector2(diff.Y, -diff.X);

            // TODO: Move this value to a config
            normal1 *= 8;
            diff    *= 8;
            _lines.ShowLineOnce(v1, v2, color);
            _lines.ShowLineOnce(v2 + normal1 + diff, v2, color);
            _lines.ShowLineOnce(v2 - normal1 + diff, v2, color);
        }
Esempio n. 4
0
        internal void ShowSphereOnce(Vector3 center, float radius, Color color)
        {
            for (var j = 0; j < Sides; j++)
            {
                var x = new Vector3(CosSideSteps[j], 0, SinSideSteps[j]) * radius;
                var y = Vector3.UnitY * radius;

                // Draw the vertical circles.
                for (var i = 0; i < CircleSteps; i++)
                {
                    _lines.ShowLineOnce(center + y * SinCircleSteps[i] + x * CosCircleSteps[i], center + y * SinCircleSteps[i + 1] + x * CosCircleSteps[i + 1], color);
                }
            }

            var x2 = Vector3.UnitX * radius;
            var z2 = Vector3.UnitZ * radius;

            // Draw the equator.
            for (var i = 0; i < CircleSteps; i++)
            {
                _lines.ShowLineOnce(center + x2 * SinCircleSteps[i] + z2 * CosCircleSteps[i], center + x2 * SinCircleSteps[i + 1] + z2 * CosCircleSteps[i + 1], color);
            }
        }
Esempio n. 5
0
 /// <summary>
 ///     Helper methods, draws the border of the box. Must be called every frame.
 ///     TODO: Move this to a UI debug drawer or something similar
 /// </summary>
 internal void DrawBorderLines(Color color, InternalLineDrawer lineDrawer)
 {
     var screenPos = GetScreenPosition();
     var tl = screenPos;
     var tr = new Vector2(screenPos.X + _size.X, screenPos.Y);
     var br = new Vector2(screenPos.X + _size.X, screenPos.Y + _size.Y);
     var bl = new Vector2(screenPos.X, screenPos.Y + _size.Y);
     lineDrawer.ShowLineOnce(tl, tr, color);
     lineDrawer.ShowLineOnce(tr, br, color);
     lineDrawer.ShowLineOnce(br, bl, color);
     lineDrawer.ShowLineOnce(bl, tl, color);
 }
Esempio n. 6
0
 public void DrawCrossLines(Color color, InternalLineDrawer lineDrawer)
 {
     lineDrawer.ShowLineOnce(TopLeft, BottomRight, color);
     lineDrawer.ShowLineOnce(TopRight, BottomLeft, color);
 }
Esempio n. 7
0
 internal void ShowBoxOnce(Vector3 min, Vector3 max, Color color)
 {
     lines.ShowLineOnce(new Vector3(min.X, min.Y, min.Z), new Vector3(max.X, min.Y, min.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, max.Y, min.Z), new Vector3(max.X, max.Y, min.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, min.Y, min.Z), new Vector3(min.X, max.Y, min.Z), color);
     lines.ShowLineOnce(new Vector3(max.X, min.Y, min.Z), new Vector3(max.X, max.Y, min.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, min.Y, max.Z), new Vector3(max.X, min.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, max.Y, max.Z), new Vector3(max.X, max.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, min.Y, max.Z), new Vector3(min.X, max.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(max.X, min.Y, max.Z), new Vector3(max.X, max.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, min.Y, min.Z), new Vector3(min.X, min.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(min.X, max.Y, min.Z), new Vector3(min.X, max.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(max.X, max.Y, min.Z), new Vector3(max.X, max.Y, max.Z), color);
     lines.ShowLineOnce(new Vector3(max.X, min.Y, min.Z), new Vector3(max.X, min.Y, max.Z), color);
 }