Example #1
0
File: Face.cs Project: silky/sledge
 /// <summary>
 /// Test this face to see if the given bounding box intersects with it
 /// </summary>
 /// <param name="box">The box to test against</param>
 /// <returns>True if the box intersects</returns>
 public bool IntersectsWithBox(Box box)
 {
     var verts = Vertices.Select(x => x.Location).ToList();
     return box.GetBoxLines().Any(x => GetIntersectionPoint(verts, x, true) != null);
 }
Example #2
0
 public override void Render(ViewportBase viewport)
 {
     if (_state == EntityState.None) return;
     TextureHelper.DisableTexturing();
     var high = Document.GameData.MapSizeHigh;
     var low = Document.GameData.MapSizeLow;
     if (viewport is Viewport3D)
     {
         var offset = new Coordinate(20, 20, 20);
         var start = _location - offset;
         var end = _location + offset;
         var box = new Box(start, end);
         GL.Begin(BeginMode.Lines);
         GL.Color3(Color.LimeGreen);
         foreach (var line in box.GetBoxLines())
         {
             Coord(line.Start);
             Coord(line.End);
         }
         Coord(low, _location.DY, _location.DZ);
         Coord(high, _location.DY, _location.DZ);
         Coord(_location.DX, low, _location.DZ);
         Coord(_location.DX, high, _location.DZ);
         Coord(_location.DX, _location.DY, low);
         Coord(_location.DX, _location.DY, high);
         GL.End();
     }
     else if (viewport is Viewport2D)
     {
         var vp = viewport as Viewport2D;
         var units = vp.PixelsToUnits(5);
         var offset = new Coordinate(units, units, units);
         var start = vp.Flatten(_location - offset);
         var end = vp.Flatten(_location + offset);
         GL.Begin(BeginMode.LineLoop);
         GL.Color3(Color.LimeGreen);
         Coord(start.DX, start.DY, start.DZ);
         Coord(end.DX, start.DY, start.DZ);
         Coord(end.DX, end.DY, start.DZ);
         Coord(start.DX, end.DY, start.DZ);
         GL.End();
         GL.Begin(BeginMode.Lines);
         var loc = vp.Flatten(_location);
         Coord(low, loc.DY, 0);
         Coord(high, loc.DY, 0);
         Coord(loc.DX, low, 0);
         Coord(loc.DX, high, 0);
         GL.End();
     }
     TextureHelper.EnableTexturing();
 }
Example #3
0
 protected virtual void Render3DBox(Viewport3D viewport, Coordinate start, Coordinate end)
 {
     var box = new Box(start, end);
     TextureHelper.Unbind();
     GL.Begin(PrimitiveType.Lines);
     GL.Color4(GetRenderBoxColour());
     foreach (var line in box.GetBoxLines())
     {
         Coord(line.Start);
         Coord(line.End);
     }
     GL.End();
 }
Example #4
0
        public override void Render(ViewportBase viewport)
        {
            if (_currentPoint != null)
            {
                var sub = new Coordinate(40, 40, 40);
                var pointBox = new Box(_currentPoint.CurrentPosition.Location - sub, _currentPoint.CurrentPosition.Location + sub);

                TextureHelper.Unbind();
                GL.LineWidth(3);
                GL.Begin(PrimitiveType.Lines);
                GL.Color3(1f, 1, 0);
                foreach (var line in pointBox.GetBoxLines())
                {
                    GL.Vertex3(line.Start.DX, line.Start.DY, line.Start.DZ);
                    GL.Vertex3(line.End.DX, line.End.DY, line.End.DZ);
                }
                GL.End();
                GL.LineWidth(1);
            }
        }