public Corridor CreateCorrdior(Polygon2D area, double floorHeight, double ceilingHeight)
        {
            var c = new Corridor();

            c.Area = area;
            c.FloorHeight = floorHeight;
            c.CeilingHeight = ceilingHeight;

            return c;
        }
 private static bool CorridorCollision(Geometry.Circle2D c, double objectZ, double objectHeight , Corridor corridor)
 {
     if (Geometry.Intersections.CirclePolygonIntersection(c,
            corridor.Area))
     {
         if (objectZ >= corridor.FloorHeight - (objectHeight / 2)
             &&
             objectZ <= corridor.CeilingHeight - (objectHeight))
             return false;
         return true;
     }
     return false;
 }
        private void DrawCorridor(Corridor c)
        {
            var floorTex = ContentManager.Instance[c.FloorTexture.TextureTag];
              var ceilingTex = ContentManager.Instance[c.CeilingTexture.TextureTag];
              var cWallTex = ContentManager.Instance[c.CeilingWallTexture.TextureTag];
              var cFloorTex = ContentManager.Instance[c.FloorWallTexture.TextureTag];

              var area = c.Area.Triangulate();

              SetupTexture(c.FloorTexture);
              GL.BindTexture(TextureTarget.Texture2D, floorTex.glID);
              GL.Begin(BeginMode.Triangles);

              var center = c.Area.Center;

              foreach (var renderTriangle in area)
              {
            GL.Normal3(0, 1, 0);

            GL.TexCoord2(renderTriangle.Points[0].X / floorTex.Width, renderTriangle.Points[0].Y / floorTex.Height);
            GL.Vertex3(renderTriangle.Points[0].X, c.FloorHeight, renderTriangle.Points[0].Y);

            GL.TexCoord2(renderTriangle.Points[1].X / floorTex.Width, renderTriangle.Points[1].Y / floorTex.Height);
            GL.Vertex3(renderTriangle.Points[1].X, c.FloorHeight, renderTriangle.Points[1].Y);

            GL.TexCoord2(renderTriangle.Points[2].X / floorTex.Width, renderTriangle.Points[2].Y / floorTex.Height);
            GL.Vertex3(renderTriangle.Points[2].X, c.FloorHeight, renderTriangle.Points[2].Y);
              }
              GL.End();

              SetupTexture(c.CeilingTexture);
              GL.BindTexture(TextureTarget.Texture2D, ceilingTex.glID);
              GL.Begin(BeginMode.Triangles);

              foreach (var renderTriangle in area)
              {
            GL.Normal3(0, -1, 0);

            GL.TexCoord2(renderTriangle.Points[0].X / ceilingTex.Width, renderTriangle.Points[0].Y / ceilingTex.Height);
            GL.Vertex3(renderTriangle.Points[0].X, c.CeilingHeight, renderTriangle.Points[0].Y);

            GL.TexCoord2(renderTriangle.Points[2].X / ceilingTex.Width, renderTriangle.Points[2].Y / ceilingTex.Height);
            GL.Vertex3(renderTriangle.Points[2].X, c.CeilingHeight, renderTriangle.Points[2].Y);

            GL.TexCoord2(renderTriangle.Points[1].X / ceilingTex.Width, renderTriangle.Points[1].Y / ceilingTex.Height);
            GL.Vertex3(renderTriangle.Points[1].X, c.CeilingHeight, renderTriangle.Points[1].Y);

              }

              GL.End();

              SetupTexture(c.CeilingWallTexture);

              GL.BindTexture(TextureTarget.Texture2D, cWallTex.glID);

              GL.Begin(BeginMode.Quads);

              double total = 0;
              foreach (var wx in c.Area.Lines) total += wx.Length;

              double runningTotal = 0;

              foreach (var wall in c.Area.Lines)
              {
            var l1 = new Line2D(center, wall.A);
            var l2 = new Line2D(center, wall.B);

            GL.Normal3(l1.Normal.X, 0, l1.Normal.Y);

            GL.TexCoord2((runningTotal / total), _gameInstance.CurrentLevel.BaseFloorHeight / cWallTex.Height);
            GL.Vertex3(wall.A.X, _gameInstance.CurrentLevel.BaseFloorHeight, wall.A.Y);

            GL.Normal3(l2.Normal.X, 0, l2.Normal.Y);
            GL.TexCoord2((wall.Length + runningTotal) / total, _gameInstance.CurrentLevel.BaseFloorHeight / cWallTex.Height);
            GL.Vertex3(wall.B.X, _gameInstance.CurrentLevel.BaseFloorHeight, wall.B.Y);

            GL.Normal3(l2.Normal.X, 0, l2.Normal.Y);
            GL.TexCoord2((wall.Length + runningTotal) / total, c.FloorHeight / cWallTex.Height);
            GL.Vertex3(wall.B.X, c.FloorHeight, wall.B.Y);

            GL.Normal3(l1.Normal.X, 0, l1.Normal.Y);
            GL.TexCoord2(runningTotal / total, c.FloorHeight / cWallTex.Height);
            GL.Vertex3(wall.A.X, c.FloorHeight, wall.A.Y);
              }
              GL.End();

              SetupTexture(c.FloorWallTexture);

              GL.BindTexture(TextureTarget.Texture2D, cFloorTex.glID);

              GL.Begin(BeginMode.Quads);
              foreach (var wall in c.Area.Lines)
              {
            var l1 = new Line2D(center, wall.A);
            var l2 = new Line2D(center, wall.B);

            GL.Normal3(l1.Normal.X, 0, l1.Normal.Y);

            GL.TexCoord2((runningTotal) / total, c.CeilingHeight / cFloorTex.Height);
            GL.Vertex3(wall.A.X, c.CeilingHeight, wall.A.Y);

            GL.Normal3(l2.Normal.X, 0, l2.Normal.Y);

            GL.TexCoord2((wall.Length + runningTotal) / total, c.CeilingHeight / cFloorTex.Height);
            GL.Vertex3(wall.B.X, c.CeilingHeight, wall.B.Y);

            GL.Normal3(l2.Normal.X, 0, l2.Normal.Y);

            GL.TexCoord2((wall.Length + runningTotal) / total, _gameInstance.CurrentLevel.BaseCeilingHeight / cFloorTex.Height);
            GL.Vertex3(wall.B.X, _gameInstance.CurrentLevel.BaseCeilingHeight, wall.B.Y);

            GL.Normal3(l1.Normal.X, 0, l1.Normal.Y);
            GL.TexCoord2((runningTotal) / total, _gameInstance.CurrentLevel.BaseCeilingHeight / cFloorTex.Height);
            GL.Vertex3(wall.A.X, _gameInstance.CurrentLevel.BaseCeilingHeight, wall.A.Y);

            runningTotal += wall.Length;

              }
              GL.End();
        }