Esempio n. 1
0
 public override void BuildFace(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Block block)
 {
     BlockBuilder.BuildRenderer(chunk, pos, meshData, direction);
     BlockBuilder.BuildTexture(chunk, pos, meshData, direction, Textures);
     BlockBuilder.BuildColors(chunk, pos, meshData, direction);
     if (!HertzVoxConfig.UseGreedyCollider)
     {
         BlockBuilder.BuildCollider(chunk, pos, meshData, direction);
     }
 }
Esempio n. 2
0
 public override void BuildFace(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Block block)
 {
     BlockBuilder.BuildRenderer(chunk, pos, meshData, direction);
     BlockBuilder.BuildTexture(chunk, pos, meshData, direction, textures);
     BlockBuilder.BuildColors(chunk, pos, meshData, direction);
     if (Config.Toggle.UseCollisionMesh)
     {
         BlockBuilder.BuildCollider(chunk, pos, meshData, direction);
     }
 }
Esempio n. 3
0
    public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, TextureCollection texture, Block block)
    {
        float halfBlock      = (Config.Env.BlockSize / 2) + Config.Env.BlockFacePadding;
        float colliderOffest = 0.05f * Config.Env.BlockSize;
        float blockHeight    = halfBlock * 2 * (block.data2 / 255f);

        float offsetX = (halfBlock * 2 * ((byte)(block.data3 & 0x0F) / 32f)) - (halfBlock / 2);
        float offsetZ = (halfBlock * 2 * ((byte)((block.data3 & 0xF0) >> 4) / 32f)) - (halfBlock / 2);

        //Converting the position to a vector adjusts it based on block size and gives us real world coordinates for x, y and z
        Vector3 vPos         = pos;
        Vector3 vPosCollider = pos;

        vPos += new Vector3(offsetX, 0, offsetZ);

        float blockLight = ((block.data1 / 255f) * Config.Env.BlockLightStrength) + (0.8f * Config.Env.AOStrength);

        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x - halfBlock, vPos.y - halfBlock + blockHeight, vPos.z - halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock + blockHeight, vPos.z + halfBlock));
        meshData.AddVertex(new Vector3(vPos.x + halfBlock, vPos.y - halfBlock, vPos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, vPos, meshData, Direction.north, texture);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x + halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(vPosCollider.x - halfBlock, vPosCollider.y - halfBlock + colliderOffest, vPosCollider.z - halfBlock), collisionMesh: true);
        meshData.AddQuadTriangles(collisionMesh: true);
    }
Esempio n. 4
0
    public static void CrossMeshRenderer(Chunk chunk, BlockPos pos, MeshData meshData, Tile tilePos, Block block)
    {
        float halfBlock      = 0.5005f;
        float colliderOffest = 0.05f;
        float blockHeight    = halfBlock * 2 * (block.data2 / 255f);

        float blockLight = ((block.data1 / 255f) * Config.Env.BlockLightStrength) + (0.8f * Config.Env.AOStrength);

        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + blockHeight, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + blockHeight, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, pos, meshData, Direction.north, tilePos);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + blockHeight, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + blockHeight, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, pos, meshData, Direction.north, tilePos);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + blockHeight, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + blockHeight, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z - halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, pos, meshData, Direction.north, tilePos);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + blockHeight, pos.z - halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + blockHeight, pos.z + halfBlock));
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock, pos.z + halfBlock));
        meshData.AddQuadTriangles();
        BlockBuilder.BuildTexture(chunk, pos, meshData, Direction.north, tilePos);
        meshData.AddColors(blockLight, blockLight, blockLight, blockLight, blockLight);

        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + colliderOffest, pos.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + colliderOffest, pos.z + halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(pos.x + halfBlock, pos.y - halfBlock + colliderOffest, pos.z - halfBlock), collisionMesh: true);
        meshData.AddVertex(new Vector3(pos.x - halfBlock, pos.y - halfBlock + colliderOffest, pos.z - halfBlock), collisionMesh: true);
        meshData.AddQuadTriangles(collisionMesh: true);
    }
Esempio n. 5
0
 public override void BuildFace(Chunk chunk, BlockPos pos, MeshData meshData, BlockDirection blockDirection, Block block)
 {
     BlockBuilder.BuildRenderer(chunk, pos, meshData, blockDirection);
     BlockBuilder.BuildTexture(chunk, pos, meshData, blockDirection, new Tile[] {
         new Tile((int)textures[0].x, (int)textures[0].y),
         new Tile((int)textures[1].x, (int)textures[1].y),
         new Tile((int)textures[2].x, (int)textures[2].y),
         new Tile((int)textures[3].x, (int)textures[3].y),
         new Tile((int)textures[4].x, (int)textures[4].y),
         new Tile((int)textures[5].x, (int)textures[5].y)
     });
     BlockBuilder.BuildColors(chunk, pos, meshData, blockDirection);
     if (Config.Toggle.UseCollisionMesh)
     {
         BlockBuilder.BuildCollider(chunk, pos, meshData, blockDirection);
     }
 }