Ejemplo n.º 1
0
        public void TestEquals()
        {
            Vector4B a = new Vector4B(false, true, false, true);
            Vector4B b = new Vector4B(true, false, true, false);
            Vector4B c = new Vector4B(false, true, false, true);

            Assert.IsTrue(a.Equals(c));
            Assert.IsTrue(c.Equals(a));
            Assert.IsTrue(a == c);
            Assert.IsTrue(c == a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);
            Assert.IsTrue(a != b);
            Assert.IsTrue(b != a);

            object objA = a;
            object objB = b;
            object objC = c;

            Assert.IsTrue(a.Equals(objA));
            Assert.IsTrue(a.Equals(objC));
            Assert.IsFalse(a.Equals(objB));

            Assert.IsTrue(objA.Equals(objC));
            Assert.IsFalse(objA.Equals(objB));

            Assert.IsFalse(a.Equals(null));
            Assert.IsFalse(a.Equals(5));
        }
Ejemplo n.º 2
0
 public void Construct2()
 {
     Vector4B v = new Vector4B(new Vector2B(false, false), true, true);
     Assert.IsFalse(v.X);
     Assert.IsFalse(v.Y);
     Assert.IsTrue(v.Z);
     Assert.IsTrue(v.W);
 }
Ejemplo n.º 3
0
 public void XY()
 {
     Vector4B a = new Vector4B(false, true, false, true);
     Vector2B xy = a.XY;
     Assert.IsFalse(xy.X);
     Assert.IsTrue(xy.Y);
 }
Ejemplo n.º 4
0
 public void XYZ()
 {
     Vector4B a = new Vector4B(false, true, false, true);
     Vector3B xyz = a.XYZ;
     Assert.IsFalse(xyz.X);
     Assert.IsTrue(xyz.Y);
     Assert.IsFalse(xyz.Z);
 }
Ejemplo n.º 5
0
 public void ToVector4H()
 {
     Vector4B a = new Vector4B(false, false, true, true);
     Vector4H sA = a.ToVector4H();
     Assert.AreEqual((Half)0, sA.X);
     Assert.AreEqual((Half)0, sA.Y);
     Assert.AreEqual((Half)1, sA.Z);
     Assert.AreEqual((Half)1, sA.W);
 }
Ejemplo n.º 6
0
 public void TestToString()
 {
     CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
     try
     {
         Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
         Vector4B a = new Vector4B(false, true, false, true);
         Assert.AreEqual("(False, True, False, True)", a.ToString());
     }
     finally
     {
         Thread.CurrentThread.CurrentCulture = originalCulture;
     }
 }
Ejemplo n.º 7
0
 public void ToVector4F()
 {
     Vector4B a = new Vector4B(false, false, true, true);
     Vector4F sA = a.ToVector4F();
     Assert.AreEqual(0.0f, sA.X, 1e-7);
     Assert.AreEqual(0.0f, sA.Y, 1e-7);
     Assert.AreEqual(1.0f, sA.Z, 1e-7);
     Assert.AreEqual(1.0f, sA.W, 1e-7);
 }
Ejemplo n.º 8
0
 public void ToVector4I()
 {
     Vector4B a = new Vector4B(false, false, true, true);
     Vector4I sA = a.ToVector4I();
     Assert.AreEqual(0, sA.X);
     Assert.AreEqual(0, sA.Y);
     Assert.AreEqual(1, sA.Z);
     Assert.AreEqual(1, sA.W);
 }
Ejemplo n.º 9
0
        public void TestGetHashCode()
        {
            Vector4B a = new Vector4B(false, true, false, true);
            Vector4B b = new Vector4B(true, false, true, false);
            Vector4B c = new Vector4B(false, true, false, true);

            Assert.AreEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
Ejemplo n.º 10
0
        public void GenCubeFace(ref TerraCube cube, CubeFaces cubeFace, ref Vector4B cubePosition, ref Vector3I cubePosiInWorld, VisualChunk chunk, ref TerraCube topCube, Dictionary <long, int> verticeDico)
        {
            byte      yBlockOffset      = 0;
            int       verticeCubeOffset = chunk.Graphics.SolidCubeVertices.Count;
            int       indiceCubeOffset  = chunk.Graphics.SolidCubeIndices.Count;
            ByteColor newColor          = cube.EmissiveColor;

            BlockProfile blockProfile    = _wp.WorldParameters.Configuration.BlockProfiles[cube.Id];
            bool         IsEmissiveColor = blockProfile.IsEmissiveColorLightSource;
            //Les 4 vertex de ma face.... en fct de leur position dans le cube leur valeur en Z va changer ! (Face Top, Bottom, ...)
            Vector4B topLeft;
            Vector4B topRight;
            Vector4B bottomLeft;
            Vector4B bottomRight;

            //x = Is Upper VErtex or not
            //y = Cube Face
            //z = Not used
            //w = Cube "Offset"

            //GetBlock Offset
            //This "natural" offset should only be made when the upper block is not the same as the block itself
            if (topCube.Id != cube.Id)
            {
                yBlockOffset = (byte)(blockProfile.YBlockOffset * 255);
            }

            Vector4B vertexInfo = new Vector4B((byte)0, (byte)cubeFace, (byte)(0), yBlockOffset);

            long hashVertex;
            int  generatedVertex = 0;
            int  vertexOffset0, vertexOffset1, vertexOffset2, vertexOffset3;

            //Get the index of the current cube.
            int baseIndex = _cubesHolder.Index(ref cubePosiInWorld);

            int[] ind = new int[9];

            ChunkColumnInfo chunkInfo = chunk.BlockData.GetColumnInfo(cubePosition.X, cubePosition.Z);

            Vector4B biomeInfo = new Vector4B(chunkInfo.Moisture, chunkInfo.Temperature, blockProfile.BiomeColorArrayTexture, blockProfile.SideOffsetMultiplier);

            switch (cubeFace)
            {
            case CubeFaces.Front:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Z, SingleArrayChunkContainer.IdxRelativeMove.Z_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Z, ind, false);

                ByteColor Back_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor BackLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BackRight_Cube       = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor BackTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor BackBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor BackLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BackRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor BackLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BackRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ?_cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(0, 1, 1, 0);
                topRight    = cubePosition + new Vector4B(1, 1, 1, 0);
                bottomLeft  = cubePosition + new Vector4B(0, 0, 1, 0);
                bottomRight = cubePosition + new Vector4B(1, 0, 1, 0);

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackTop_Cube, BackLeftTop_Cube);
                    }
                    vertexInfo.X = 1;

                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Front.AnimationSpeed, blockProfile.Tex_Front.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackTop_Cube, BackRightTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Front.AnimationSpeed, blockProfile.Tex_Front.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackBottom_Cube, BackLeftBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Front.AnimationSpeed, blockProfile.Tex_Front.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackBottom_Cube, BackRightBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Front.AnimationSpeed, blockProfile.Tex_Front.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));

                break;

            case CubeFaces.Back:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Z, SingleArrayChunkContainer.IdxRelativeMove.Z_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Z, ind, false);

                ByteColor Front_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontRight_Cube       = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor FrontRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(1, 1, 0, 0);
                topRight    = cubePosition + new Vector4B(0, 1, 0, 0);
                bottomLeft  = cubePosition + new Vector4B(1, 0, 0, 0);
                bottomRight = cubePosition + new Vector4B(0, 0, 0, 0);

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontLeftTop_Cube, FrontLeft_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Back.AnimationSpeed, blockProfile.Tex_Back.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontRight_Cube, FrontRightTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Back.AnimationSpeed, blockProfile.Tex_Back.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontLeft_Cube, FrontLeftBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Back.AnimationSpeed, blockProfile.Tex_Back.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontRight_Cube, FrontRightBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Back.AnimationSpeed, blockProfile.Tex_Back.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));

                break;

            case CubeFaces.Top:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Y, SingleArrayChunkContainer.IdxRelativeMove.Y_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Y, ind, false);

                ByteColor Bottom_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomRight_Cube       = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor BottomRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(0, 1, 0, 0);
                topRight    = cubePosition + new Vector4B(1, 1, 0, 0);
                bottomLeft  = cubePosition + new Vector4B(0, 1, 1, 0);
                bottomRight = cubePosition + new Vector4B(1, 1, 1, 0);

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Bottom_Cube, BottomLeft_Cube, BottomLeftTop_Cube, BottomTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Top.AnimationSpeed, blockProfile.Tex_Top.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Bottom_Cube, BottomRight_Cube, BottomBottom_Cube, BottomRightBottom_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Top.AnimationSpeed, blockProfile.Tex_Top.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Bottom_Cube, BottomBottom_Cube, BottomLeft_Cube, BottomLeftBottom_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Top.AnimationSpeed, blockProfile.Tex_Top.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Bottom_Cube, BottomTop_Cube, BottomRight_Cube, BottomRightTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Top.AnimationSpeed, blockProfile.Tex_Top.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));

                break;

            case CubeFaces.Bottom:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Y, SingleArrayChunkContainer.IdxRelativeMove.Y_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Y, ind, false);

                ByteColor Top_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor TopLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor TopRight_Cube       = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor TopTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor TopBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor TopLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor TopRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor TopLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor TopRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(0, 0, 1, 0);
                topRight    = cubePosition + new Vector4B(1, 0, 1, 0);
                bottomLeft  = cubePosition + new Vector4B(0, 0, 0, 0);
                bottomRight = cubePosition + new Vector4B(1, 0, 0, 0);

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopLeft_Cube, TopLeftBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Bottom.AnimationSpeed, blockProfile.Tex_Bottom.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopLeft_Cube, TopLeftTop_Cube);
                    }
                    vertexInfo.X = 0;
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Bottom.AnimationSpeed, blockProfile.Tex_Bottom.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopRight_Cube, TopRightBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Bottom.AnimationSpeed, blockProfile.Tex_Bottom.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopRight_Cube, TopRightTop_Cube);
                    }
                    vertexInfo.X = 0;
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Bottom.AnimationSpeed, blockProfile.Tex_Bottom.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));

                break;

            case CubeFaces.Left:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.X, SingleArrayChunkContainer.IdxRelativeMove.X_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.X, ind, false);

                ByteColor Right_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor RightLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor RightRight_Cube       = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor RightTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor RightBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor RightLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor RightRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor RightLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor RightRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(0, 1, 0, 0);
                bottomRight = cubePosition + new Vector4B(0, 0, 1, 0);
                bottomLeft  = cubePosition + new Vector4B(0, 0, 0, 0);
                topRight    = cubePosition + new Vector4B(0, 1, 1, 0);

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightRight_Cube, RightRightTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Left.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightLeft_Cube, RightLeftTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Left.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightRight_Cube, RightRightBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Left.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightLeft_Cube, RightLeftBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Left.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));
                break;

            case CubeFaces.Right:

                //Get the 9 Facing cubes to the face
                _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.X, SingleArrayChunkContainer.IdxRelativeMove.X_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.X, ind, false);

                ByteColor Left_Cube            = (ind[SingleArrayChunkContainer.BaseIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftLeft_Cube        = (ind[SingleArrayChunkContainer.LeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor : new ByteColor();
                ByteColor LefttRight_Cube      = (ind[SingleArrayChunkContainer.RightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftTop_Cube         = (ind[SingleArrayChunkContainer.UpIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftBottom_Cube      = (ind[SingleArrayChunkContainer.DownIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftLeftTop_Cube     = (ind[SingleArrayChunkContainer.UpLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftRightTop_Cube    = (ind[SingleArrayChunkContainer.UpRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftLeftBottom_Cube  = (ind[SingleArrayChunkContainer.DownLeftIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor : new ByteColor();
                ByteColor LeftRightBottom_Cube = (ind[SingleArrayChunkContainer.DownRightIndex] != int.MaxValue) ? _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor : new ByteColor();

                topLeft     = cubePosition + new Vector4B(1, 1, 1, 0);
                topRight    = cubePosition + new Vector4B(1, 1, 0, 0);
                bottomLeft  = cubePosition + new Vector4B(1, 0, 1, 0);
                bottomRight = cubePosition + new Vector4B(1, 0, 0, 0);

                hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset0) == false)
                {
                    vertexOffset0 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset0);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LefttRight_Cube, LeftRightTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Right.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffset << 48);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset1) == false)
                {
                    vertexOffset1 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset1);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LeftLeft_Cube, LeftLeftTop_Cube);
                    }
                    vertexInfo.X = 1;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref topLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Right.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset2) == false)
                {
                    vertexOffset2 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset2);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LeftLeft_Cube, LeftLeftBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Right.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40);
                if (verticeDico.TryGetValue(hashVertex, out vertexOffset3) == false)
                {
                    vertexOffset3 = generatedVertex + verticeCubeOffset;
                    verticeDico.Add(hashVertex, vertexOffset3);
                    if (!IsEmissiveColor)
                    {
                        newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LefttRight_Cube, LeftRightBottom_Cube);
                    }
                    vertexInfo.X = 0;
                    //if (chunk.SliceValue > 0 && newColor == ByteColor.Zero) newColor = new ByteColor(0, 0, 0, 40);
                    chunk.Graphics.SolidCubeVertices.Add(new VertexCubeSolid(ref bottomRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo, ref biomeInfo, blockProfile.Tex_Right.AnimationSpeed, blockProfile.Tex_Left.Texture.AnimationFrames));
                    generatedVertex++;
                }

                //Create Vertices
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset3));

                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset1));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset2));
                chunk.Graphics.SolidCubeIndices.Add((ushort)(vertexOffset0));

                break;
            }
        }
Ejemplo n.º 11
0
        private void GenerateCubesFace(CubeFaces cubeFace, VisualChunk chunk)
        {
            TerraCube    currentCube, neightborCube, topCube;
            BlockProfile blockProfile, neightborCubeProfile;

            Vector4B cubePosiInChunk = new Vector4B(0, 0, 0, 1);
            Vector3I cubePosiInWorld;
            int      XWorld, YWorld, ZWorld;
            int      neightborCubeIndex;

            int baseCubeIndex = _cubesHolder.Index(chunk.CubeRange.Position.X, chunk.CubeRange.Position.Y, chunk.CubeRange.Position.Z);
            int cubeIndexX    = baseCubeIndex;
            int cubeIndexZ    = baseCubeIndex;
            int cubeIndex     = baseCubeIndex;

            var worldRangeMaxX = _visualWorldParameters.WorldRange.Max.X;
            var worldRangeMaxY = _visualWorldParameters.WorldRange.Max.Y;
            var worldRangeMaxZ = _visualWorldParameters.WorldRange.Max.Z;
            int xNeight, yNeight, zNeight;

            byte yMin = (byte)(chunk.Graphics.SliceValue == -1 ? 0 : Math.Max(0, chunk.Graphics.SliceValue - 5));
            byte yMax = (byte)(chunk.Graphics.SliceValue == -1 ? chunk.CubeRange.Size.Y : chunk.Graphics.SliceValue);

            Dictionary <long, int> verticeDico = new Dictionary <long, int>();

            for (byte x = 0; x < AbstractChunk.ChunkSize.X; x++)
            {
                XWorld = (x + chunk.CubeRange.Position.X);
                if (x != 0)
                {
                    cubeIndexX += _cubesHolder.MoveX;
                    cubeIndexZ  = cubeIndexX;
                    cubeIndex   = cubeIndexX;
                }

                for (byte z = 0; z < AbstractChunk.ChunkSize.Z; z++)
                {
                    ZWorld = (z + chunk.CubeRange.Position.Z);

                    if (z != 0)
                    {
                        cubeIndexZ += _cubesHolder.MoveZ;
                        cubeIndex   = cubeIndexZ;
                    }

                    for (byte y = yMin; y < yMax; y++)
                    {
                        //_cubeRange in fact identify the chunk, the chunk position in the world being _cubeRange.Min
                        YWorld = (y + chunk.CubeRange.Position.Y);

                        if (y != yMin)
                        {
                            cubeIndex += _cubesHolder.MoveY;
                        }
                        else
                        {
                            cubeIndex += _cubesHolder.MoveY * yMin;
                        }

                        //_cubesHolder.Cubes[] is the BIG table containing all terraCube in the visible world.
                        //For speed access, I use an array with only one dimension, thus the table index must be computed from the X, Y, Z position of the terracube.
                        //Computing myself this index, is faster than using an array defined as [x,y,z]

                        //Terra Cube contain only the data that are variables, and could be different between 2 cube.
                        currentCube = _cubesHolder.Cubes[cubeIndex];

                        // ? Am I an Air Cube ? ==> Default Value, not needed to render !
                        if (currentCube.Id == WorldConfiguration.CubeId.Air)
                        {
                            continue;
                        }

                        //The Cube profile contain the value that are fixed for a block type.
                        blockProfile = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[currentCube.Id];

                        cubePosiInWorld   = new Vector3I(XWorld, YWorld, ZWorld);
                        cubePosiInChunk.X = x; //cubePosiInChunk = new Vector4B(x, y, z);
                        cubePosiInChunk.Y = y;
                        cubePosiInChunk.Z = z;
                        //Check to see if the face needs to be generated or not !
                        //Border Chunk test ! ==> Don't generate faces that are "border" chunks
                        //BorderChunk value is true if the chunk is at the border of the visible world.
                        int topCubeIndex = cubeIndex + _cubesHolder.MoveY;

                        xNeight = x;
                        yNeight = y;
                        zNeight = z;

                        switch (cubeFace)
                        {
                        case CubeFaces.Back:
                            if (ZWorld - 1 < _visualWorldParameters.WorldRange.Position.Z)
                            {
                                continue;
                            }
                            neightborCubeIndex = _cubesHolder.FastIndex(cubeIndex, ZWorld, SingleArrayChunkContainer.IdxRelativeMove.Z_Minus1);
                            zNeight--;
                            break;

                        case CubeFaces.Front:
                            if (ZWorld + 1 >= worldRangeMaxZ)
                            {
                                continue;
                            }
                            neightborCubeIndex = _cubesHolder.FastIndex(cubeIndex, ZWorld, SingleArrayChunkContainer.IdxRelativeMove.Z_Plus1);
                            zNeight++;
                            break;

                        case CubeFaces.Bottom:
                            if (YWorld - 1 < yMin)
                            {
                                continue;
                            }
                            neightborCubeIndex = cubeIndex - _cubesHolder.MoveY;
                            yNeight--;
                            break;

                        case CubeFaces.Top:
                            if (YWorld + 1 > worldRangeMaxY)
                            {
                                continue;
                            }
                            neightborCubeIndex = topCubeIndex;
                            yNeight++;
                            break;

                        case CubeFaces.Left:
                            if (XWorld - 1 < _visualWorldParameters.WorldRange.Position.X)
                            {
                                continue;
                            }
                            neightborCubeIndex = _cubesHolder.FastIndex(cubeIndex, XWorld, SingleArrayChunkContainer.IdxRelativeMove.X_Minus1);
                            xNeight--;
                            break;

                        case CubeFaces.Right:
                            if (XWorld + 1 >= worldRangeMaxX)
                            {
                                continue;
                            }
                            neightborCubeIndex = _cubesHolder.FastIndex(cubeIndex, XWorld, SingleArrayChunkContainer.IdxRelativeMove.X_Plus1);
                            xNeight++;
                            break;

                        default:
                            throw new NullReferenceException();
                        }

                        if (YWorld + 1 < yMax)
                        {
                            neightborCube = _cubesHolder.Cubes[neightborCubeIndex];
                        }
                        else
                        {
                            neightborCube = new TerraCube(WorldConfiguration.CubeId.Air);
                        }

                        neightborCubeProfile = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[neightborCube.Id];

                        //Check if a tag is present and ICubeYOffsetModifier is implementad by the tag;
                        float cubeYOffset = (float)blockProfile.YBlockOffset;    //Natural YOffset of the Cube
                        if (blockProfile.IsTaggable)
                        {
                            BlockTag             tag       = chunk.BlockData.GetTag(new Vector3I(x, y, z));
                            ICubeYOffsetModifier tagOffset = tag as ICubeYOffsetModifier;   //If block is taggle then it will overide the natural UOffset
                            if (tagOffset != null)
                            {
                                cubeYOffset = tagOffset.YOffset;
                            }
                        }

                        float neightborcubeYOffset = (float)neightborCubeProfile.YBlockOffset;
                        if (neightborCubeProfile.IsTaggable)
                        {
                            //Find the chunk where this neightboor is located !! (Could be a chunk next to this one !)
                            Vector3I    NeightCubeWorldPosition = new Vector3I(xNeight + chunk.CubeRange.Position.X, yNeight, zNeight + chunk.CubeRange.Position.Z);
                            VisualChunk neighbChunk             = WorldChunks.GetChunk(NeightCubeWorldPosition);

                            BlockTag             tag       = neighbChunk.BlockData.GetTag(new Vector3I(NeightCubeWorldPosition.X - neighbChunk.CubeRange.Position.X, yNeight, NeightCubeWorldPosition.Z - neighbChunk.CubeRange.Position.Z));
                            ICubeYOffsetModifier tagOffset = tag as ICubeYOffsetModifier;
                            if (tagOffset != null)
                            {
                                neightborcubeYOffset = tagOffset.YOffset;
                            }
                        }

                        bool yOffsetDiff = (cubeYOffset < neightborcubeYOffset && cubeFace != CubeFaces.Top) || (cubeYOffset > 0 && cubeFace == CubeFaces.Top); // && neightborCube.Id != currentCube.Id);

                        switch (blockProfile.CubeFamilly)
                        {
                        case enuCubeFamilly.Solid:
                            //Default linked to : CubeMeshFactory.GenSolidCubeFace;
                            if (!yOffsetDiff && !_solidCubeMeshFactory.FaceGenerationCheck(ref currentCube, ref cubePosiInWorld, cubeFace, ref neightborCube))
                            {
                                continue;
                            }
                            topCube = _cubesHolder.Cubes[topCubeIndex];
                            _solidCubeMeshFactory.GenCubeFace(ref currentCube, cubeFace, ref cubePosiInChunk, ref cubePosiInWorld, chunk, ref topCube, verticeDico);
                            break;

                        case enuCubeFamilly.Liquid:
                            //Default linked to : CubeMeshFactory.GenLiquidCubeFace;

                            //In case of Water block, never display the bottom or up face if both cube are of the same type !
                            if (cubeFace == CubeFaces.Top || cubeFace == CubeFaces.Bottom)
                            {
                                if (neightborCube.Id == currentCube.Id)
                                {
                                    continue;
                                }
                            }

                            if (!yOffsetDiff && !_liquidCubeMeshFactory.FaceGenerationCheck(ref currentCube, ref cubePosiInWorld, cubeFace, ref neightborCube))
                            {
                                continue;
                            }
                            topCube = _cubesHolder.Cubes[topCubeIndex];
                            _liquidCubeMeshFactory.GenCubeFace(ref currentCube, cubeFace, ref cubePosiInChunk, ref cubePosiInWorld, chunk, ref topCube, verticeDico);
                            break;

                        case enuCubeFamilly.Other:
                            break;
                        }
                    }
                }
            }
            verticeDico.Clear();
        }
Ejemplo n.º 12
0
 public VertexSprite3D(Vector4 position, ByteColor color, Vector3 textureCoordinate, Vector4B biomeInfo)
 {
     this.Position          = position;
     this.Color             = color;
     this.TextureCoordinate = textureCoordinate;
     this.MetaData          = Vector3.Zero;
     this.BiomeInfo         = biomeInfo;
 }
Ejemplo n.º 13
0
 public VertexCubeSolid(ref Vector4B position, int textureArrayId, ref ByteColor lighting, ref Vector4B vertexInfo, ref Vector4B biomeInfo, byte animationSpeed, byte maxAnimationFrame)
 {
     this.VertexInfo = vertexInfo;
     this.Color      = lighting;
     this.Position   = position;
     this.ArrayId    = (ushort)textureArrayId;
     this.BiomeInfo  = biomeInfo;
     Dummy           = 0;
     Animation       = new Vector4B()
     {
         X = animationSpeed, Y = maxAnimationFrame
     };
 }