//Handle Cube removed / added sound private void _chunkEntityImpactManager_BlockReplaced(object sender, LandscapeBlockReplacedEventArgs e) { BlockProfile NewBlockTypeProfile = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[e.NewBlockType]; BlockProfile PreviousBlockTypeProfile = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[e.PreviousBlock.Id]; if (e.NewBlockType == WorldConfiguration.CubeId.Air && PreviousBlockTypeProfile.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid) { return; } if (NewBlockTypeProfile.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid && e.PreviousBlock.Id == WorldConfiguration.CubeId.Air) { return; } if (NewBlockTypeProfile.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid && PreviousBlockTypeProfile.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid) { return; } if (e.NewBlockType == WorldConfiguration.CubeId.Air) { PlayBlockTake(e.Position); } else { PlayBlockPut(e.Position); } }
//Default Face Generation Checks ! public bool FaceGenerationCheck(ref TerraCube cube, ref Vector3I cubePosiInWorld, CubeFaces cubeFace, ref TerraCube NeightBorFaceCube) { //if (cubeFace != CubeFaces.Top) //{ // blockProfile NeightBorProfile = _wp.WorldParameters.Configuration.CubeProfiles[NeightBorFaceCube.Id]; // if ((!NeightBorProfile.IsBlockingLight && NeightBorProfile.CubeFamilly != enuCubeFamilly.Liquid)) // { // return true; // } //}else{ // if (cubePosiInWorld.Y == seaLevel || NeightBorFaceCube.Id == WorldConfiguration.CubeId.Air) // { // return true; // } //} BlockProfile NeightBorProfile = _wp.WorldParameters.Configuration.BlockProfiles[NeightBorFaceCube.Id]; if ((!NeightBorProfile.IsBlockingLight && NeightBorProfile.CubeFamilly != enuCubeFamilly.Liquid)) { return(true); } return(false); }
private void CheckHeadUnderWater() { if (_cubesHolder.IndexYSafe(MathHelper.Floor(CameraWorldPosition.X), MathHelper.Floor(CameraWorldPosition.Y), MathHelper.Floor(CameraWorldPosition.Z), out _headCubeIndex)) { //Get the cube at the camera position ! _headCube = _cubesHolder.Cubes[_headCubeIndex]; //Get Feet block int feetBlockIdx = _cubesHolder.FastIndex(_headCubeIndex, MathHelper.Floor(CameraWorldPosition.Y), SingleArrayChunkContainer.IdxRelativeMove.Y_Minus1); TerraCube feetBlock = _cubesHolder.Cubes[feetBlockIdx]; var belowIndex = _cubesHolder.FastIndex(feetBlockIdx, MathHelper.Floor(CameraWorldPosition.Y) - 1, SingleArrayChunkContainer.IdxRelativeMove.Y_Minus1); if (belowIndex < 0 || belowIndex > _cubesHolder.Cubes.Length) { return; } TerraCube BelowfeetBlock = _cubesHolder.Cubes[belowIndex]; if (_visualWorldParameters.WorldParameters.Configuration.BlockProfiles[feetBlock.Id].CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid && (_visualWorldParameters.WorldParameters.Configuration.BlockProfiles[BelowfeetBlock.Id].CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid || _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[_headCube.Id].CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid)) { if (_playerCharacter.DisplacementMode == EntityDisplacementModes.Walking) { _playerCharacter.DisplacementMode = EntityDisplacementModes.Swiming; } } else { if (_playerCharacter.DisplacementMode == EntityDisplacementModes.Swiming) { _playerCharacter.DisplacementMode = EntityDisplacementModes.Walking; } } //Eyes under water (Used to change view Color) BlockProfile headCubeProfile = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[_headCube.Id]; if (headCubeProfile.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid) { int AboveHead = _cubesHolder.FastIndex(_headCubeIndex, MathHelper.Floor(CameraWorldPosition.Y), SingleArrayChunkContainer.IdxRelativeMove.Y_Plus1); if (_cubesHolder.Cubes[AboveHead].Id == WorldConfiguration.CubeId.Air) { //Check the offset of the water var Offset = CameraWorldPosition.Y - MathHelper.Floor(CameraWorldPosition.Y); if (Offset >= 1 - _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[_headCube.Id].YBlockOffset) { IsHeadInsideWater = false; return; } } IsHeadInsideWater = true; } else { IsHeadInsideWater = false; } } }
public bool DeleteBlockProfile(BlockProfile profile) { //Get cube profile id int profileID = 0; while (BlockProfiles[profileID] != profile) { profileID++; } if (profileID <= 18) { return(false); //Don't remove system cube } //New Array BlockProfile[] newArray = new BlockProfile[255]; //Copy until the ID from old to new int i; for (i = 0; i < profileID; i++) { newArray[i] = BlockProfiles[i]; } //Copy the Old array to the new one skipping the removed Block for (; i < BlockProfiles.Length - 1; i++) { newArray[i] = BlockProfiles[i + 1]; } BlockProfiles = newArray; return(true); }
protected override void CreateDefaultCubeProfiles() { BlockProfiles = new BlockProfile[255]; int id = 0; //Air Block BlockProfiles[id] = (new BlockProfile() { Name = "Air", Description = "A cube", Id = 0, Tex_Top = new TextureData(), Tex_Bottom = new TextureData(), Tex_Back = new TextureData(), Tex_Front = new TextureData(), Tex_Left = new TextureData(), Tex_Right = new TextureData(), IsSeeThrough = true, CubeFamilly = Enums.enuCubeFamilly.Solid, Friction = 0.25f, IsSystemCube = true }); foreach (var processorInjectedCube in ProcessorParam.InjectDefaultCubeProfiles()) { id++; BlockProfiles[id] = processorInjectedCube; } base.CreateDefaultCubeProfiles(); }
public override PickType CanPickBlock(BlockProfile blockProfile) { if (blockProfile.Id == WorldConfiguration.CubeId.Air) { return(PickType.Transparent); } return(PickType.Pick); }
//By default Basic collector use Block configuration for Picking public override PickType CanPickBlock(BlockProfile blockProfile) { if (blockProfile.Id == WorldConfiguration.CubeId.Air) { return(PickType.Transparent); } //Default Block Behaviours here return(blockProfile.IsPickable ? PickType.Pick : PickType.Stop); }
private void InitCollections() { BluePrints = new Dictionary <ushort, Entity>(); BlockProfiles = new BlockProfile[255]; Services = new List <Service>(); ContainerSets = new Dictionary <string, SlotContainer <BlueprintSlot> >(); Recipes = new List <Recipe>(); TreeBluePrints = new List <TreeBluePrint>(); CharacterClasses = new List <CharacterClassItem>(); }
/// <summary> /// Defines tool pick behaviour for the blocks /// </summary> /// <param name="blockProfile"></param> /// <returns></returns> public virtual PickType CanPickBlock(BlockProfile blockProfile) { if (blockProfile.Id == WorldConfiguration.CubeId.Air) { return(PickType.Transparent); } //Default Block Behaviours here return(PickType.Pick); }
public override PickType CanPickBlock(BlockProfile blockProfile) { if (blockProfile.Id == WorldConfiguration.CubeId.Air) { return(PickType.Transparent); } // don't allow to pick blocks by hand return(PickType.Stop); }
private bool SurfaceSpawnLogic(int x, int z, ChunkSpawnableEntity entity, AbstractChunk chunk, ByteChunkCursor cursor, FastRandom rnd, out Vector3D entitySpawnLocation) { entitySpawnLocation = default(Vector3D); int y; int columnInfoIndex = x * AbstractChunk.ChunkSize.Z + z; //Y base = Original world generated ground height (Before any player modification) y = chunk.BlockData.ColumnsInfo[columnInfoIndex].MaxGroundHeight; cursor.SetInternalPosition(x, y, z); // verify that we can spawn here var canSpawn = cursor.Read() != WorldConfiguration.CubeId.Air && cursor.Move(CursorRelativeMovement.Up) && cursor.Read() == WorldConfiguration.CubeId.Air && cursor.Move(CursorRelativeMovement.Up) && cursor.Read() == WorldConfiguration.CubeId.Air; // return cursor to the spawn point cursor.Move(CursorRelativeMovement.Down); if (!canSpawn) { return(false); } // Check that the block is well "Solid to entity" BlockProfile blockSpawnProfile = _config.BlockProfiles[cursor.Peek(CursorRelativeMovement.Down)]; if (!blockSpawnProfile.IsSolidToEntity) { return(false); } if (entity.IsWildChunkNeeded) { //Get Chunk master biome byte masterBiomeId = chunk.BlockData.ChunkMetaData.ChunkMasterBiomeType; //Get biome surface block layer byte surfaceBiomeCube = _config.ProcessorParam.Biomes[masterBiomeId].SurfaceCube; //If the entity need a Wild chunk, then it can only spawn on a cube surface equal to the default biome surface cube ! if (surfaceBiomeCube != blockSpawnProfile.Id) { return(false); } } // Hurray it can spawn ! :D //Add some randomnes on the cube where it will spawn double XOffset, ZOffset; XOffset = rnd.NextDouble(0.2, 0.8); ZOffset = rnd.NextDouble(0.2, 0.8); entitySpawnLocation = new Vector3D(chunk.BlockPosition.X + x + XOffset, cursor.InternalPosition.Y, chunk.BlockPosition.Z + z + ZOffset); return(true); }
//Default Face Generation Checks ! public bool FaceGenerationCheck(ref TerraCube cube, ref Vector3I cubePosiInWorld, CubeFaces cubeFace, ref TerraCube NeightBorFaceCube) { //By default I don't need to trace the cubeFace of my cube if the face NeightBor cube is blocking light ! (Not see-through) BlockProfile blockProfile = _wp.WorldParameters.Configuration.BlockProfiles[cube.Id]; BlockProfile NeighborCubeProfile = _wp.WorldParameters.Configuration.BlockProfiles[NeightBorFaceCube.Id]; if ((NeighborCubeProfile.IsSeeThrough) || ((blockProfile.SideOffsetMultiplier > 0 ^ NeighborCubeProfile.SideOffsetMultiplier > 0) && cube.Id != NeightBorFaceCube.Id)) { return(true); } //Else draw the face return(false); }
private void PopulateChunkWithItems(ByteChunkCursor cursor, GeneratedChunk chunk, ref Vector3D chunkWorldPosition, ushort bluePrintId, int x, int y, int z, FastRandom rnd, EntityFactory entityFactory, bool isBlockCentered = true) { cursor.SetInternalPosition(x, y, z); //Check that the block above is "Air" if (cursor.Peek(CursorRelativeMovement.Up) != UtopiaProcessorParams.CubeId.Air) { return; } //Check that the block below is "solid" byte blockBelow = cursor.Read(); BlockProfile blockBelowProfile = _config.BlockProfiles[blockBelow]; if (blockBelowProfile.IsSolidToEntity) { //Cloning the Entity Blue Print ! var entity = entityFactory.CreateFromBluePrint(bluePrintId); if (entity is IBlockLinkedEntity) { Vector3I linkedCubePosition = new Vector3I(chunkWorldPosition.X + x, y, chunkWorldPosition.Z + z); ((IBlockLinkedEntity)entity).LinkedCube = linkedCubePosition; } if (entity is BlockLinkedItem) { Vector3I LocationCube = new Vector3I(chunkWorldPosition.X + x, y + 1, chunkWorldPosition.Z + z); ((BlockLinkedItem)entity).BlockLocationRoot = LocationCube; } double XOffset = 0.5; double ZOffset = 0.5; if (isBlockCentered == false) { XOffset = rnd.NextDouble(0.2, 0.8); ZOffset = rnd.NextDouble(0.2, 0.8); } entity.Position = new Vector3D(chunkWorldPosition.X + x + XOffset, y + 1, chunkWorldPosition.Z + z + ZOffset); chunk.Entities.Add((StaticEntity)entity); } }
public BlockProfile CreateNewCube(BlockProfile copyFrom = null) { //Get New Cube ID. //We keep the id from 0 to 99 for "System" cubes //101 to 254 for Custom created cubes byte newProfileId = (byte)(BlockProfiles.Where(x => x != null).Max(x => x.Id) + 1); BlockProfile newCubeProfile = copyFrom ?? new BlockProfile() { Name = "NewCustomCube", Id = newProfileId, Tex_Top = new TextureData(), Tex_Bottom = new TextureData(), Tex_Back = new TextureData(), Tex_Front = new TextureData(), Tex_Left = new TextureData(), Tex_Right = new TextureData(), LightAbsorbed = 255, IsPickable = true, IsSolidToEntity = true, IsBlockingWater = true, CubeFamilly = Enums.enuCubeFamilly.Solid, Friction = 0.25f, IsSystemCube = false }; if (copyFrom != null) { newCubeProfile.Id = newProfileId; newCubeProfile.IsSystemCube = false; } if (BlockProfiles.Length <= newProfileId) { var array = BlockProfiles; Array.Resize(ref array, newProfileId + 1); BlockProfiles = array; } BlockProfiles[newProfileId] = newCubeProfile; return(newCubeProfile); }
public TerraCubeWithPosition(Vector3I pos, byte cubeId, BlockProfile profile) { BlockProfile = profile; Position = pos; Cube = new TerraCube(cubeId); }
public TerraCubeWithPosition(Vector3I pos, TerraCube cube, BlockProfile profile) { BlockProfile = profile; Position = pos; Cube = cube; }
public void GenCubeFace(ref TerraCube cube, CubeFaces cubeFace, ref Vector4B cubePosition, ref Vector3I cubePosiInWorld, VisualChunk chunk, ref TerraCube topCube, Dictionary <long, int> verticeDico) { int yBlockOffsetAsInt = 0; float yBlockOffset = 0; int verticeCubeOffset = chunk.Graphics.LiquidCubeVertices.Count; int indiceCubeOffset = chunk.Graphics.LiquidCubeIndices.Count; ByteColor newColor = cube.EmissiveColor; BlockTag tag = null; BlockProfile blockProfile = _wp.WorldParameters.Configuration.BlockProfiles[cube.Id]; //Get the Cube Tag Informations if (blockProfile.IsTaggable) { tag = chunk.BlockData.GetTag(new Vector3I(cubePosition.X, cubePosition.Y, cubePosition.Z)); } bool IsEmissiveColor = blockProfile.IsEmissiveColorLightSource; bool vertexInDico; //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; //GetBlock Offset if (blockProfile.IsTaggable && tag is ICubeYOffsetModifier) { yBlockOffset = ((ICubeYOffsetModifier)tag).YOffset; } else { //Add a naturel Offset to StillWater when touching water at the surface ! if (topCube.Id != cube.Id) { yBlockOffset = (float)blockProfile.YBlockOffset; } } yBlockOffsetAsInt = (int)(yBlockOffset * 255); ChunkColumnInfo chunkInfo = chunk.BlockData.GetColumnInfo(new Vector2I(cubePosition.X, cubePosition.Z)); Vector4B vertexInfo2 = new Vector4B(chunkInfo.Moisture, chunkInfo.Temperature, (byte)0, (byte)0); Vector4B vertexInfo1 = new Vector4B((byte)cubeFace, (byte)0, //Is "UP" vertex blockProfile.BiomeColorArrayTexture, (byte)0); long hashVertex; int generatedVertex = 0; int vertexOffset0, vertexOffset1, vertexOffset2, vertexOffset3; int[] ind = new int[9]; //Get the index of the current cube. int baseIndex = _cubesHolder.Index(ref cubePosiInWorld); 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, true); ByteColor Back_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor BackLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor BackRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor BackTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor BackBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor BackLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor BackRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor BackLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor BackRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Front.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Front.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackTop_Cube, BackLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackTop_Cube, BackRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackBottom_Cube, BackLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackBottom_Cube, BackRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.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, true); ByteColor Front_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor FrontLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor FrontRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor FrontTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor FrontBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor FrontLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor FrontRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor FrontLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor FrontRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Back.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Back.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontLeftTop_Cube, FrontLeft_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontRight_Cube, FrontRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontLeft_Cube, FrontLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontRight_Cube, FrontRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.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, true); ByteColor Bottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor BottomLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor BottomRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor BottomTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor BottomBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor BottomLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor BottomRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor BottomLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor BottomRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Top.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Top.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomLeft_Cube, BottomLeftTop_Cube, BottomTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomRight_Cube, BottomBottom_Cube, BottomRightBottom_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomBottom_Cube, BottomLeft_Cube, BottomLeftBottom_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomTop_Cube, BottomRight_Cube, BottomRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.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, true); ByteColor Top_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor TopLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor TopRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor TopTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor TopBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor TopLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor TopRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor TopLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor TopRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Bottom.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Bottom.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopLeft_Cube, TopLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopLeft_Cube, TopLeftTop_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopRight_Cube, TopRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopRight_Cube, TopRightTop_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.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, true); ByteColor Right_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor RightLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor RightRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor RightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor RightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor RightLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor RightRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor RightLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor RightRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Left.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Left.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightRight_Cube, RightRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightLeft_Cube, RightLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightRight_Cube, RightRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightLeft_Cube, RightLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.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, true); ByteColor Left_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor LeftLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor LefttRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor LeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor LeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor LeftLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor LeftRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor LeftLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor LeftRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Right.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Right.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LefttRight_Cube, LeftRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LeftLeft_Cube, LeftLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LeftLeft_Cube, LeftLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LefttRight_Cube, LeftRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); break; } }
private void WalkingSoundProcessing() { // foreach dynamic entity for (int i = 0; i < _stepsTracker.Count; i++) { DynamicEntitySoundTrack entityTrack = _stepsTracker[i]; IDynamicEntity entity = entityTrack.Entity; // first let's detect if the entity is in air Vector3D underTheFeets = entity.Position; underTheFeets.Y -= 0.01f; var result = _singleArray.GetCube(underTheFeets); if (result.IsValid == false) { return; } BlockProfile cubeUnderFeet = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[result.Cube.Id]; // no need to play step if the entity is in air or not in walking displacement mode if (cubeUnderFeet.Id == WorldConfiguration.CubeId.Air || _stepsTracker[i].Entity.DisplacementMode != Shared.Entities.EntityDisplacementModes.Walking) { var item = new DynamicEntitySoundTrack { Entity = _stepsTracker[i].Entity, Position = entity.Position, isLocalSound = _stepsTracker[i].isLocalSound }; //Save the position of the entity _stepsTracker[i] = item; continue; } // possible that entity just landed after the jump, so we need to check if the entity was in the air last time to play the landing sound Vector3D prevUnderTheFeets = entityTrack.Position; //Containing the previous DynamicEntity Position prevUnderTheFeets.Y -= 0.01f; //Compute the distance between the previous and current position, set to double distance = Vector3D.Distance(entityTrack.Position, entity.Position); // do we need to play the step sound? //Trigger only if the difference between previous memorize position and current is > 1.5 meters //Or if the previous position was in the air if (distance >= 1.5f || _singleArray.CheckCube(prevUnderTheFeets, WorldConfiguration.CubeId.Air)) { byte soundIndex = 0; var cubeResult = _singleArray.GetCube(entity.Position); if (cubeResult.IsValid) //Valid cube retrieved { BlockProfile currentCube = _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[cubeResult.Cube.Id]; //If walking on the ground, but with Feets and legs inside water block if (currentCube.CubeFamilly == Shared.Enums.enuCubeFamilly.Liquid && cubeUnderFeet.IsSolidToEntity) { //If my Head is not inside a Water block (Meaning = I've only the feet inside water) if (_singleArray.CheckCube(entity.Position + new Vector3D(0, entity.DefaultSize.Y, 0), WorldConfiguration.CubeId.Air)) { soundIndex = PlayWalkingSound(currentCube.Id, entityTrack); } } else { //Play a foot step sound only if the block under feet is solid to entity. (No water, no air, ...) if (_visualWorldParameters.WorldParameters.Configuration.BlockProfiles[cubeUnderFeet.Id].IsSolidToEntity) { soundIndex = PlayWalkingSound(cubeUnderFeet.Id, entityTrack); } } } //Save the Entity last position. var item = new DynamicEntitySoundTrack { Entity = _stepsTracker[i].Entity, Position = entity.Position, LastSound = soundIndex, isLocalSound = _stepsTracker[i].isLocalSound }; _stepsTracker[i] = item; } } }
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; } }