示例#1
0
 public void RenderTransparent(bool cache)
 {
     if (_cached2 || (_displayList2.Cached && !cache))
     {
         _displayList2.Call();
     }
     else if (cache)
     {
         _displayList2.Begin();
         GL.Begin(BeginMode.Quads);
         for (int x = 0; x < Width; ++x)
         {
             for (int y = 0; y < Depth; ++y)
             {
                 for (int z = 0; z < Height; ++z)
                 {
                     Blocktype type = GetBlocktype(x, y, z);
                     if (type != Blocktype.Water &&
                         type != Blocktype.StillWater &&
                         type != Blocktype.Ice)
                     {
                         continue;
                     }
                     BlocktypeInfo info = BlocktypeInfo.Find(type);
                     BlockRenderer.Render(this, info, x, y, z);
                 }
             }
         }
         GL.End();
         _displayList2.End();
         _cached2 = true;
     }
 }
示例#2
0
 public void RenderPicking(Vector3d origin, float range)
 {
     foreach (Chunk chunk in _chunks.Values)
     {
         double dist = Math.Sqrt((Math.Pow(origin.X - (chunk.X * Chunk.Width + Chunk.Width / 2), 2) +
                                  Math.Pow(origin.Z - (chunk.Z * Chunk.Height + Chunk.Height / 2), 2))) -
                       Chunk.Width * Math.Sqrt(2) / 2;
         if (dist > range)
         {
             continue;
         }
         GL.PushMatrix();
         GL.Translate(chunk.X * Chunk.Width, 0.0, chunk.Z * Chunk.Height);
         for (int x = (int)Math.Floor(Math.Max(0, origin.X - chunk.X * Chunk.Width - range));
              x < (int)Math.Ceiling(Math.Min(Chunk.Width, origin.X - chunk.X * Chunk.Width + range)); x++)
         {
             GL.PushName(chunk.X * 16 + x);
             for (int y = (int)Math.Floor(Math.Max(0, origin.Y - range));
                  y < (int)Math.Ceiling(Math.Min(Chunk.Depth, origin.Y + range)); y++)
             {
                 GL.PushName(y);
                 for (int z = (int)Math.Floor(Math.Max(0, origin.Z - chunk.Z * Chunk.Height - range));
                      z < (int)Math.Ceiling(Math.Min(Chunk.Height, origin.Z - chunk.Z * Chunk.Height + range)); z++)
                 {
                     dist = Math.Sqrt((Math.Pow(origin.X - (chunk.X * Chunk.Width + x), 2) + Math.Pow(origin.Y - y, 2)) +
                                      Math.Pow(origin.Z - (chunk.Z * Chunk.Height + z), 2));
                     if (dist > range)
                     {
                         continue;
                     }
                     Blocktype type = chunk.GetBlocktype(x, y, z);
                     if (type == Blocktype.Air)
                     {
                         continue;
                     }
                     BlocktypeInfo info = BlocktypeInfo.Find(type);
                     GL.PushName(chunk.Z * 16 + z);
                     BlockRenderer.RenderPicking(chunk, info, x, y, z);
                     GL.PopName();
                 }
                 GL.PopName();
             }
             GL.PopName();
         }
         GL.PopMatrix();
     }
 }