Example #1
0
 public byte GetFace(Direction direction)
 {
     switch (InternalType)
     {
         case BlockType.Grass: return new byte[] { 1, 1, 0, 3, 1, 1 }[direction.Value];
         case BlockType.Stone: return 2;
         case BlockType.Dirt: return 3;
         case BlockType.Water: return 4;
         case BlockType.Sand: return 5;
         case BlockType.Leaves: return 6;
         case BlockType.Lava: return 7;
         case BlockType.Log: return new byte[] { 8, 8, 9, 9, 8, 8 }[direction.Value];
         default: return 0;
     }
 }
Example #2
0
        public static byte GetFaceShade(BlockIndex index, Direction direction)
        {
            if (Constants.Graphics.AmbientOcclusionEnabled)
            {
                double maxDist = 6;
                double dist = 0;
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);

                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() + direction.GetPerpendicularRight(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() - direction.GetPerpendicularRight(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() + direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() - direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);

                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() + direction.GetPerpendicularRight() + direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() + direction.GetPerpendicularRight() - direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() - direction.GetPerpendicularRight() + direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);
                dist += Lighting.GetRayIntersectDistance(maxDist, direction.GetVector3() - direction.GetPerpendicularRight() - direction.GetPerpendicularLeft(), (index.Position + new Vector3d(0.5, 0.5, 0.5)) + direction.GetVector3() * 0.6);

                dist /= 9;

                byte baseShade = (byte)Math.Ceiling(Math.Sqrt(Math.Pow(maxDist, 2)*3));
                baseShade -= (byte)(dist / 21 * 10);

                return baseShade;
            }
            else
            {
                return 0;
            }
        }